import nvme-cli-1.10.1-2.el8

This commit is contained in:
CentOS Sources 2020-06-09 19:58:25 +00:00 committed by Andrew Lukoshko
commit fc687b5ead
7 changed files with 388 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
SOURCES/v1.10.1.tar.gz

1
.nvme-cli.metadata Normal file
View File

@ -0,0 +1 @@
b312f3385742cc8a171379dd10b3397b45462eca SOURCES/v1.10.1.tar.gz

View File

@ -0,0 +1,128 @@
commit 4bad11866a349b7ae5d10869474f7c0fee740845
Author: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Date: Wed Jan 8 12:24:41 2020 -0800
Add additional smart log critical warn decoding
Provide a user option to request additional smart log page decoding,
and print out detailed critical warning when requested.
Signed-off-by: Wendy Xiong<wenxiong@linux.vnet.ibm.com>
[merge up, rename json keys]
Signed-off-by: Keith Busch <kbusch@kernel.org>
diff --git a/nvme-print.c b/nvme-print.c
index 2ba1de1..46d5228 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -585,10 +585,11 @@ static void json_endurance_log(struct nvme_endurance_group_log *endurance_group,
json_free_object(root);
}
-static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid)
+static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
+ enum nvme_print_flags flags)
{
+ int c, human = flags & VERBOSE;
struct json_object *root;
- int c;
char key[21];
unsigned int temperature = ((smart->temperature[1] << 8) |
@@ -607,8 +608,22 @@ static void json_smart_log(struct nvme_smart_log *smart, unsigned int nsid)
root = json_create_object();
- json_object_add_value_int(root, "critical_warning",
- smart->critical_warning);
+ if (human) {
+ struct json_object *crt = json_create_object();
+
+ json_object_add_value_int(crt, "value", smart->critical_warning);
+ json_object_add_value_int(crt, "available_spare", smart->critical_warning & 0x01);
+ json_object_add_value_int(crt, "temp_threshold", (smart->critical_warning & 0x02) >> 1);
+ json_object_add_value_int(crt, "reliability_degraded", (smart->critical_warning & 0x04) >> 2);
+ json_object_add_value_int(crt, "ro", (smart->critical_warning & 0x08) >> 3);
+ json_object_add_value_int(crt, "vmbu_failed", (smart->critical_warning & 0x10) >> 4);
+ json_object_add_value_int(crt, "pmr_ro", (smart->critical_warning & 0x20) >> 5);
+
+ json_object_add_value_object(root, "critical_warning", crt);
+ } else
+ json_object_add_value_int(root, "critical_warning",
+ smart->critical_warning);
+
json_object_add_value_int(root, "temperature", temperature);
json_object_add_value_int(root, "avail_spare", smart->avail_spare);
json_object_add_value_int(root, "spare_thresh", smart->spare_thresh);
@@ -3400,16 +3415,26 @@ void nvme_show_smart_log(struct nvme_smart_log *smart, unsigned int nsid,
/* convert temperature from Kelvin to Celsius */
int temperature = ((smart->temperature[1] << 8) |
smart->temperature[0]) - 273;
- int i;
+ int i, human = flags & VERBOSE;
if (flags & BINARY)
return d_raw((unsigned char *)smart, sizeof(*smart));
else if (flags & JSON)
- return json_smart_log(smart, nsid);
+ return json_smart_log(smart, nsid, flags);
printf("Smart Log for NVME device:%s namespace-id:%x\n", devname, nsid);
printf("critical_warning : %#x\n",
smart->critical_warning);
+
+ if (human) {
+ printf(" Available Spare[0] : %d\n", smart->critical_warning & 0x01);
+ printf(" Temp. Threshold[1] : %d\n", (smart->critical_warning & 0x02) >> 1);
+ printf(" NVM subsystem Reliability[2] : %d\n", (smart->critical_warning & 0x04) >> 2);
+ printf(" Read-only[3] : %d\n", (smart->critical_warning & 0x08) >> 3);
+ printf(" Volatile mem. backup failed[4] : %d\n", (smart->critical_warning & 0x10) >> 4);
+ printf(" Persistent Mem. RO[5] : %d\n", (smart->critical_warning & 0x20) >> 5);
+ }
+
printf("temperature : %d C\n",
temperature);
printf("available_spare : %u%%\n",
diff --git a/nvme.c b/nvme.c
index 3b386bc..dd3ab58 100644
--- a/nvme.c
+++ b/nvme.c
@@ -218,6 +218,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
"(default) or binary.";
const char *namespace = "(optional) desired namespace";
const char *raw = "output in binary format";
+ const char *human_readable = "show info in readable format";
enum nvme_print_flags flags;
int err, fd;
@@ -225,6 +226,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
__u32 namespace_id;
int raw_binary;
char *output_format;
+ int human_readable;
};
struct config cfg = {
@@ -234,9 +236,10 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
OPT_ARGS(opts) = {
- OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
- OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
- OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace),
+ OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
+ OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw),
+ OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable),
OPT_END()
};
@@ -249,6 +252,8 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
goto close_fd;
if (cfg.raw_binary)
flags = BINARY;
+ if (cfg.human_readable)
+ flags |= VERBOSE;
err = nvme_smart_log(fd, cfg.namespace_id, &smart_log);
if (!err)

View File

@ -0,0 +1,13 @@
--- nvme-cli-1.9/Makefile.orig 2020-05-27 14:04:56.259961135 -0400
+++ nvme-cli-1.9/Makefile 2020-05-27 14:05:22.796185371 -0400
@@ -125,8 +125,8 @@
$(INSTALL) -m 644 -T ./etc/discovery.conf.in $(DESTDIR)$(SYSCONFDIR)/nvme/discovery.conf; \
fi
-install-spec: install-bin install-man install-bash-completion install-zsh-completion install-etc install-systemd install-udev install-dracut
-install: install-spec install-hostparams
+install-spec: install-bin install-man install-bash-completion install-zsh-completion install-systemd install-udev install-dracut
+install: install-spec
nvme.spec: nvme.spec.in NVME-VERSION-FILE
sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+

View File

@ -0,0 +1,16 @@
commit 27cc5431f4aabdc8fea8b371c18b3ec1f6b9235b
Author: Yi Zhang <yi.zhang@redhat.com>
Date: Thu Jan 16 15:56:58 2020 +0800
nvme-cli: memblaze: change to 100644 mode for memblaze-nvme.c
Bellow WARNING observed with rpmbuild -bb rpmbuild/SPECS/nvme-cli.spec
*** WARNING: plugins/memblaze/memblaze-nvme.c is executable but has
empty or no shebang, removing executable bit
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
diff --git a/plugins/memblaze/memblaze-nvme.c b/plugins/memblaze/memblaze-nvme.c
old mode 100755
new mode 100644

View File

@ -0,0 +1,58 @@
commit 01e6062e7be71b7dec29ecd8de09eb411ddd78f1
Author: Yi Zhang <yi.zhang@redhat.com>
Date: Fri May 1 15:42:10 2020 +0800
nvme-print: nvme list -o json fix
Bellow error log will be triggered on non pcie transport, so only print the
ProductName for pcie transport, also add print "\n" and json_free_object fix
Failed to open /sys/class/nvme/nvme1/device/subsystem_vendor with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/subsystem_device with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/vendor with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/device with errno No such file or directory
Failed to open /sys/class/nvme/nvme1/device/class with errno No such file or directory
{
"Devices" : [
{
"NameSpace" : 1,
"DevicePath" : "/dev/nvme1n1",
"Firmware" : "4.18.0-1",
"Index" : 1,
"ModelNumber" : "Linux",
"ProductName" : "NULL",
"SerialNumber" : "eb4695bf0da275a3",
"UsedBytes" : 268435456000,
"MaximumLBA" : 524288000,
"PhysicalSize" : 268435456000,
"SectorSize" : 512
}
]
}
Reported-by: Justin Tee <justin.tee@broadcom.com>
Signed-off-by: Yi Zhang <yi.zhang@redhat.com>
Signed-off-by: Keith Busch <kbusch@kernel.org>
diff --git a/nvme-print.c b/nvme-print.c
index 42e27a3..7414280 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -4629,7 +4629,7 @@ static void json_simple_ns(struct nvme_namespace *n, struct json_array *devices)
json_object_add_value_string(device_attrs, "ModelNumber", formatter);
- if (index >= 0) {
+ if (index >= 0 && !strcmp(n->ctrl->transport, "pcie")) {
char *product = nvme_product_name(index);
json_object_add_value_string(device_attrs, "ProductName", product);
@@ -4682,6 +4682,8 @@ static void json_simple_list(struct nvme_topology *t)
}
json_object_add_value_array(root, "Devices", devices);
json_print_object(root, NULL);
+ printf("\n");
+ json_free_object(root);
}
static void json_print_list_items(struct nvme_topology *t,

171
SPECS/nvme-cli.spec Normal file
View File

@ -0,0 +1,171 @@
#%%global commit0 bdbb4da0979fbdc079cf98410cdb31cf799e83b3
#%%global shortcommit0 %%(c=%%{commit0}; echo ${c:0:7})
Name: nvme-cli
Version: 1.10.1
Release: 2%{?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-memblaze-change-mode-patch
Patch1: nvme-cli-add-addl-smart-log-crit-warn-decoding-patch
Patch2: nvme-cli-makefile-dont-install-host-params-patch
Patch3: nvme-print-nvme-list-json-fix-patch
BuildRequires: libuuid-devel
BuildRequires: gcc
BuildRequires: systemd-devel
%description
nvme-cli provides NVM-Express user space tooling for Linux.
%prep
#%%setup -qn %%{name}-%%{commit0}
%setup -q
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
# CFLAGS on the command line breaks the build. It works okay as an
# environment variable, though. See:
# https://github.com/linux-nvme/nvme-cli/pull/480
CFLAGS="%{optflags}" make PREFIX=/usr LDFLAGS="%{__global_ldflags}" %{?_smp_mflags}
%install
%make_install PREFIX=/usr UDEVDIR="%{_udevrulesdir}/.." SYSTEMDDIR="%{_unitdir}/.."
mkdir -p %{buildroot}%{_sysconfdir}/nvme
# hostid and hostnqn are supposed to be unique per machine. We obviously
# can't package them.
#rm -f %{buildroot}%{_sysconfdir}/nvme/hostid
#rm -f %{buildroot}%{_sysconfdir}/nvme/hostnqn
# Do not install the dracut rule yet. See rhbz 1742764
rm -f %{buildroot}/usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf
%files
%license LICENSE
%doc README.md
%{_sbindir}/nvme
%{_mandir}/man1/nvme*.gz
%{_datadir}/bash-completion/completions/nvme
%{_datadir}/zsh/site-functions/_nvme
%dir %{_sysconfdir}/nvme
%{_unitdir}/nvmefc-boot-connections.service
%{_unitdir}/nvmf-connect.target
%{_unitdir}/nvmf-connect@.service
%{_udevrulesdir}/70-nvmf-autoconnect.rules
%{_udevrulesdir}/71-nvmf-iopolicy-netapp.rules
# Do not install the dracut rule yet. See rhbz 1742764
# /usr/lib/dracut/dracut.conf.d/70-nvmf-autoconnect.conf
%post
if [ $1 -eq 1 ] || [ $1 -eq 2 ]; then
if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
echo $(nvme gen-hostnqn) > %{_sysconfdir}/nvme/hostnqn
fi
if [ ! -s %{_sysconfdir}/nvme/hostid ]; then
uuidgen > %{_sysconfdir}/nvme/hostid
fi
# apply udev and systemd changes that we did
systemctl enable nvmefc-boot-connections
systemctl daemon-reload
udevadm control --reload-rules && udevadm trigger
fi
%changelog
* Thu Mar 19 2020 luto@kernel.org - 1.10.1-1
- Update to 1.10.1
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 1.9-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Wed Oct 02 2019 luto@kernel.org - 1.9-1
- Update to 1.9
- Certain fabric functionality may not work yet due to missing dracut
support and missing hostid and hostnqn configuration.
* Thu Jul 25 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.8.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild
* Mon Apr 15 2019 luto@kernel.org - 1.8.1-1
- Update to 1.8.1-1.
- Remove a build hack.
* Sun Feb 24 2019 luto@kernel.org - 1.7-2
- Create /etc/nvme
* Sun Feb 24 2019 luto@kernel.org - 1.7-1
- Bump to 1.7
- Clean up some trivial rpmlint complaints
* Fri Feb 01 2019 Fedora Release Engineering <releng@fedoraproject.org> - 1.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild
* Tue Jul 24 2018 luto@kernel.org - 1.6-1
- Update to 1.6
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Thu Feb 08 2018 Fedora Release Engineering <releng@fedoraproject.org> - 1.4-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild
* Wed Nov 22 2017 luto@kernel.org - 1.4-1
- Update to 1.4
* Thu Aug 03 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild
* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.3-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild
* Mon May 22 2017 luto@kernel.org - 1.3-1
- Update to 1.3
* Wed Apr 19 2017 luto@kernel.org - 1.2-2
- Update to 1.2
- 1.2-1 never existed
* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild
* Wed Feb 01 2017 luto@kernel.org - 1.1-1
- Update to 1.1
* Sun Nov 20 2016 luto@kernel.org - 1.0-1
- Update to 1.0
* Mon Oct 31 2016 luto@kernel.org - 0.9-1
- Update to 0.9
* Thu Jun 30 2016 luto@kernel.org - 0.8-1
- Update to 0.8
* Tue May 31 2016 luto@kernel.org - 0.7-1
- Update to 0.7
* Fri Mar 18 2016 luto@kernel.org - 0.5-1
- Update to 0.5
* Sun Mar 06 2016 luto@kernel.org - 0.4-1
- Update to 0.4
* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.2-3.20160112gitbdbb4da
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild
* Wed Jan 20 2016 luto@kernel.org - 0.2-2.20160112gitbdbb4da
- Update to new upstream commit, fixing #49. "nvme list" now works.
* Wed Jan 13 2016 luto@kernel.org - 0.2-1.20160112gitde3e0f1
- Initial import.