diff --git a/.gitignore b/.gitignore index fc68fce..cedd5a8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SOURCES/v1.12.tar.gz +SOURCES/v1.14.tar.gz diff --git a/.nvme-cli.metadata b/.nvme-cli.metadata index a1de130..5ba5ed1 100644 --- a/.nvme-cli.metadata +++ b/.nvme-cli.metadata @@ -1 +1 @@ -ec24fdc3944cff338170f8a98e95e9ebe90463f2 SOURCES/v1.12.tar.gz +0cdeb36c3a661104f49617fb1b625edab18234b2 SOURCES/v1.14.tar.gz diff --git a/SOURCES/0001-Prevent-compiler-from-optimizing-mmio_read64-to-sing.patch b/SOURCES/0001-Prevent-compiler-from-optimizing-mmio_read64-to-sing.patch deleted file mode 100644 index 57b888a..0000000 --- a/SOURCES/0001-Prevent-compiler-from-optimizing-mmio_read64-to-sing.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 33e60ff64a043b189d2661543b417b21b6f3667b Mon Sep 17 00:00:00 2001 -From: Adam Judge -Date: Tue, 9 Jun 2020 15:58:49 -0400 -Subject: [PATCH] Prevent compiler from optimizing mmio_read64 to single 64b - read - ---- - nvme-print.c | 8 ++++++-- - 1 file changed, 6 insertions(+), 2 deletions(-) - -diff --git a/nvme-print.c b/nvme-print.c -index fc8f99d..c0de928 100644 ---- a/nvme-print.c -+++ b/nvme-print.c -@@ -1311,9 +1311,13 @@ static inline uint32_t mmio_read32(void *addr) - /* Access 64-bit registers as 2 32-bit; Some devices fail 64-bit MMIO. */ - static inline __u64 mmio_read64(void *addr) - { -- __le32 *p = addr; -+ const volatile __u32 *p = addr; -+ __u32 low, high; -+ -+ low = le32_to_cpu(*p); -+ high = le32_to_cpu(*(p + 1)); - -- return le32_to_cpu(*p) | ((uint64_t)le32_to_cpu(*(p + 1)) << 32); -+ return ((__u64) high << 32) | low; - } - - static void json_ctrl_registers(void *bar) --- -2.31.1 - diff --git a/SOURCES/0001-nvme-topology-no-error-message-when-openeing-of-cont.patch b/SOURCES/0001-nvme-topology-no-error-message-when-openeing-of-cont.patch new file mode 100644 index 0000000..a611a60 --- /dev/null +++ b/SOURCES/0001-nvme-topology-no-error-message-when-openeing-of-cont.patch @@ -0,0 +1,46 @@ +From 7c2833a047ad9754ccb9b26b863f3967b85aad57 Mon Sep 17 00:00:00 2001 +From: Daniel Wagner +Date: Wed, 2 Jun 2021 15:42:42 +0200 +Subject: [PATCH] nvme-topology: no error message when openeing of controller + fails + +scan_ctrl() tries to open the controller device but this operation is +expected to fail for fabric setups when a path is down. This can lead +to the situation where the subsystem is in a healthy state, e.g. at +least one path is in live state. In this scenario a failure is printed +although everything is fine. + +This is especially a problem for NVMe/TCP configs where the controller +remains in 'connecting' state for 10 minutes following a path +down. All that time 'nvme list' ends up in errors and that's a major +irritant for end users. This also makes CI automation more complex +than needed. + +Just drop the error message as we have other error paths in this +function where we just bail out if they fail without printing an +error message. + +Signed-off-by: Daniel Wagner +--- + nvme-topology.c | 4 +--- + 1 file changed, 1 insertion(+), 3 deletions(-) + +diff --git a/nvme-topology.c b/nvme-topology.c +index 31cf7f9..47121e4 100644 +--- a/nvme-topology.c ++++ b/nvme-topology.c +@@ -319,10 +319,8 @@ static int scan_ctrl(struct nvme_ctrl *c, char *p, __u32 ns_instance) + return ret; + + fd = open(path, O_RDONLY); +- if (fd < 0) { +- fprintf(stderr, "Failed to open %s\n", path); ++ if (fd < 0) + goto free; +- } + + ret = nvme_identify_ctrl(fd, &c->id); + if (ret < 0) +-- +2.27.0 + diff --git a/SOURCES/0002-fabrics-skip-connect-if-transport-type-doesn-t-match.patch b/SOURCES/0002-fabrics-skip-connect-if-transport-type-doesn-t-match.patch new file mode 100644 index 0000000..057d87e --- /dev/null +++ b/SOURCES/0002-fabrics-skip-connect-if-transport-type-doesn-t-match.patch @@ -0,0 +1,40 @@ +From edf0998f5a668b141c73a9648acf427105586372 Mon Sep 17 00:00:00 2001 +From: Martin George +Date: Sat, 5 Jun 2021 15:16:26 +0530 +Subject: [PATCH] fabrics: skip connect if transport type doesn't match + +Discovery log page data may include records belonging to different +transport types. If during a nvme connect-all, a connect is attempted +on a record that doesn't match the transport type passed here, it +would end up in a connect failure for that record. For e.g. one would +see the below error if a connect is attempted on a tcp record but the +transport type passed here is 'fc' and its associated parameters: + +nvme_tcp: malformed src address passed: nn-0xXXXX:pn-0xYYYY + +Fix this by proceeding with the connect only if the appropriate +transport type matches a given record during the connect-all. + +Signed-off-by: Martin George +--- + fabrics.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/fabrics.c b/fabrics.c +index db42ddb..6cc142d 100644 +--- a/fabrics.c ++++ b/fabrics.c +@@ -1354,6 +1354,10 @@ static bool should_connect(struct nvmf_disc_rsp_page_entry *entry) + if (cargs_match_found(entry)) + return false; + ++ /* skip connect if the transport type doesn't match */ ++ if (strcmp(fabrics_cfg.transport, trtype_str(entry->trtype))) ++ return false; ++ + if (!fabrics_cfg.matching_only || !fabrics_cfg.traddr) + return true; + +-- +2.27.0 + diff --git a/SOURCES/0002-nvme-print-split-pmrmsc-into-pmrmscl-and-pmrmscu.patch b/SOURCES/0002-nvme-print-split-pmrmsc-into-pmrmscl-and-pmrmscu.patch deleted file mode 100644 index f53033b..0000000 --- a/SOURCES/0002-nvme-print-split-pmrmsc-into-pmrmscl-and-pmrmscu.patch +++ /dev/null @@ -1,122 +0,0 @@ -diff --git a/linux/nvme.h b/linux/nvme.h -index f2c4fdb..9e7a108 100644 ---- a/linux/nvme.h -+++ b/linux/nvme.h -@@ -172,7 +172,8 @@ enum { - NVME_REG_PMRSTS = 0x0e08, /* Persistent Memory Region Status */ - NVME_REG_PMREBS = 0x0e0c, /* Persistent Memory Region Elasticity Buffer Size */ - NVME_REG_PMRSWTP= 0x0e10, /* Persistent Memory Region Sustained Write Throughput */ -- NVME_REG_PMRMSC = 0x0e14, /* Persistent Memory Region Controller Memory Space Control */ -+ NVME_REG_PMRMSCL= 0x0e14, /* Persistent Memory Region Controller Memory Space Control Lower */ -+ NVME_REG_PMRMSCU= 0x0e18, /* Persistent Memory Region Controller Memory Space Control Upper*/ - NVME_REG_DBS = 0x1000, /* SQ 0 Tail Doorbell */ - }; - -diff --git a/nvme-print.c b/nvme-print.c -index 30fca29..93f0e5a 100644 ---- a/nvme-print.c -+++ b/nvme-print.c -@@ -1293,12 +1293,18 @@ static void nvme_show_registers_pmrswtp(__u32 pmrswtp) - nvme_register_pmr_pmrszu_to_string(pmrswtp & 0x0000000f)); - } - --static void nvme_show_registers_pmrmsc(uint64_t pmrmsc) -+static void nvme_show_registers_pmrmscl(uint32_t pmrmscl) - { -- printf("\tController Base Address (CBA) : %" PRIx64 "\n", -- (pmrmsc & 0xfffffffffffff000) >> 12); -- printf("\tController Memory Space Enable (CMSE) : %" PRIx64 "\n\n", -- (pmrmsc & 0x0000000000000002) >> 1); -+ printf("\tController Base Address (CBA): %#x\n", -+ (pmrmscl & 0xfffff000) >> 12); -+ printf("\tController Memory Space Enable (CMSE): %#x\n\n", -+ (pmrmscl & 0x00000002) >> 1); -+} -+ -+static void nvme_show_registers_pmrmscu(uint32_t pmrmscu) -+{ -+ printf("\tController Base Address (CBA): %#x\n", -+ pmrmscu); - } - - static inline uint32_t mmio_read32(void *addr) -@@ -1318,9 +1324,10 @@ static inline __u64 mmio_read64(void *addr) - - static void json_ctrl_registers(void *bar) - { -- uint64_t cap, asq, acq, bpmbl, cmbmsc, pmrmsc; -+ uint64_t cap, asq, acq, bpmbl, cmbmsc; - uint32_t vs, intms, intmc, cc, csts, nssr, aqa, cmbsz, cmbloc, -- bpinfo, bprsel, cmbsts, pmrcap, pmrctl, pmrsts, pmrebs, pmrswtp; -+ bpinfo, bprsel, cmbsts, pmrcap, pmrctl, pmrsts, pmrebs, pmrswtp, -+ pmrmscl, pmrmscu; - struct json_object *root; - - cap = mmio_read64(bar + NVME_REG_CAP); -@@ -1345,7 +1352,8 @@ static void json_ctrl_registers(void *bar) - pmrsts = mmio_read32(bar + NVME_REG_PMRSTS); - pmrebs = mmio_read32(bar + NVME_REG_PMREBS); - pmrswtp = mmio_read32(bar + NVME_REG_PMRSWTP); -- pmrmsc = mmio_read64(bar + NVME_REG_PMRMSC); -+ pmrmscl = mmio_read32(bar + NVME_REG_PMRMSCL); -+ pmrmscu = mmio_read32(bar + NVME_REG_PMRMSCU); - - root = json_create_object(); - json_object_add_value_uint(root, "cap", cap); -@@ -1370,7 +1378,8 @@ static void json_ctrl_registers(void *bar) - json_object_add_value_int(root, "pmrsts", pmrsts); - json_object_add_value_int(root, "pmrebs", pmrebs); - json_object_add_value_int(root, "pmrswtp", pmrswtp); -- json_object_add_value_uint(root, "pmrmsc", pmrmsc); -+ json_object_add_value_uint(root, "pmrmscl", pmrmscl); -+ json_object_add_value_uint(root, "pmrmscu", pmrmscu); - json_print_object(root, NULL); - printf("\n"); - json_free_object(root); -@@ -1379,9 +1388,10 @@ static void json_ctrl_registers(void *bar) - void nvme_show_ctrl_registers(void *bar, bool fabrics, enum nvme_print_flags flags) - { - const unsigned int reg_size = 0x50; /* 00h to 4Fh */ -- uint64_t cap, asq, acq, bpmbl, cmbmsc, pmrmsc; -+ uint64_t cap, asq, acq, bpmbl, cmbmsc; - uint32_t vs, intms, intmc, cc, csts, nssr, aqa, cmbsz, cmbloc, bpinfo, -- bprsel, cmbsts, pmrcap, pmrctl, pmrsts, pmrebs, pmrswtp; -+ bprsel, cmbsts, pmrcap, pmrctl, pmrsts, pmrebs, pmrswtp, -+ pmrmscl, pmrmscu; - int human = flags & VERBOSE; - - if (flags & BINARY) -@@ -1411,7 +1421,8 @@ void nvme_show_ctrl_registers(void *bar, bool fabrics, enum nvme_print_flags fla - pmrsts = mmio_read32(bar + NVME_REG_PMRSTS); - pmrebs = mmio_read32(bar + NVME_REG_PMREBS); - pmrswtp = mmio_read32(bar + NVME_REG_PMRSWTP); -- pmrmsc = mmio_read64(bar + NVME_REG_PMRMSC); -+ pmrmscl = mmio_read32(bar + NVME_REG_PMRMSCL); -+ pmrmscu = mmio_read32(bar + NVME_REG_PMRMSCU); - - if (human) { - if (cap != 0xffffffff) { -@@ -1490,8 +1501,11 @@ void nvme_show_ctrl_registers(void *bar, bool fabrics, enum nvme_print_flags fla - printf("pmrswtp : %x\n", pmrswtp); - nvme_show_registers_pmrswtp(pmrswtp); - -- printf("pmrmsc : %"PRIx64"\n", pmrmsc); -- nvme_show_registers_pmrmsc(pmrmsc); -+ printf("pmrmscl : %#x\n", pmrmscl); -+ nvme_show_registers_pmrmscl(pmrmscl); -+ -+ printf("pmrmscu : %#x\n", pmrmscu); -+ nvme_show_registers_pmrmscu(pmrmscu); - } - } else { - if (cap != 0xffffffff) -@@ -1522,7 +1536,8 @@ void nvme_show_ctrl_registers(void *bar, bool fabrics, enum nvme_print_flags fla - printf("pmrsts : %x\n", pmrsts); - printf("pmrebs : %x\n", pmrebs); - printf("pmrswtp : %x\n", pmrswtp); -- printf("pmrmsc : %"PRIx64"\n", pmrmsc); -+ printf("pmrmscl : %#x\n", pmrmscl); -+ printf("pmrmscu : %#x\n", pmrmscu); - } - } - } diff --git a/SOURCES/0003-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch b/SOURCES/0003-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch new file mode 100644 index 0000000..267dd62 --- /dev/null +++ b/SOURCES/0003-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch @@ -0,0 +1,30 @@ +From 22c19f6a5b58ad9ce99d2c2a95239eab911d908e Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Tue, 22 Jun 2021 13:40:23 +0200 +Subject: [PATCH] nvme-ioctl: return -1 on failure from nvme_get_nsid() + +If the call to 'fstat' fails we should be returning '-1' (as the +errno is already set by fstat()) to be compliant with the return +values from 'ioctl()'. + +Signed-off-by: Hannes Reinecke +--- + nvme-ioctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/nvme-ioctl.c b/nvme-ioctl.c +index cc12ae6..64152b1 100644 +--- a/nvme-ioctl.c ++++ b/nvme-ioctl.c +@@ -68,7 +68,7 @@ int nvme_get_nsid(int fd) + int err = fstat(fd, &nvme_stat); + + if (err < 0) +- return -errno; ++ return err; + + return ioctl(fd, NVME_IOCTL_ID); + } +-- +2.27.0 + diff --git a/SOURCES/0004-nvme-topology-scan-all-controllers-in-scan_subsystem.patch b/SOURCES/0004-nvme-topology-scan-all-controllers-in-scan_subsystem.patch new file mode 100644 index 0000000..03bfc24 --- /dev/null +++ b/SOURCES/0004-nvme-topology-scan-all-controllers-in-scan_subsystem.patch @@ -0,0 +1,66 @@ +From ce9d818f420af6be0801004a77e91915587fc02f Mon Sep 17 00:00:00 2001 +From: Hannes Reinecke +Date: Tue, 22 Jun 2021 13:48:36 +0200 +Subject: [PATCH] nvme-topology: scan all controllers in scan_subsystem() + +When a controller is unavailable or resetting during scan_subsystem() +we should be checking all available controllers for this namespace +to avoid a spurious failure. + +Signed-off-by: Hannes Reinecke +--- + nvme-topology.c | 21 ++++++++++++--------- + 1 file changed, 12 insertions(+), 9 deletions(-) + +diff --git a/nvme-topology.c b/nvme-topology.c +index 47121e4..6d2edaa 100644 +--- a/nvme-topology.c ++++ b/nvme-topology.c +@@ -155,23 +155,23 @@ static int scan_namespace(struct nvme_namespace *n) + return ret; + + fd = open(path, O_RDONLY); +- if (fd < 0) ++ if (fd < 0) { ++ ret = fd; + goto free; +- ++ } + if (!n->nsid) { +- n->nsid = nvme_get_nsid(fd); +- if (n->nsid < 0) ++ ret = nvme_get_nsid(fd); ++ if (ret < 0) + goto close_fd; ++ n->nsid = ret; + } + + ret = nvme_identify_ns(fd, n->nsid, 0, &n->ns); +- if (ret < 0) +- goto close_fd; + close_fd: + close(fd); + free: + free(path); +- return 0; ++ return ret; + } + + static char *get_nvme_ctrl_path_ana_state(char *path, int nsid) +@@ -382,8 +382,11 @@ static int scan_subsystem(struct nvme_subsystem *s, __u32 ns_instance, int nsid) + for (i = 0; i < s->nr_namespaces; i++) { + n = &s->namespaces[i]; + n->name = strdup(ns[i]->d_name); +- n->ctrl = &s->ctrls[0]; +- scan_namespace(n); ++ for (j = 0; j < s->nr_ctrls; j++) { ++ n->ctrl = &s->ctrls[j]; ++ if (!scan_namespace(n)) ++ break; ++ } + } + } else { + i = s->nr_namespaces; +-- +2.27.0 + diff --git a/SOURCES/0005-nvme-topology-fix-controller-check-in-scan_subsystem.patch b/SOURCES/0005-nvme-topology-fix-controller-check-in-scan_subsystem.patch new file mode 100644 index 0000000..4e7ad80 --- /dev/null +++ b/SOURCES/0005-nvme-topology-fix-controller-check-in-scan_subsystem.patch @@ -0,0 +1,36 @@ +From bace574bbe55739a49e7fada5483b3d3a5ef361c Mon Sep 17 00:00:00 2001 +From: Martin George +Date: Mon, 19 Jul 2021 10:07:48 -0700 +Subject: [PATCH] nvme-topology: fix controller check in scan_subsystem() + +Fix the current check in scan_subsystem() so that it iterates +through all the available controllers till it gets a 'live' +controller for that namespace. + +Link: https://github.com/linux-nvme/nvme-cli/pull/1101 +Fixes: ce9d818 ("nvme-topology: scan all controllers in scan_subsystem()") +Signed-off-by: Martin George +Reviewed-by: Daniel Wagner +Signed-off-by: Keith Busch +--- + nvme-topology.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +diff --git a/nvme-topology.c b/nvme-topology.c +index 6d2edaa..7a6baa0 100644 +--- a/nvme-topology.c ++++ b/nvme-topology.c +@@ -384,7 +384,9 @@ static int scan_subsystem(struct nvme_subsystem *s, __u32 ns_instance, int nsid) + n->name = strdup(ns[i]->d_name); + for (j = 0; j < s->nr_ctrls; j++) { + n->ctrl = &s->ctrls[j]; +- if (!scan_namespace(n)) ++ if (!strcmp(n->ctrl->state, "live") && ++ !scan_namespace(n)) ++ + break; + } + } +-- +2.27.0 + diff --git a/SOURCES/0006-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch b/SOURCES/0006-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch new file mode 100644 index 0000000..059a2a9 --- /dev/null +++ b/SOURCES/0006-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch @@ -0,0 +1,51 @@ +From 59e7477c5a18ec4bcb1f9b1e20d2303b4e0cafb1 Mon Sep 17 00:00:00 2001 +From: Martin George +Date: Thu, 5 Aug 2021 18:01:24 +0530 +Subject: [PATCH] nvme-print: fix 'nvme list' segfault if controller is + unavailable + +Check if the controller is available before dereferencing the +controller attributes. + +Signed-off-by: Martin George +--- + nvme-print.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/nvme-print.c b/nvme-print.c +index 8a2cbc4..0c0ec3b 100755 +--- a/nvme-print.c ++++ b/nvme-print.c +@@ -6147,6 +6147,9 @@ static void nvme_show_list_item(struct nvme_namespace *n) + struct stat st; + int ret; + ++ if (!n->ctrl) ++ return; ++ + sprintf(path, "%s%s", n->ctrl->path, n->name); + ret = stat(path, &st); + if (ret < 0) +@@ -6203,6 +6206,9 @@ static void nvme_show_details_ns(struct nvme_namespace *n, bool ctrl) + char usage[128]; + char format[128]; + ++ if (!n->ctrl) ++ return; ++ + sprintf(usage,"%6.2f %2sB / %6.2f %2sB", nuse, u_suffix, + nsze, s_suffix); + sprintf(format,"%3.0f %2sB + %2d B", (double)lba, l_suffix, +@@ -6419,6 +6425,9 @@ static void json_simple_ns(struct nvme_namespace *n, struct json_object *devices + char *devnode; + struct stat st; + ++ if (!n->ctrl) ++ return; ++ + if (asprintf(&devnode, "%s%s", n->ctrl->path, n->name) < 0) + return; + +-- +2.27.0 + diff --git a/SPECS/nvme-cli.spec b/SPECS/nvme-cli.spec index 37895d4..02ebdf4 100644 --- a/SPECS/nvme-cli.spec +++ b/SPECS/nvme-cli.spec @@ -2,18 +2,21 @@ #%%global shortcommit0 %%(c=%%{commit0}; echo ${c:0:7}) Name: nvme-cli -Version: 1.12 -Release: 4%{?dist} +Version: 1.14 +Release: 3%{?dist} Summary: NVMe management command line interface License: GPLv2+ URL: https://github.com/linux-nvme/nvme-cli -#Source0: https://github.com/linux-nvme/%%{name}/archive/%%{commit0}.tar.gz Source0: https://github.com/linux-nvme/%{name}/archive/v%{version}.tar.gz Patch0: nvme-cli-makefile-dont-install-host-params-patch -Patch1: 0001-Prevent-compiler-from-optimizing-mmio_read64-to-sing.patch -Patch2: 0002-nvme-print-split-pmrmsc-into-pmrmscl-and-pmrmscu.patch +Patch1: 0001-nvme-topology-no-error-message-when-openeing-of-cont.patch +Patch2: 0002-fabrics-skip-connect-if-transport-type-doesn-t-match.patch +Patch3: 0003-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch +Patch4: 0004-nvme-topology-scan-all-controllers-in-scan_subsystem.patch +Patch5: 0005-nvme-topology-fix-controller-check-in-scan_subsystem.patch +Patch6: 0006-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch BuildRequires: libuuid-devel BuildRequires: gcc @@ -29,6 +32,10 @@ nvme-cli provides NVM-Express user space tooling for Linux. %patch0 -p1 %patch1 -p1 %patch2 -p1 +%patch3 -p1 +%patch4 -p1 +%patch5 -p1 +%patch6 -p1 %build @@ -86,11 +93,26 @@ if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then fi %changelog -* Wed Jun 09 2021 Maurizio Lombardi - 1.12-4 -- Fix for bz1970382 +* Mon Sep 13 2021 Maurizio Lombardi - 1.14-3 +- Fix crash when executing nvme-list -* Wed Mar 24 2021 Maurizio Lombardi - 1.12-3 -- Added the dependency to util-linux and exit with error code 0 from the post install script +* Thu Jul 22 2021 Maurizio Lombardi - 1.14-2 +- Merge various bugfixes + +* Wed Apr 28 2021 Maurizio Lombardi - 1.14-1 +- Update to version v1.14 + +* Tue Apr 20 2021 Maurizio Lombardi - 1.13-4 +- Rebuild to mark bz1949462 as fixed + +* Fri Apr 16 2021 Maurizio Lombardi - 1.13-3 +- KATO values fixes for various controllers + +* Wed Apr 14 2021 Maurizio Lombardi - 1.13-2 +- Add dependency to util-linux and fix the post install script + +* Wed Apr 14 2021 Maurizio Lombardi - 1.13-1 +- Update to 1.13 * Tue Jun 16 2020 Fedora Release Monitoring - 1.12-1 - Update to 1.12 (#1827581)