import nvme-cli-1.16-3.el8

This commit is contained in:
CentOS Sources 2022-05-10 03:18:00 -04:00 committed by Stepan Oksanichenko
parent 3a1d9cc07f
commit b58352e17c
16 changed files with 310 additions and 281 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/v1.14.tar.gz
SOURCES/v1.16.tar.gz

View File

@ -1 +1 @@
0cdeb36c3a661104f49617fb1b625edab18234b2 SOURCES/v1.14.tar.gz
2706485a7adb8134943102ff3f1a087e003f2b1f SOURCES/v1.16.tar.gz

View File

@ -0,0 +1,32 @@
From f74ac1b841b0aae73969debaed0444f0ecb03dba Mon Sep 17 00:00:00 2001
From: Martin George <marting@netapp.com>
Date: Mon, 15 Nov 2021 16:00:47 +0530
Subject: [PATCH] fabrics: fix 'nvme connect' segfault if transport type is
omitted
Check if the transport type is available before dereferencing
it in discovery_trsvcid().
Fixes: 362c90f ("fabrics: add default port number for NVMe/TCP I/O
controllers")
Signed-off-by: Martin George <marting@netapp.com>
---
fabrics.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fabrics.c b/fabrics.c
index d691191..adca89b 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -1070,6 +1070,8 @@ static void set_discovery_kato(struct fabrics_config *cfg)
static void discovery_trsvcid(struct fabrics_config *fabrics_cfg, bool discover)
{
+ if (!fabrics_cfg->transport)
+ return;
if (!strcmp(fabrics_cfg->transport, "tcp")) {
if (discover) {
/* Default port for NVMe/TCP discovery controllers */
--
2.27.0

View File

@ -1,46 +0,0 @@
From 7c2833a047ad9754ccb9b26b863f3967b85aad57 Mon Sep 17 00:00:00 2001
From: Daniel Wagner <dwagner@suse.de>
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 <dwagner@suse.de>
---
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

View File

@ -0,0 +1,29 @@
From ff8f9b6f59b574fda24a071fb0af4381c0cc6d9f Mon Sep 17 00:00:00 2001
From: Maurizio Lombardi <mlombard@redhat.com>
Date: Thu, 9 Dec 2021 12:21:51 +0100
Subject: [PATCH 1/6] fabrics: fix a buffer overrun
the uuid buffer size must be at least 37 bytes to avoid
corrupting the memory
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
fabrics.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fabrics.c b/fabrics.c
index adca89b..0766729 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -883,7 +883,7 @@ static char *hostnqn_generate_systemd(void)
static char *hostnqn_read_dmi(void)
{
- char uuid[16];
+ char uuid[37];
char *ret = NULL;
if (uuid_from_dmi(uuid) < 0)
--
2.27.0

View File

@ -1,40 +0,0 @@
From edf0998f5a668b141c73a9648acf427105586372 Mon Sep 17 00:00:00 2001
From: Martin George <marting@netapp.com>
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 <marting@netapp.com>
---
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

View File

@ -0,0 +1,36 @@
From 821935cccfcad6b18da78d42f9ddf49f4cbe0b8e Mon Sep 17 00:00:00 2001
From: Daniel Wagner <dwagner@suse.de>
Date: Thu, 9 Dec 2021 15:40:26 +0100
Subject: [PATCH 2/6] bash: Fix nvme completion
Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
completions/bash-nvme-completion.sh | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/completions/bash-nvme-completion.sh b/completions/bash-nvme-completion.sh
index 41938d7..902da01 100644
--- a/completions/bash-nvme-completion.sh
+++ b/completions/bash-nvme-completion.sh
@@ -101,8 +101,7 @@ _cmds="list list-subsys id-ctrl id-ns \
connect disconnect disconnect-all gen-hostnqn \
show-hostnqn dir-receive dir-send virt-mgmt \
rpmb boot-part-log fid-support-effects-log \
- supported-log-pages lockdown"
- supported-log-pages list-endgrp"
+ supported-log-pages lockdown list-endgrp"
# Add plugins:
for plugin in "${!_plugin_subcmds[@]}"; do
@@ -1368,7 +1367,7 @@ plugin_ymtc_opts () {
opts+=" --namespace-id= -n --raw-binary -b"
;;
"help")
- opts+=NO_OPTS
+ opts+=$NO_OPTS
;;
esac
--
2.27.0

View File

@ -1,30 +0,0 @@
From 22c19f6a5b58ad9ce99d2c2a95239eab911d908e Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
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 <hare@suse.de>
---
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

View File

@ -0,0 +1,39 @@
From 45223fd3c5a13da9209c4f44d7593cb42cab94fb Mon Sep 17 00:00:00 2001
From: Maurizio Lombardi <mlombard@redhat.com>
Date: Tue, 14 Dec 2021 10:09:42 +0100
Subject: [PATCH 3/6] nvme: do not leak an open file handle
We performed a "sec_fd=open(cfg.file)" earlier, so we should not
overwrite the handle.
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
nvme.c | 9 +--------
1 file changed, 1 insertion(+), 8 deletions(-)
diff --git a/nvme.c b/nvme.c
index 862f9b6..5beeac7 100644
--- a/nvme.c
+++ b/nvme.c
@@ -4379,17 +4379,10 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p
fprintf(stderr, "WARNING: --tl not dword aligned; unaligned bytes may be truncated\n");
if (strlen(cfg.file) == 0) {
+ close(sec_fd);
sec_fd = STDIN_FILENO;
sec_size = cfg.tl;
} else {
- sec_fd = open(cfg.file, O_RDONLY);
- if (sec_fd < 0) {
- fprintf(stderr, "Failed to open %s: %s\n",
- cfg.file, strerror(errno));
- err = -EINVAL;
- goto close_fd;
- }
-
err = fstat(sec_fd, &sb);
if (err < 0) {
perror("fstat");
--
2.27.0

View File

@ -1,66 +0,0 @@
From ce9d818f420af6be0801004a77e91915587fc02f Mon Sep 17 00:00:00 2001
From: Hannes Reinecke <hare@suse.de>
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 <hare@suse.de>
---
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

View File

@ -1,36 +0,0 @@
From bace574bbe55739a49e7fada5483b3d3a5ef361c Mon Sep 17 00:00:00 2001
From: Martin George <marting@netapp.com>
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 <marting@netapp.com>
Reviewed-by: Daniel Wagner <dwagner@suse.de>
Signed-off-by: Keith Busch <kbusch@kernel.org>
---
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

View File

@ -0,0 +1,35 @@
From b580886dbc322b2a71d6c0c1b71f9fca7b750b02 Mon Sep 17 00:00:00 2001
From: Maurizio Lombardi <mlombard@redhat.com>
Date: Tue, 14 Dec 2021 09:58:09 +0100
Subject: [PATCH 4/6] nvme-topology: fix memory leaks in
nvme_logical_block_size_from_ns_char()
Free the allocated strings before returning from the function
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
---
nvme-topology.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/nvme-topology.c b/nvme-topology.c
index 0a22f6b..6be2b09 100644
--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -686,10 +686,13 @@ int nvme_logical_block_size_from_ns_char(const char *dev)
return -EINVAL;
s = nvme_get_ctrl_attr(path, "logical_block_size");
+ free(path);
if (!s)
return -EINVAL;
- return atoi(s);
+ ret = atoi(s);
+ free(s);
+ return ret;
}
void *mmap_registers(const char *dev)
--
2.27.0

View File

@ -0,0 +1,37 @@
From 58c23ceb12d16756b2222a55d1d9dc5f34bb4fa4 Mon Sep 17 00:00:00 2001
From: James Smart <jsmart2021@gmail.com>
Date: Fri, 17 Dec 2021 11:32:32 -0800
Subject: [PATCH 5/6] nvme-cli: nvmf-connect@.service: Remove matching from
default syntax
commit 53aab69a0add added the "--matching" argument to the systemd
connect script that issues connect-all to a discovery controller. When
this argument is used, only discovery log entries whose target port
traddr's match the traddr of the discovery controller will be connected
to. This eliminates the ability to do referrals by the discovery
controller.
Revert the commit so that the "--matching" argument is not default
behavior.
Signed-off-by: James Smart <jsmart2021@gmail.com>
CC: Martin Wilck <mwilck@suse.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Link: https://lore.kernel.org/r/20211217193232.29034-1-jsmart2021@gmail.com
---
nvmf-autoconnect/systemd/nvmf-connect@.service | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nvmf-autoconnect/systemd/nvmf-connect@.service b/nvmf-autoconnect/systemd/nvmf-connect@.service
index 5fbf081..c60f146 100644
--- a/nvmf-autoconnect/systemd/nvmf-connect@.service
+++ b/nvmf-autoconnect/systemd/nvmf-connect@.service
@@ -11,4 +11,4 @@ Requires=nvmf-connect.target
[Service]
Type=simple
Environment="CONNECT_ARGS=%i"
-ExecStart=/bin/sh -c "nvme connect-all --matching --quiet `/bin/echo -e '${CONNECT_ARGS}'`"
+ExecStart=/bin/sh -c "nvme connect-all --quiet `/bin/echo -e '${CONNECT_ARGS}'`"
--
2.27.0

View File

@ -1,51 +0,0 @@
From 59e7477c5a18ec4bcb1f9b1e20d2303b4e0cafb1 Mon Sep 17 00:00:00 2001
From: Martin George <marting@netapp.com>
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 <marting@netapp.com>
---
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

View File

@ -0,0 +1,86 @@
From 1264c6323937c4a0342174fdd9be5a66ab1eaf24 Mon Sep 17 00:00:00 2001
From: James Smart <jsmart2021@gmail.com>
Date: Fri, 17 Dec 2021 14:20:22 -0800
Subject: [PATCH 6/6] nvme-cli: Make connect-all matching be case insensitive
The comparison routine that checks discovery controller traddr with a
discovery log traddr uses a simple strncmp. For FC, which kicks off
connect-all requests vay systemd, the nvme-fc transport will build
traddr strings with lower case hexadecimal. Some FC discovery
controllers return traddr strings with upper case hexadecimal. There
was is no rqmt in the NVME-FC spec that it be upper or lower case.
Given the case difference, the connect-all fails the match logic and
doesn't connect to storage.
Revise the traddr comparison routine to duplicate the strings and
convert them to lower case for comparison.
Signed-off-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Daniel Wagner <dwagner@suse.de>
Link: https://lore.kernel.org/r/20211217222022.30516-1-jsmart2021@gmail.com
---
fabrics.c | 26 +++++++++++++++++++++++++-
1 file changed, 25 insertions(+), 1 deletion(-)
diff --git a/fabrics.c b/fabrics.c
index 0766729..a1e2593 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -34,6 +34,7 @@
#include <stddef.h>
#include <syslog.h>
#include <time.h>
+#include <ctype.h>
#include <sys/types.h>
#include <arpa/inet.h>
@@ -681,6 +682,12 @@ static int space_strip_len(int max, const char *str)
return i + 1;
}
+static void strtolower(char *str)
+{
+ for ( ; *str; str++)
+ *str = tolower(*str);
+}
+
static void print_discovery_log(struct nvmf_disc_rsp_page_hdr *log, int numrec,
int instance)
{
@@ -1385,7 +1392,9 @@ static bool cargs_match_found(struct nvmf_disc_rsp_page_entry *entry)
static bool should_connect(struct nvmf_disc_rsp_page_entry *entry)
{
+ char *dctrl_traddr, *log_traddr;
int len;
+ bool connect = true;
if (cargs_match_found(entry))
return false;
@@ -1398,7 +1407,22 @@ static bool should_connect(struct nvmf_disc_rsp_page_entry *entry)
return true;
len = space_strip_len(NVMF_TRADDR_SIZE, entry->traddr);
- return !strncmp(fabrics_cfg.traddr, entry->traddr, len);
+
+ dctrl_traddr = strdup(fabrics_cfg.traddr);
+ log_traddr = strndup(entry->traddr, len);
+ if (!dctrl_traddr || !log_traddr)
+ goto free_exit;
+
+ strtolower(dctrl_traddr);
+ strtolower(log_traddr);
+
+ connect = (strlen(dctrl_traddr) == len) &&
+ !strcmp(dctrl_traddr, log_traddr);
+
+free_exit:
+ free(log_traddr);
+ free(dctrl_traddr);
+ return connect;
}
static int connect_ctrls(struct nvmf_disc_rsp_page_hdr *log, int numrec)
--
2.27.0

View File

@ -2,7 +2,7 @@
#%%global shortcommit0 %%(c=%%{commit0}; echo ${c:0:7})
Name: nvme-cli
Version: 1.14
Version: 1.16
Release: 3%{?dist}
Summary: NVMe management command line interface
@ -11,12 +11,13 @@ URL: https://github.com/linux-nvme/nvme-cli
Source0: https://github.com/linux-nvme/%{name}/archive/v%{version}.tar.gz
Patch0: nvme-cli-makefile-dont-install-host-params-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
Patch1: 0001-fabrics-fix-nvme-connect-segfault-if-transport-type-.patch
Patch2: 0002-fabrics-fix-a-buffer-overrun.patch
Patch3: 0003-bash-Fix-nvme-completion.patch
Patch4: 0004-nvme-do-not-leak-an-open-file-handle.patch
Patch5: 0005-nvme-topology-fix-memory-leaks-in-nvme_logical_block.patch
Patch6: 0006-nvme-cli-nvmf-connect-.service-Remove-matching-from-.patch
Patch7: 0007-nvme-cli-Make-connect-all-matching-be-case-insensiti.patch
BuildRequires: libuuid-devel
BuildRequires: gcc
@ -36,7 +37,7 @@ nvme-cli provides NVM-Express user space tooling for Linux.
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%build
@ -93,8 +94,11 @@ if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then
fi
%changelog
* Mon Sep 13 2021 Maurizio Lombardi <mlombard@redhat.com> - 1.14-3
- Fix crash when executing nvme-list
* Fri Jan 07 2022 Maurizio Lombardi <mlombard@redhat.com> - 1.16-3
- Merge a few bugfixes
* Mon Nov 29 2021 Maurizio Lombardi <mlombard@redhat.com> - 1.16-2
- Update to version 1.16
* Thu Jul 22 2021 Maurizio Lombardi <mlombard@redhat.com> - 1.14-2
- Merge various bugfixes