1
0
Fork 0

Merging upstream version 2.9.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-16 12:26:52 +01:00
parent bb95f41000
commit 698d985f9d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
451 changed files with 5896 additions and 2734 deletions

View file

@ -38,12 +38,14 @@
#include <sys/types.h>
#include <linux/types.h>
#include <libnvme.h>
#include "common.h"
#include "nvme.h"
#include "nbft.h"
#include "libnvme.h"
#include "nvme-print.h"
#include "fabrics.h"
#include "util/logging.h"
#define PATH_NVMF_DISC SYSCONFDIR "/nvme/discovery.conf"
#define PATH_NVMF_CONFIG SYSCONFDIR "/nvme/config.json"
@ -76,6 +78,7 @@ static const char *nvmf_queue_size = "number of io queue elements to use (defaul
static const char *nvmf_keep_alive_tmo = "keep alive timeout period in seconds";
static const char *nvmf_reconnect_delay = "reconnect timeout period in seconds";
static const char *nvmf_ctrl_loss_tmo = "controller loss timeout period in seconds";
static const char *nvmf_fast_io_fail_tmo = "fast I/O fail timeout (default off)";
static const char *nvmf_tos = "type of service";
static const char *nvmf_keyring = "Keyring for TLS key lookup";
static const char *nvmf_tls_key = "TLS key to use";
@ -106,6 +109,7 @@ static const char *nvmf_context = "execution context identification string";
OPT_INT("keep-alive-tmo", 'k', &c.keep_alive_tmo, nvmf_keep_alive_tmo), \
OPT_INT("reconnect-delay", 'c', &c.reconnect_delay, nvmf_reconnect_delay), \
OPT_INT("ctrl-loss-tmo", 'l', &c.ctrl_loss_tmo, nvmf_ctrl_loss_tmo), \
OPT_INT("fast_io_fail_tmo", 'F', &c.fast_io_fail_tmo, nvmf_fast_io_fail_tmo),\
OPT_INT("tos", 'T', &c.tos, nvmf_tos), \
OPT_INT("keyring", 0, &c.keyring, nvmf_keyring), \
OPT_INT("tls_key", 0, &c.tls_key, nvmf_tls_key), \
@ -195,6 +199,7 @@ static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h,
struct nvme_fabrics_config *cfg,
struct tr_config *trcfg)
{
_cleanup_free_ struct nvme_id_ctrl *id = NULL;
nvme_ctrl_t c;
c = __create_discover_ctrl(r, h, cfg, trcfg);
@ -204,10 +209,12 @@ static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h,
if (nvme_ctrl_is_unique_discovery_ctrl(c))
return c;
/* Find out the name of discovery controller */
struct nvme_id_ctrl id = { 0 };
id = nvme_alloc(sizeof(*id));
if (!id)
return NULL;
if (nvme_ctrl_identify(c, &id)) {
/* Find out the name of discovery controller */
if (nvme_ctrl_identify(c, id)) {
fprintf(stderr, "failed to identify controller, error %s\n",
nvme_strerror(errno));
nvme_disconnect_ctrl(c);
@ -215,7 +222,7 @@ static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h,
return NULL;
}
if (!strcmp(id.subnqn, NVME_DISC_SUBSYS_NAME))
if (!strcmp(id->subnqn, NVME_DISC_SUBSYS_NAME))
return c;
/*
@ -225,7 +232,7 @@ static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h,
nvme_disconnect_ctrl(c);
nvme_free_ctrl(c);
trcfg->subsysnqn = id.subnqn;
trcfg->subsysnqn = id->subnqn;
return __create_discover_ctrl(r, h, cfg, trcfg);
}
@ -636,7 +643,8 @@ char *nvmf_hostid_from_hostnqn(const char *hostnqn)
void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsigned int verbose)
{
char *hostid_from_file, *hostid_from_hostnqn;
_cleanup_free_ char *hostid_from_file = NULL;
_cleanup_free_ char *hostid_from_hostnqn = NULL;
if (!hostid)
return;
@ -646,7 +654,6 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsi
if (verbose)
fprintf(stderr,
"warning: use generated hostid instead of hostid file\n");
free(hostid_from_file);
}
if (!hostnqn)
@ -657,7 +664,6 @@ void nvmf_check_hostid_and_hostnqn(const char *hostid, const char *hostnqn, unsi
if (verbose)
fprintf(stderr,
"warning: use hostid which does not match uuid in hostnqn\n");
free(hostid_from_hostnqn);
}
}
@ -714,7 +720,9 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
if (!strcmp(config_file, "none"))
config_file = NULL;
r = nvme_create_root(stderr, map_log_level(verbose, quiet));
log_level = map_log_level(verbose, quiet);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -724,8 +732,9 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect)
nvme_root_set_application(r, context);
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}
@ -942,7 +951,9 @@ int nvmf_connect(const char *desc, int argc, char **argv)
if (!strcmp(config_file, "none"))
config_file = NULL;
r = nvme_create_root(stderr, map_log_level(verbose, quiet));
log_level = map_log_level(verbose, quiet);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -952,8 +963,9 @@ int nvmf_connect(const char *desc, int argc, char **argv)
nvme_root_set_application(r, context);
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}
@ -991,7 +1003,7 @@ int nvmf_connect(const char *desc, int argc, char **argv)
};
c = lookup_ctrl(h, &trcfg);
if (c && nvme_ctrl_get_name(c)) {
if (c && nvme_ctrl_get_name(c) && !cfg.duplicate_connect) {
fprintf(stderr, "already connected\n");
errno = EALREADY;
goto out_free;
@ -1102,7 +1114,9 @@ int nvmf_disconnect(const char *desc, int argc, char **argv)
return -EINVAL;
}
r = nvme_create_root(stderr, map_log_level(cfg.verbose, false));
log_level = map_log_level(cfg.verbose, false);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -1110,8 +1124,9 @@ int nvmf_disconnect(const char *desc, int argc, char **argv)
}
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}
@ -1170,7 +1185,9 @@ int nvmf_disconnect_all(const char *desc, int argc, char **argv)
if (ret)
return ret;
r = nvme_create_root(stderr, map_log_level(cfg.verbose, false));
log_level = map_log_level(cfg.verbose, false);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -1178,8 +1195,9 @@ int nvmf_disconnect_all(const char *desc, int argc, char **argv)
}
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}
@ -1238,7 +1256,9 @@ int nvmf_config(const char *desc, int argc, char **argv)
if (!strcmp(config_file, "none"))
config_file = NULL;
r = nvme_create_root(stderr, map_log_level(verbose, quiet));
log_level = map_log_level(verbose, quiet);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -1247,8 +1267,9 @@ int nvmf_config(const char *desc, int argc, char **argv)
if (scan_tree) {
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}
@ -1390,7 +1411,9 @@ int nvmf_dim(const char *desc, int argc, char **argv)
return -EINVAL;
}
r = nvme_create_root(stderr, map_log_level(cfg.verbose, false));
log_level = map_log_level(cfg.verbose, false);
r = nvme_create_root(stderr, log_level);
if (!r) {
fprintf(stderr, "Failed to create topology root: %s\n",
nvme_strerror(errno));
@ -1398,8 +1421,9 @@ int nvmf_dim(const char *desc, int argc, char **argv)
}
ret = nvme_scan_topology(r, NULL, NULL);
if (ret < 0) {
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
if (errno != ENOENT)
fprintf(stderr, "Failed to scan topology: %s\n",
nvme_strerror(errno));
nvme_free_tree(r);
return ret;
}