diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-26 05:11:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-07-26 05:11:33 +0000 |
commit | a751023422eadf87cd8d6484878193a4914a9d85 (patch) | |
tree | 3fca0ae6325173fc2583e7d88abe4c38e6193277 /fabrics.c | |
parent | Adding upstream version 2.0. (diff) | |
download | nvme-cli-a5004e61c84e53608ae45d8c495164f8697da020.tar.xz nvme-cli-a5004e61c84e53608ae45d8c495164f8697da020.zip |
Adding upstream version 2.1~rc0.upstream/2.1_rc0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'fabrics.c')
-rw-r--r-- | fabrics.c | 30 |
1 files changed, 21 insertions, 9 deletions
@@ -1,3 +1,4 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (C) 2016 Intel Corporation. All rights reserved. * Copyright (c) 2016 HGST, a Western Digital Company. @@ -174,6 +175,9 @@ static nvme_ctrl_t create_discover_ctrl(nvme_root_t r, nvme_host_t h, nvme_ctrl_t c; c = __create_discover_ctrl(r, h, cfg, trcfg); + if (!c) + return NULL; + if (!persistent) return c; @@ -218,7 +222,7 @@ static void print_discovery_log(struct nvmf_discovery_log *log, int numrec) printf("=====Discovery Log Entry %d======\n", i); printf("trtype: %s\n", nvmf_trtype_str(e->trtype)); printf("adrfam: %s\n", - e->traddr && strlen(e->traddr) ? + strlen(e->traddr) ? nvmf_adrfam_str(e->adrfam): ""); printf("subtype: %s\n", nvmf_subtype_str(e->subtype)); printf("treq: %s\n", nvmf_treq_str(e->treq)); @@ -383,6 +387,10 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg, nvme_ctrl_t child; int tmo = defcfg->keep_alive_tmo; + /* Skip connect if the transport types don't match */ + if (strcmp(nvme_ctrl_get_transport(c), nvmf_trtype_str(e->trtype))) + continue; + if (e->subtype == NVME_NQN_DISC) set_discovery_kato(defcfg); @@ -401,7 +409,7 @@ static int __discover(nvme_ctrl_t c, struct nvme_fabrics_config *defcfg, nvme_disconnect_ctrl(child); nvme_free_ctrl(child); } - } else if (errno == EALREADY && !quiet) { + } else if (errno == ENVME_CONNECT_ALREADY && !quiet) { char *traddr = log->entries[i].traddr; space_strip_len(NVMF_TRADDR_SIZE, traddr); @@ -475,6 +483,8 @@ static nvme_ctrl_t lookup_discover_ctrl(nvme_root_t r, struct tr_config *trcfg) static char *get_default_trsvcid(const char *transport, bool discovery_ctrl) { + if (!transport) + return NULL; if (!strcmp(transport, "tcp")) { if (discovery_ctrl) { /* Default port for NVMe/TCP discovery controllers */ @@ -526,6 +536,7 @@ static int discover_from_conf_file(nvme_root_t r, nvme_host_t h, f = fopen(PATH_NVMF_DISC, "r"); if (f == NULL) { + fprintf(stderr, "No params given and no %s\n", PATH_NVMF_DISC); errno = ENOENT; return -1; } @@ -650,11 +661,12 @@ int nvmf_discover(const char *desc, int argc, char **argv, bool connect) } ret = nvme_scan_topology(r, NULL, NULL); if (ret < 0) { - fprintf(stderr, "Failed to scan topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; } + nvme_read_config(r, config_file); if (!hostnqn) hostnqn = hnqn = nvmf_hostnqn_from_file(); @@ -821,7 +833,7 @@ int nvmf_connect(const char *desc, int argc, char **argv) if (strcmp(transport, "loop")) { if (!traddr) { fprintf(stderr, - "required argument [--address | -a] not specified for transport %s\n", + "required argument [--traddr | -a] not specified for transport %s\n", transport); return EINVAL; } @@ -838,7 +850,7 @@ int nvmf_connect(const char *desc, int argc, char **argv) } ret = nvme_scan_topology(r, NULL, NULL); if (ret < 0) { - fprintf(stderr, "Failed to scan topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; @@ -934,7 +946,7 @@ 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 topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; @@ -1021,7 +1033,7 @@ 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 topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; @@ -1092,7 +1104,7 @@ 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 topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; @@ -1231,7 +1243,7 @@ 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 topoplogy: %s\n", + fprintf(stderr, "Failed to scan topology: %s\n", nvme_strerror(errno)); nvme_free_tree(r); return ret; |