Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package nvme-cli.17251 for 
openSUSE:Leap:15.2:Update checked in at 2021-12-10 18:06:25
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2:Update/nvme-cli.17251 (Old)
 and      /work/SRC/openSUSE:Leap:15.2:Update/.nvme-cli.17251.new.2520 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nvme-cli.17251"

Fri Dec 10 18:06:25 2021 rev:1 rq:936275 version:1.10

Changes:
--------
New Changes file:

--- /dev/null   2021-12-09 00:52:20.582305468 +0100
+++ 
/work/SRC/openSUSE:Leap:15.2:Update/.nvme-cli.17251.new.2520/nvme-cli.changes   
    2021-12-10 18:06:26.652792859 +0100
@@ -0,0 +1,1636 @@
+-------------------------------------------------------------------
+Thu Nov 18 13:52:18 UTC 2021 - Daniel Wagner <daniel.wag...@suse.com>
+
+- Fix smart log read out (bsc#1177737)
+  * add 0023-Fixing-Alignment-Error-In-intel-smart-log-add.patch
+- Allow -1 as ctrl_loss_tmo value (bsc#1192348)
+  * add 0024-nvme-cli-ctrl-loss-tmo-should-accept-1-as-value.patch
+- Fix segfauls while discovering (bsc#1191935)
+  * add 0025-Input-expects-device-name-without-dev.patch
+  * add 0026-fabrics-fix-nvme-discover-segfault-if-sysfs-path-is-.patch
+  * add 0027-fabrics-Only-free-initialized-valued-on-exit.patch
+  * add 0028-nvme-print-add-discovery-async-event-config-field.patch
+  * add 0029-fabrics-fix-nvme-connect-segfault-if-transport-type-.patch
+- Use pkg-config for libuuid dependency setup
+  * add 0100-build-use-pkg-config-for-libuuid-detection.patch
+
+-------------------------------------------------------------------
+Wed Aug 11 08:25:26 UTC 2021 - Daniel Wagner <daniel.wag...@suse.com>
+
+- Do not print error message when opening controller (bsc#1186719)
+  * add 0014-nvme-topology-no-error-message-when-openeing-of-cont.patch
+- Fix failures during 'nvme list' (bsc#1186719)
+  * add 0015-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch
+  * add 0016-nvme-topology-scan-all-controllers-in-scan_subsystem.patch
+- Only connect to matching controllers (bsc#1186719)
+  * add 0017-connect-all-add-m-matching-option.patch
+- Skip connect if transport type doesn't match (bsc#1187287 bsc#1187860)
+  * add 0018-fabrics-skip-connect-if-transport-type-doesn-t-match.patch
+- Ignore non live controllers when scanning subsystems (bsc#1186719 
bsc#1187287)
+  * add 0019-nvme-topology-fix-controller-check-in-scan_subsystem.patch-
+- Remove UUID validation heuristic (bsc#1187890)
+  * add 0020-gen-hostnqn-Remove-UUID-validation-heuristic.patch
+- Do not segfault when controller is not available (bsc#1189046)
+  * add 0021-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch
+- Use correct default port for discovery (bsc#1189195 bsc#1187858)
+  * add 0022-fabrics-add-default-port-number-for-NVMe-TCP-I-O-con.patch
+
+-------------------------------------------------------------------
+Tue May 18 09:07:00 UTC 2021 - Daniel Wagner <daniel.wag...@suse.com>
+
+- Lookup existing persistent controllers (bsc#1179825)
+  * add 0012-fabrics-move-connect_args-extraction-to-a-dedicated-.patch
+  * add 0013-nvme-discover-lookup-existing-persistent-controllers.patch
+
+------------------------------------------------------------------
+Thu Apr  8 12:24:47 UTC 2021 - Daniel Wagner <daniel.wag...@suse.com>
+
+- Use default port 8009 for NVMeoF discovery (bsc#1180505)
+  * add 0011-nvme-add-fabrics-discovery-controller-default-port-n.patch
+- Add missing huck in previous backport (bsc#1182591)
+  * fabrics-ensure-zero-kato-for-non-persistent-controllers.patch 
+
+-------------------------------------------------------------------
+Mon Mar 15 12:05:12 UTC 2021 - Daniel Wagner <daniel.wag...@suse.com>
+
+- Add KATO fixes for NVMEoF (bsc#1182591)
+  * add fabrics-set-keep_alive_tmo-also-for-discovery-controllers.patch
+  * add fabrics-permit-kato-int-argument-for-discovery-controllers.patch
+  * add fabrics-ensure-zero-kato-for-non-persistent-controllers.patch
+  * add print-device-name-when-creating-a-persistent-device.patch 
+
+-------------------------------------------------------------------
+Tue Oct 13 15:54:27 CEST 2020 - h...@suse.de
+
+- fabrics: write reconnect_delay to fabrics device on connect
+  (bsc#1172111)
+  * add 0006-fabrics-write-reconnect_delay-to-fabrics-device-on-c.patch
+  
+-------------------------------------------------------------------
+Tue Feb  4 09:37:15 CET 2020 - h...@suse.de
+
+- Add additional smart log critical warn decoding (bsc#1161768)
+  * add 0003-Add-additional-smart-log-critical-warn-decoding.patch
+- Update patches with upstream version:
+  * delete 0101-Makefile-use-UDEVRULESDIR-instead-of-UDEVDIR.patch
+  * add 0002-Makefile-use-UDEVRULESDIR-instead-of-UDEVDIR.patch
+  * delete 0102-nvme-cli-Add-script-to-determine-host-NQN.patch
+  * add 0005-nvme-cli-Add-script-to-determine-host-NQN.patch
+- Add nvmf autoconnect service
+  * add 0004-nvmf-autoconnect.service.patch
+
+-------------------------------------------------------------------
+Tue Jan 21 07:09:17 UTC 2020 - h...@suse.com
+
+- Update to version 1.10 (jsc#SLE-7726 jsc#SLE-8339 bsc#1160329):
+  * Release v1.10
+  * Regen documentation
+  * Use asprintf for long names
+  * WDC plugin update
+  * Fix systemd service script use of CONNECT_ARGS env var
+  * Shannon Plugin update.
+  * Doc/Makefile: Introduce 'quiet' build option
+  * Makefile: use 'quiet' compile
+  * Makefile: Use special variables
+  * micron: don't ignore 'system()' return value
+  * Fix libhugetlbfs flags
+  * Regenerate documentation
+  * Micron plugin updates
+  * README.md: Mention the buildroot package
+  * nvmf-autoconnect: add udev rules to set iopolicy for certain NetApp devices
+  * Fix intel json latency statistics output format
+  * intel: Add function lat-stats to cli
+  * Fix typo (bulit -> built)
+  * Warn on admin-passthru opcode not matching read/write flag
+  * MAINT: Fix format compile warning error on 32 bit system
+  * nvme-cli: Check for sysfs interface before NVMe discovery
+  * Revert "Add Dera plugin extension."
+  * Add Dera plugin extension.
+  * Improve self test log command
+  * nvme-cli: Update err to 0 in get_telemetry_log
+  * fixup up self-test log when no test is in progress
+  * nvme-cli: Update err value to 0 in get_ns_id func.
+  * nvme.c: create-ns arguments are added
+  * [NVMe-CLI] Get DUI for SN-340 failing with Data Area 4 - Buffer 
Misalignment
+  * Minor intel-nvme print refactor
+  * Use simpler nvme ioctl api for admin
+  * Relocate functions and constants to the files that use them
+  * Move all spec defined structs to single file
+  * Update build rules for .c with no .h
+  * Makefile: fix cleaning subdirectories
+  * remove unused "paths" controller field
+  * reign in line lengths
+  * Add print for directive receive
+  * Unify print routines
+  * regenerate documentation
+  * fix fw-download reference to committing fw
+  * argconfig: Remove unused paramters
+  * fix huawei filter to search all namespaces
+  * nvme-cli: Support for hugetlbfs
+  * Remove all 'struct nvme_command' usage
+  * nvme-cli: Update PMR Capability and PMR Status
+  * nvme-cli: Update Controller Capabilities Register
+  * nvme-cli: Update NVMe Registers
+  * fixup attach-ns documentation
+  * Add files via upload
+  * Regen docs, add host-nqn man page
+  * fix namespace checks for legacy list
+  * Reset wdc_do_cap_dui default parameters to the proper values
+  * README.md: Mention the OpenEmbedded/Yocto recipe
+  * Intel plugin: Adding fields to id-ctrl VU region
+  * udev: convert the discovery event handler to the kernel support
+  * Use a systemd app-specific machine ID for hostnqn
+  * nvme-cli: Add 'transport type' error to the error log
+  * nvme-cli: Update nvme_endurance_group_log structure
+  * Adding fields to id-ctrl VU reigon for Intel DC drives
+  * Check return value of scandir
+  * nvme-cli: Add namespace-id option to self-test-log
+  * Report invalid output format for 'list' command
+  * Provide no-binary output format help text
+  * regen documentation
+  * Documentation: nvme-wdc-vs-fw-activate-history(1,html) generated
+  * nvme-cli/fabrics: Add tos param to connect cmd
+  * nvme.spec.in: fix rpm build error
+  * Correct self-test-log output
+  * nvme: Add 'Endurance Group Critical Warning Summary' to the
+  Smart/Health information Log
+  * make: install-hostparams depends on install-etc
+  * MAINT: compile warning error on 32 bit system
+  * nvme-print: fix to print ctrltype when human-readable
+  * nvme: add Persistent Memory Region(PMR) Write Elasticity Status Registers
+  * [NVMe-CLI] Fix Potential Memory Leak with vs-internal-log command.
+  * regen docs
+  * fix admin-passthru documentation typo
+  * nvme-cli: Fix namespace list output
+  * Fix builds for missing uuid
+  * Revert "remove LIBUUID things from nvme.h"
+  * Revert "nvme-cli: Fix compile on non-libuuid machines"
+  * Revert "fix uuid include typo"
+  * remove LIBUUID things from nvme.h
+  * fix build error due to asprintf()
+  * id-ctrl: show Flush command behavior in VWC
+  * fix uuid include typo
+  * nvme-cli: Fix compile on non-libuuid machines
+  * Regen docs
+  * nvme-cli: Code cleanup
+  * nvme-cli: Macro'ify argument defines
+  * nvme-cli: Code reorg
+  * [NVMe-CLI] Add support to specify file size in get DUI data for SN340.
+  * Regenerate documentation
+  * nvme-cli: Make 'list' more useful
+  * id-ctrl: show Persistent Event Log support in LPA
+  * id-ctrl: show Persistent Event Log Size(PELS)
+  * id-ctrl: show Endurance Group Maximum ID(ENDGIDMAX)
+  * id-ctrl: show FRU Globally Unique Identifier(FGUID)
+  * id-ctrl: show Controller Type(CNTRLTYPE)
+  * id-ctrl: update id-ctrl header for 1.4
+  * systemd: fix echo call with absolute path
+  * nvmf-autoconnect: fix absolute path for systemctl
+  * make: install udev rules in sysconfdir
+  * Add an example for attach-ns
+  * make: fix discovery.conf override
+  * fabrics: fix loop connect-all
+  * nvme: fix compilation error
+  * nvme-cli: Enhance format FNA detection
+  * nvme-cli: Warn and delay before formatting
+  * nvme-cli: prefill metadata buffers
+  * Fixed bash-nvme-completion.sh typo
++++ 1439 more lines (skipped)
++++ between /dev/null
++++ and 
/work/SRC/openSUSE:Leap:15.2:Update/.nvme-cli.17251.new.2520/nvme-cli.changes

New:
----
  0001-Makefile-generate-Dracut-config-according-to-UDEVDIR.patch
  0002-Makefile-use-UDEVRULESDIR-instead-of-UDEVDIR.patch
  0003-Add-additional-smart-log-critical-warn-decoding.patch
  0004-nvmf-autoconnect.service.patch
  0005-nvme-cli-Add-script-to-determine-host-NQN.patch
  0006-fabrics-write-reconnect_delay-to-fabrics-device-on-c.patch
  0007-fabrics-set-keep_alive_tmo-also-for-discovery-controllers.patch
  0008-fabrics-permit-kato-int-argument-for-discovery-controllers.patch
  0009-fabrics-ensure-zero-kato-for-non-persistent-controllers.patch
  0010-print-device-name-when-creating-a-persistent-device.patch
  0011-nvme-add-fabrics-discovery-controller-default-port-n.patch
  0012-fabrics-move-connect_args-extraction-to-a-dedicated-.patch
  0013-nvme-discover-lookup-existing-persistent-controllers.patch
  0014-nvme-topology-no-error-message-when-openeing-of-cont.patch
  0015-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch
  0016-nvme-topology-scan-all-controllers-in-scan_subsystem.patch
  0017-connect-all-add-m-matching-option.patch
  0018-fabrics-skip-connect-if-transport-type-doesn-t-match.patch
  0019-nvme-topology-fix-controller-check-in-scan_subsystem.patch
  0020-gen-hostnqn-Remove-UUID-validation-heuristic.patch
  0021-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch
  0022-fabrics-add-default-port-number-for-NVMe-TCP-I-O-con.patch
  0023-Fixing-Alignment-Error-In-intel-smart-log-add.patch
  0024-nvme-cli-ctrl-loss-tmo-should-accept-1-as-value.patch
  0025-Input-expects-device-name-without-dev.patch
  0026-fabrics-fix-nvme-discover-segfault-if-sysfs-path-is-.patch
  0027-fabrics-Only-free-initialized-valued-on-exit.patch
  0028-nvme-print-add-discovery-async-event-config-field.patch
  0029-fabrics-fix-nvme-connect-segfault-if-transport-type-.patch
  0100-build-use-pkg-config-for-libuuid-detection.patch
  _service
  _servicedata
  nvme-cli-1.10.tar.gz
  nvme-cli-rpmlintrc
  nvme-cli.changes
  nvme-cli.spec

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nvme-cli.spec ++++++
#
# spec file for package nvme-cli
#
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


Name:           nvme-cli
Version:        1.10
Release:        0
Summary:        NVM Express user space tools
License:        GPL-2.0-only
Group:          Hardware/Other
URL:            https://github.com/linux-nvme/nvme-cli
Source:         %{name}-%{version}.tar.gz
Source2:        nvme-cli-rpmlintrc
Patch1:         0001-Makefile-generate-Dracut-config-according-to-UDEVDIR.patch
Patch2:         0002-Makefile-use-UDEVRULESDIR-instead-of-UDEVDIR.patch
Patch3:         0003-Add-additional-smart-log-critical-warn-decoding.patch
Patch4:         0004-nvmf-autoconnect.service.patch
Patch5:         0005-nvme-cli-Add-script-to-determine-host-NQN.patch
Patch6:         0006-fabrics-write-reconnect_delay-to-fabrics-device-on-c.patch
Patch7:         
0007-fabrics-set-keep_alive_tmo-also-for-discovery-controllers.patch
Patch8:         
0008-fabrics-permit-kato-int-argument-for-discovery-controllers.patch
Patch9:         
0009-fabrics-ensure-zero-kato-for-non-persistent-controllers.patch
Patch10:        0010-print-device-name-when-creating-a-persistent-device.patch
Patch11:        0011-nvme-add-fabrics-discovery-controller-default-port-n.patch
Patch12:        0012-fabrics-move-connect_args-extraction-to-a-dedicated-.patch
Patch13:        0013-nvme-discover-lookup-existing-persistent-controllers.patch
Patch14:        0014-nvme-topology-no-error-message-when-openeing-of-cont.patch
Patch15:        0015-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch
Patch16:        0016-nvme-topology-scan-all-controllers-in-scan_subsystem.patch
Patch17:        0017-connect-all-add-m-matching-option.patch
Patch18:        0018-fabrics-skip-connect-if-transport-type-doesn-t-match.patch
Patch19:        0019-nvme-topology-fix-controller-check-in-scan_subsystem.patch
Patch20:        0020-gen-hostnqn-Remove-UUID-validation-heuristic.patch
Patch21:        0021-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch
Patch22:        0022-fabrics-add-default-port-number-for-NVMe-TCP-I-O-con.patch
Patch23:        0023-Fixing-Alignment-Error-In-intel-smart-log-add.patch
Patch24:        0024-nvme-cli-ctrl-loss-tmo-should-accept-1-as-value.patch
Patch25:        0025-Input-expects-device-name-without-dev.patch
Patch26:        0026-fabrics-fix-nvme-discover-segfault-if-sysfs-path-is-.patch
Patch27:        0027-fabrics-Only-free-initialized-valued-on-exit.patch
Patch28:        0028-nvme-print-add-discovery-async-event-config-field.patch
Patch29:        0029-fabrics-fix-nvme-connect-segfault-if-transport-type-.patch
# downstream patches
Patch100:       0100-build-use-pkg-config-for-libuuid-detection.patch
BuildRequires:  asciidoc
BuildRequires:  xmlto
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(libudev)
BuildRequires:  pkgconfig(uuid)
BuildRequires:  systemd-devel
%ifarch x86_64 aarch64 i586
Requires(post): dmidecode
%endif

%description
NVM Express (NVMe) is a direct attached storage interface. The
nvme-cli package contains core management tools with minimal
dependencies.

%package -n     nvme-cli-regress-script
Summary:        A small script to test the nvme binary for regressions
Group:          Hardware/Other
Requires:       nvme-cli

%description -n nvme-cli-regress-script
A small shell script to test the nvme binary for regressions. It requires an
NVMe device for testing purposes. Do NOT use in a production environment.


%prep
%setup -q
%autosetup -p1

%build
echo %{version} > version
make CFLAGS="%{optflags} -I." PREFIX=%{_prefix} %{?_smp_mflags} all
# nvme-cli-regress-script subpackage: remove make and install steps
sed -i '/make.*/d' regress

%install
make PREFIX=%{_prefix} DESTDIR=%{buildroot} UDEVRULESDIR=%{_udevrulesdir} 
install-bin install-man install-udev install-systemd %{?_smp_mflags}
install -m 644 -D /dev/null %{buildroot}%{_sysconfdir}/nvme/hostnqn
install -m 644 -D completions/bash-nvme-completion.sh 
%{buildroot}%{_datadir}/bash_completion/completions/nvme
%ifarch x86_64 aarch64 i586
install -m 744 -D scripts/gen-hostnqn.sh 
%{buildroot}%{_sbindir}/nvme-gen-hostnqn
%endif
# for subpackage nvme-cli-regress-script:
install -m 744 -D regress %{buildroot}%{_sbindir}/nvme-regress

%define services nvmefc-boot-connections.service nvmf-connect.target 
nvmf-autoconnect.service

%pre
%service_add_pre %services nvmf-connect@.service

%post
%ifarch x86_64 aarch64 i586
if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
        %{_sbindir}/nvme-gen-hostnqn > %{_sysconfdir}/nvme/hostnqn
fi
%endif
if [ ! -s %{_sysconfdir}/nvme/hostnqn ]; then
        %{_bindir}/echo "Generating random host NQN."
        %{_sbindir}/nvme gen-hostnqn > %{_sysconfdir}/nvme/hostnqn
fi
if [ ! -s %{_sysconfdir}/nvme/hostid ]; then
        %{_bindir}/uuidgen > %{_sysconfdir}/nvme/hostid
fi
%service_add_post %services nvmf-connect@.service

%preun
%service_del_preun -f %services

%postun
%service_del_postun %services

%posttrans
if [ -f /sys/class/fc/fc_udev_device/nvme_discovery ]; then
        %{_bindir}/echo add > /sys/class/fc/fc_udev_device/nvme_discovery
fi

%files
%defattr(-,root,root)
%license LICENSE
%doc README.md
%{_sbindir}/nvme
%ifarch x86_64 aarch64 i586
%{_sbindir}/nvme-gen-hostnqn
%endif
%{_mandir}/man1/nvme*.1*%{?ext_man}
%dir %{_datadir}/bash_completion
%dir %{_datadir}/bash_completion/completions/
%{_datadir}/bash_completion/completions/nvme
%{_udevrulesdir}/70-nvmf-autoconnect.rules
%{_udevrulesdir}/71-nvmf-iopolicy-netapp.rules
%{_unitdir}/nvmefc-boot-connections.service
%{_unitdir}/nvmf-connect@.service
%{_unitdir}/nvmf-connect.target
%{_unitdir}/nvmf-autoconnect.service
%dir %{_sysconfdir}/nvme/
%ghost %{_sysconfdir}/nvme/hostnqn
%ghost %{_sysconfdir}/nvme/hostid

%files -n nvme-cli-regress-script
%defattr(-,root,root)
%{_sbindir}/nvme-regress

%changelog
++++++ 0001-Makefile-generate-Dracut-config-according-to-UDEVDIR.patch ++++++
From: Haochen Tong <i...@hexchain.org>
Date: Thu, 9 Jan 2020 20:16:23 +0100
Subject: [PATCH] Makefile: generate Dracut config according to UDEVDIR
Git-commit: 797ec651a057935a93319f2a3e082874076b5dfb

Signed-off-by: Haochen Tong <i...@hexchain.org>
---
 Makefile                                                 | 10 +++++++---
 nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf    |  1 -
 nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in |  1 +
 3 files changed, 8 insertions(+), 4 deletions(-)
 delete mode 100644 nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf
 create mode 100644 nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in

diff --git a/Makefile b/Makefile
index 441da6d..03d57d3 100644
--- a/Makefile
+++ b/Makefile
@@ -101,7 +101,7 @@ test:
 all: doc
 
 clean:
-       $(RM) $(NVME) $(OBJS) $(PLUGIN_OBJS) $(UTIL_OBJS) *~ a.out 
NVME-VERSION-FILE *.tar* nvme.spec version control nvme-*.deb
+       $(RM) $(NVME) $(OBJS) $(PLUGIN_OBJS) $(UTIL_OBJS) *~ a.out 
NVME-VERSION-FILE *.tar* nvme.spec version control nvme-*.deb 
70-nvmf-autoconnect.conf
        $(MAKE) -C Documentation clean
        $(RM) tests/*.pyc
        $(RM) verify-no-dep
@@ -128,9 +128,9 @@ install-udev:
        $(INSTALL) -d $(DESTDIR)$(UDEVDIR)/rules.d
        $(INSTALL) -m 644 ./nvmf-autoconnect/udev-rules/* 
$(DESTDIR)$(UDEVDIR)/rules.d
 
-install-dracut:
+install-dracut: 70-nvmf-autoconnect.conf
        $(INSTALL) -d $(DESTDIR)$(DRACUTDIR)/dracut.conf.d
-       $(INSTALL) -m 644 ./nvmf-autoconnect/dracut-conf/* 
$(DESTDIR)$(DRACUTDIR)/dracut.conf.d
+       $(INSTALL) -m 644 $< $(DESTDIR)$(DRACUTDIR)/dracut.conf.d
 
 install-zsh-completion:
        $(INSTALL) -d $(DESTDIR)$(PREFIX)/share/zsh/site-functions
@@ -159,6 +159,10 @@ nvme.spec: nvme.spec.in NVME-VERSION-FILE
        sed -e 's/@@VERSION@@/$(NVME_VERSION)/g' < $< > $@+
        mv $@+ $@
 
+70-nvmf-autoconnect.conf: 
nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
+       sed -e 's#@@UDEVDIR@@#$(UDEVDIR)#g' < $< > $@+
+       mv $@+ $@
+
 dist: nvme.spec
        git archive --format=tar --prefix=nvme-$(NVME_VERSION)/ HEAD > 
nvme-$(NVME_VERSION).tar
        @echo $(NVME_VERSION) > version
diff --git a/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf 
b/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf
deleted file mode 100644
index 844f3d9..0000000
--- a/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf
+++ /dev/null
@@ -1 +0,0 @@
-install_items+="/usr/lib/udev/rules.d/70-nvmf-autoconnect.rules"
diff --git a/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in 
b/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
new file mode 100644
index 0000000..d1f02fe
--- /dev/null
+++ b/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
@@ -0,0 +1 @@
+install_items+="@@UDEVDIR@@/rules.d/70-nvmf-autoconnect.rules"
-- 
2.13.7

++++++ 0002-Makefile-use-UDEVRULESDIR-instead-of-UDEVDIR.patch ++++++
From: Hannes Reinecke <h...@suse.de>
Date: Thu, 16 Jan 2020 13:57:46 +0100
Subject: [PATCH] Makefile: use UDEVRULESDIR instead of UDEVDIR
Git-commit: ab918e9f3825abed66ddeee4ca2e4528b227dd37

The SUSE rpm macros only have UDEVRULESDIR, not UDEVDIR.
So introduce a UDEVRULESDIR variable which is preset to
UDEVDIR/rules.d

Signed-off-by: Hannes Reinecke <h...@suse.de>
---
 Makefile                                                 | 7 ++++---
 nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in | 2 +-
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 03d57d3..e63a9cb 100644
--- a/Makefile
+++ b/Makefile
@@ -13,6 +13,7 @@ SBINDIR = $(PREFIX)/sbin
 LIBDIR ?= $(PREFIX)/lib
 SYSTEMDDIR ?= $(LIBDIR)/systemd
 UDEVDIR ?= $(SYSCONFDIR)/udev
+UDEVRULESDIR ?= $(UDEVDIR)/rules.d
 DRACUTDIR ?= $(LIBDIR)/dracut
 LIB_DEPENDS =
 
@@ -125,8 +126,8 @@ install-systemd:
        $(INSTALL) -m 644 ./nvmf-autoconnect/systemd/* 
$(DESTDIR)$(SYSTEMDDIR)/system
 
 install-udev:
-       $(INSTALL) -d $(DESTDIR)$(UDEVDIR)/rules.d
-       $(INSTALL) -m 644 ./nvmf-autoconnect/udev-rules/* 
$(DESTDIR)$(UDEVDIR)/rules.d
+       $(INSTALL) -d $(DESTDIR)$(UDEVRULESDIR)
+       $(INSTALL) -m 644 ./nvmf-autoconnect/udev-rules/* 
$(DESTDIR)$(UDEVRULESDIR)
 
 install-dracut: 70-nvmf-autoconnect.conf
        $(INSTALL) -d $(DESTDIR)$(DRACUTDIR)/dracut.conf.d
@@ -160,7 +161,7 @@ nvme.spec: nvme.spec.in NVME-VERSION-FILE
        mv $@+ $@
 
 70-nvmf-autoconnect.conf: 
nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
-       sed -e 's#@@UDEVDIR@@#$(UDEVDIR)#g' < $< > $@+
+       sed -e 's#@@UDEVRULESDIR@@#$(UDEVRULESDIR)#g' < $< > $@+
        mv $@+ $@
 
 dist: nvme.spec
diff --git a/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in 
b/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
index d1f02fe..41ea83c 100644
--- a/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
+++ b/nvmf-autoconnect/dracut-conf/70-nvmf-autoconnect.conf.in
@@ -1 +1 @@
-install_items+="@@UDEVDIR@@/rules.d/70-nvmf-autoconnect.rules"
+install_items+="@@UDEVRULESDIR@@/70-nvmf-autoconnect.rules"
-- 
2.13.7

++++++ 0003-Add-additional-smart-log-critical-warn-decoding.patch ++++++
From: Wen Xiong <wenxi...@linux.vnet.ibm.com>
Date: Wed, 8 Jan 2020 12:24:41 -0800
Subject: [PATCH] Add additional smart log critical warn decoding
Git-commit: 4bad11866a349b7ae5d10869474f7c0fee740845

Provide a user option to request additional smart log page decoding,
and print out detailed critical warning when requested.

Signed-off-by: Wendy Xiong<wenxi...@linux.vnet.ibm.com>
[merge up, rename json keys]
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 nvme-print.c | 37 +++++++++++++++++++++++++++++++------
 nvme.c       | 11 ++++++++---
 2 files changed, 39 insertions(+), 9 deletions(-)

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)
-- 
2.13.7

++++++ 0004-nvmf-autoconnect.service.patch ++++++
From: Hannes Reinecke <h...@suse.de>
Date: Wed, 22 Jan 2020 08:45:18 +0100
Subject: [PATCH] nvmf-autoconnect.service
Git-commit: c28523e76544fb44a9b6d7aa40e42bc5ffea256e Mon Sep 17 00:00:00 2001

Add a systemd service to automatically start 'nvme connect-all'
upon booting if an /etc/nvme/discovery.conf file exists.
The 'nvme-tcp' or 'nvme-rdma' modules need to be loaded earlier
by eg the modules-load service.

Signed-off-by: Hannes Reinecke <h...@suse.com>
---
 nvmf-autoconnect/systemd/nvmf-autoconnect.service | 12 ++++++++++++
 1 file changed, 12 insertions(+)
 create mode 100644 nvmf-autoconnect/systemd/nvmf-autoconnect.service

diff --git a/nvmf-autoconnect/systemd/nvmf-autoconnect.service 
b/nvmf-autoconnect/systemd/nvmf-autoconnect.service
new file mode 100644
index 0000000..2690467
--- /dev/null
+++ b/nvmf-autoconnect/systemd/nvmf-autoconnect.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Connect NVMe-oF subsystems automatically during boot
+ConditionPathExists=/etc/nvme/discovery.conf
+After=network.target
+Before=remote-fs-pre.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/sbin/nvme connect-all
+
+[Install]
+WantedBy=default.target
-- 
2.13.7

++++++ 0005-nvme-cli-Add-script-to-determine-host-NQN.patch ++++++
From: Simon Schricker <sschric...@suse.de>
Date: Fri, 17 May 2019 15:36:37 +0200
Subject: [PATCH] nvme-cli: Add script to determine host NQN
Git-commit: 6180aa0e32ba7d0e8dfa8435d212208569168773

* Based on the system-UUID, via dmidecode
* verifies UUID format
* tries to catch fake/lazy UUIDs
---
 scripts/gen-hostnqn.sh | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)
 create mode 100644 scripts/gen-hostnqn.sh

diff --git a/scripts/gen-hostnqn.sh b/scripts/gen-hostnqn.sh
new file mode 100644
index 0000000..d8783cf
--- /dev/null
+++ b/scripts/gen-hostnqn.sh
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+LC_ALL=C
+
+UUID=$(dmidecode -s system-uuid | tr -d '[:space:]')
+
+if [ -z "$UUID" ] ; then
+       >&2 echo "No UUID found, can't determine hostnqn."
+       exit 1
+fi
+
+# convert UUID to lower-case only:
+UUID=$(echo $UUID | tr '[:upper:]' '[:lower:]')
+
+# check UUID format, e.g.: 4c4c4544-0156-4a10-8134-b7d04f383232, so: 8-4-4-4-12
+if ! [[ $UUID =~ 
^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$ ]] ; then
+       >&2 echo "UUID has invalid format."
+       >&2 echo "Invalid UUID: ${UUID}"
+       exit 2
+fi
+
+# HEURISTIC:
+# (1) if any one given character occurs more than 50% of the time, it is likely
+# that the UUID is fake.
+# (2) if the first or the last group consists of mostly the same character, it
+# is likely that the UUID is fake.
+FIRST_GROUP="$(echo $UUID | cut -d'-' -f1)"
+LAST_GROUP="$(echo $UUID | cut -d'-' -f5)"
+for i in {{0..9},{a..f}} ; do
+       COUNT_TOTAL="${UUID//[^$i]}"
+       COUNT_FIRST="${FIRST_GROUP//[^$i]}"
+       COUNT_LAST="${LAST_GROUP//[^$i]}"
+       if [ ${#COUNT_TOTAL} -ge 16 ] || [ ${#COUNT_FIRST} -ge 7 ] || [ 
${#COUNT_LAST} -ge 11 ] ; then
+               >&2 echo "UUID is too repetitive. This may be a false alert."
+               >&2 echo "Repetitive UUID: ${UUID}"
+               exit 3
+       fi
+done
+
+HOSTNQN="nqn.2014-08.org.nvmexpress:uuid:${UUID}"
+
+echo $HOSTNQN
-- 
2.13.7

++++++ 0006-fabrics-write-reconnect_delay-to-fabrics-device-on-c.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Mon, 11 May 2020 20:07:15 +0530
Subject: [PATCH] fabrics: write reconnect_delay to fabrics device on connect


Though '--reconnect-delay' option is defined for connect, it
wasn't passed down to the kernel in connect_ctrl().

Git-commit: b2a0aba1176aa26f2b5ce0c0360c4be67dff63d8
References: bsc#1172111
Signed-off-by: Martin George <mart...@netapp.com>
Signed-off-by: Keith Busch <keith.bu...@wdc.com>
---
 fabrics.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/fabrics.c b/fabrics.c
index b3e717f..18034fa 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -995,6 +995,13 @@ retry:
                p+= len;
        }
 
+       if (cfg.reconnect_delay) {
+               len = sprintf(p, ",reconnect_delay=%d", cfg.reconnect_delay);
+               if (len < 0)
+                       return -EINVAL;
+               p += len;
+       }
+
        if (cfg.ctrl_loss_tmo) {
                len = sprintf(p, ",ctrl_loss_tmo=%d", cfg.ctrl_loss_tmo);
                if (len < 0)
-- 
2.16.4

++++++ 0007-fabrics-set-keep_alive_tmo-also-for-discovery-controllers.patch 
++++++
From: Sagi Grimberg <s...@grimberg.me>
Date: Wed, 12 Feb 2020 12:01:58 -0800
Subject: [PATCH] fabrics: set keep_alive_tmo also for discovery controllers
References: bsc#1182591
Git-commit: 39a6e3e7f22fd50f0bd4e7d507d536c173fcbf04

We may use persistent discovery connections on referrals
so don't restrict it for discovery controllers.

Signed-off-by: Sagi Grimberg <s...@grimberg.me>
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 fabrics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fabrics.c b/fabrics.c
index 98a427830797..a112f76c146c 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -947,7 +947,7 @@ retry:
                p += len;
        }
 
-       if (cfg.keep_alive_tmo && !discover) {
+       if (cfg.keep_alive_tmo) {
                len = sprintf(p, ",keep_alive_tmo=%d", cfg.keep_alive_tmo);
                if (len < 0)
                        return -EINVAL;
-- 
2.29.2

++++++ 0008-fabrics-permit-kato-int-argument-for-discovery-controllers.patch 
++++++
From: Martin George <martinus....@gmail.com>
Date: Thu, 18 Feb 2021 15:16:42 +0530
Subject: [PATCH] fabrics: permit kato int argument for discovery controllers
References: bsc#1182591
Git-commit: 0258f79369e13a11baa4e286d4c09ee8ddb5688e

Given discovery controllers can now accept integer arguments
for kato, permit the same in build_options().

Signed-off-by: Martin George <mart...@netapp.com>
Reviewed-by: Hannes Reinecke <h...@suse.de>
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 fabrics.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/fabrics.c b/fabrics.c
index a2d17196bc2c..cdb0400719de 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -899,9 +899,8 @@ static int build_options(char *argstr, int max_len, bool 
discover)
            (!discover &&
              add_int_argument(&argstr, &max_len, "queue_size",
                                cfg.queue_size, false)) ||
-           (!discover &&
-             add_int_argument(&argstr, &max_len, "keep_alive_tmo",
-                               cfg.keep_alive_tmo, false)) ||
+           add_int_argument(&argstr, &max_len, "keep_alive_tmo",
+                               cfg.keep_alive_tmo, false) ||
            add_int_argument(&argstr, &max_len, "reconnect_delay",
                                cfg.reconnect_delay, false) ||
            add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
-- 
2.29.2

++++++ 0009-fabrics-ensure-zero-kato-for-non-persistent-controllers.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Wed, 3 Mar 2021 11:49:19 +0530
Subject: [PATCH] fabrics: ensure zero kato for non-persistent controllers
References: bsc#1182591
Git-commit: a67d001330ae1c407aa4f8491436bb2d0128d47f

Add a helper function that sets the default kato value for the
discovery controllers. Along with ensuring a non-zero kato value
(i.e. NVMF_DEF_DISC_TMO) is passed to a persistent discovery
controller, it also ensures a zero kato value is passed to a
non-persistent discovery controller, as mandated by the NVMe spec.

Signed-off-by: Martin George <mart...@netapp.com>
---
 fabrics.c |   17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -855,6 +855,16 @@ static int build_options(char *argstr, i
        return 0;
 }
 
+static void set_discovery_kato(struct config *cfg)
+{
+       /* Set kato to NVMF_DEF_DISC_TMO for persistent controllers */
+       if (cfg->persistent && !cfg->keep_alive_tmo)
+               cfg->keep_alive_tmo = NVMF_DEF_DISC_TMO;
+       /* Set kato to zero for non-persistent controllers */
+       else if (!cfg->persistent && (cfg->keep_alive_tmo > 0))
+               cfg->keep_alive_tmo = 0;
+}
+
 static int connect_ctrl(struct nvmf_disc_rsp_page_entry *e)
 {
        char argstr[BUF_SIZE], *p;
@@ -1220,8 +1230,7 @@ static int discover_from_conf_file(const
                if (err)
                        continue;
 
-               if (cfg.persistent && !cfg.keep_alive_tmo)
-                       cfg.keep_alive_tmo = NVMF_DEF_DISC_TMO;
+               set_discovery_kato(&cfg);
 
                err = build_options(argstr, BUF_SIZE, true);
                if (err) {
@@ -1286,8 +1295,8 @@ int discover(const char *desc, int argc,
        if (!cfg.transport && !cfg.traddr) {
                ret = discover_from_conf_file(desc, argstr, opts, connect);
        } else {
-               if (cfg.persistent && !cfg.keep_alive_tmo)
-                       cfg.keep_alive_tmo = NVMF_DEF_DISC_TMO;
+               set_discovery_kato(&cfg);
+
                ret = build_options(argstr, BUF_SIZE, true);
                if (ret)
                        goto out;
++++++ 0010-print-device-name-when-creating-a-persistent-device.patch ++++++
From: Martin Belanger <martin.belan...@dell.com>
Date: Mon, 22 Feb 2021 15:28:33 -0500
Subject: [PATCH] print device name when creating a persistent device
References: bsc#1182591
Git-commit: 554db7dd0a017a9042842ad11e24b64846335996

---
 fabrics.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fabrics.c
+++ b/fabrics.c
@@ -1143,6 +1143,8 @@ static int do_discover(char *argstr, boo
                return -errno;
        ret = nvmf_get_log_page_discovery(dev_name, &log, &numrec, &status);
        free(dev_name);
+       if (cfg.persistent)
+               printf("Persistent device: nvme%d\n", instance);
        if (!cfg.device && !cfg.persistent) {
                err = remove_ctrl(instance);
                if (err)
++++++ 0011-nvme-add-fabrics-discovery-controller-default-port-n.patch ++++++
From: Sagi Grimberg <s...@grimberg.me>
Date: Fri, 14 Aug 2020 13:42:37 -0700
Subject: [PATCH] nvme: add fabrics discovery controller default port number
References: bsc#1180505
Git-commit: 5cde509ee656141b88498726478df5c57a394926

The IANA port number for a discovery controller is 8009
for NVMe/TCP and 4420 for any NVMe/RDMA port number. So make
sure to fill it and pass it down, it will help us as we
track and match connection arguments for filtering purposes.

Signed-off-by: Sagi Grimberg <s...@grimberg.me>
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 common.h     |    3 +++
 fabrics.c    |   17 +++++++++++++++++
 linux/nvme.h |    1 +
 3 files changed, 21 insertions(+)

--- a/common.h
+++ b/common.h
@@ -9,4 +9,7 @@
 #define min(x, y) ((x) > (y) ? (y) : (x))
 #define max(x, y) ((x) > (y) ? (x) : (y))
 
+#define __stringify_1(x...) #x
+#define __stringify(x...)  __stringify_1(x)
+
 #endif
--- a/fabrics.c
+++ b/fabrics.c
@@ -855,6 +855,17 @@ static int build_options(char *argstr, i
        return 0;
 }
 
+static void discovery_trsvcid(struct config *cfg)
+{
+       if (!strcmp(cfg->transport, "tcp")) {
+               /* Default port for NVMe/TCP discovery controllers */
+               cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+       } else if (!strcmp(cfg->transport, "rdma")) {
+               /* Default port for NVMe/RDMA controllers */
+               cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
+       }
+}
+
 static void set_discovery_kato(struct config *cfg)
 {
        /* Set kato to NVMF_DEF_DISC_TMO for persistent controllers */
@@ -1234,6 +1245,9 @@ static int discover_from_conf_file(const
 
                set_discovery_kato(&cfg);
 
+               if (!cfg.trsvcid)
+                       discovery_trsvcid(&cfg);
+
                err = build_options(argstr, BUF_SIZE, true);
                if (err) {
                        ret = err;
@@ -1299,6 +1313,9 @@ int discover(const char *desc, int argc,
        } else {
                set_discovery_kato(&cfg);
 
+               if (!cfg.trsvcid)
+                       discovery_trsvcid(&cfg);
+
                ret = build_options(argstr, BUF_SIZE, true);
                if (ret)
                        goto out;
--- a/linux/nvme.h
+++ b/linux/nvme.h
@@ -70,6 +70,7 @@ static inline uint64_t le64_to_cpu(__le6
 #define NVME_DISC_SUBSYS_NAME  "nqn.2014-08.org.nvmexpress.discovery"
 
 #define NVME_RDMA_IP_PORT      4420
+#define NVME_DISC_IP_PORT      8009
 
 #define NVME_NSID_ALL          0xffffffff
 
++++++ 0012-fabrics-move-connect_args-extraction-to-a-dedicated-.patch ++++++
From: Sagi Grimberg <s...@grimberg.me>
Date: Fri, 14 Aug 2020 13:42:38 -0700
Subject: [PATCH] fabrics: move connect_args extraction to a dedicated routin
References: bsc#1179825
Git-commit: 1ca2593ee13a052b038ee3d4a16af14ccb9e578b

We will need it to track controllers as we are iterating over
nested discovery log pages recursion.

Signed-off-by: Sagi Grimberg <s...@grimberg.me>
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 fabrics.c |   46 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 14 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -354,6 +354,31 @@ static char *find_ctrl_with_connectargs(
        return devname;
 }
 
+static struct connect_args *extract_connect_args(char *argstr)
+{
+       struct connect_args *cargs;
+
+       cargs = calloc(1, sizeof(*cargs));
+       if (!cargs)
+               return NULL;
+       cargs->subsysnqn = parse_conn_arg(argstr, ',', conarg_nqn);
+       cargs->transport = parse_conn_arg(argstr, ',', conarg_transport);
+       cargs->traddr = parse_conn_arg(argstr, ',', conarg_traddr);
+       cargs->trsvcid = parse_conn_arg(argstr, ',', conarg_trsvcid);
+       cargs->host_traddr = parse_conn_arg(argstr, ',', conarg_host_traddr);
+       return cargs;
+}
+
+static void free_connect_args(struct connect_args *cargs)
+{
+       free(cargs->subsysnqn);
+       free(cargs->transport);
+       free(cargs->traddr);
+       free(cargs->trsvcid);
+       free(cargs->host_traddr);
+       free(cargs);
+}
+
 static int add_ctrl(const char *argstr)
 {
        substring_t args[MAX_OPT_ARGS];
@@ -1113,14 +1138,11 @@ static int do_discover(char *argstr, boo
        int status = 0;
 
        if (cfg.device) {
-               struct connect_args cargs;
+               struct connect_args *cargs;
 
-               memset(&cargs, 0, sizeof(cargs));
-               cargs.subsysnqn = parse_conn_arg(argstr, '.', conarg_nqn);
-               cargs.transport = parse_conn_arg(argstr, '.', conarg_transport);
-               cargs.traddr = parse_conn_arg(argstr, '.', conarg_traddr);
-               cargs.trsvcid = parse_conn_arg(argstr, '.', conarg_trsvcid);
-               cargs.host_traddr = parse_conn_arg(argstr, '.', 
conarg_host_traddr);
+               cargs = extract_connect_args(argstr);
+               if (!cargs)
+                       return -ENOMEM;
 
                /*
                 * if the cfg.device passed in matches the connect args
@@ -1133,14 +1155,10 @@ static int do_discover(char *argstr, boo
                 *    create a new ctrl.
                 * endif
                 */
-               if (!ctrl_matches_connectargs(cfg.device, &cargs))
-                       cfg.device = find_ctrl_with_connectargs(&cargs);
+               if (!ctrl_matches_connectargs(cfg.device, cargs))
+                       cfg.device = find_ctrl_with_connectargs(cargs);
 
-               free(cargs.subsysnqn);
-               free(cargs.transport);
-               free(cargs.traddr);
-               free(cargs.trsvcid);
-               free(cargs.host_traddr);
+               free_connect_args(cargs);
        }
 
        if (!cfg.device)
++++++ 0013-nvme-discover-lookup-existing-persistent-controllers.patch ++++++
From: Hannes Reinecke <h...@suse.de>
Date: Thu, 25 Feb 2021 17:12:20 +0100
Subject: [PATCH] nvme-discover: lookup existing persistent controllers
References: bsc#1179825
Git-commit: 14d0e0f7e0c1b420da65783881c064e49ac7d6d7

If persistent controller connections are present they should be
preferred even if no --device option is given on the commandline.

To avoid selecting a temporary non-persistent controller the
'kato' attribute is checked; any controller for which the
attribute is '0' will be skipped. This logic is not applied on
older kernels that don't support the 'kato' attribute. On these
kernels, we just have to assume that the encountered discovery
controller is persistent.

Signed-off-by: Hannes Reinecke <h...@suse.de>
Signed-off-by: Martin Wilck <mwi...@suse.de>
---
 fabrics.c |   55 ++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 32 insertions(+), 23 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -286,6 +286,7 @@ static bool ctrl_matches_connectargs(cha
        bool found = false;
        char *path, *addr;
        int ret;
+       bool persistent = true;
 
        ret = asprintf(&path, "%s/%s", SYS_NVME, name);
        if (ret < 0)
@@ -298,7 +299,30 @@ static bool ctrl_matches_connectargs(cha
        cargs.trsvcid = parse_conn_arg(addr, ' ', conarg_trsvcid);
        cargs.host_traddr = parse_conn_arg(addr, ' ', conarg_host_traddr);
 
-       if (!strcmp(cargs.subsysnqn, args->subsysnqn) &&
+       if (!strcmp(cargs.subsysnqn, NVME_DISC_SUBSYS_NAME)) {
+               char *kato_str = nvme_get_ctrl_attr(path, "kato"), *p;
+               unsigned int kato = 0;
+
+               /*
+                * When looking up discovery controllers we have to skip
+                * any non-persistent controllers (ie those with a zero
+                * kato value). Otherwise the controller will vanish from
+                * underneath us as they are owned by another program.
+                *
+                * On older kernels, the 'kato' attribute isn't present.
+                * Assume a persistent controller for these installations.
+                */
+               if (kato_str) {
+                       kato = strtoul(kato_str, &p, 0);
+                       if (p == kato_str)
+                               kato = 0;
+                       free(kato_str);
+                       persistent = (kato != 0);
+               }
+       }
+
+       if (persistent &&
+           !strcmp(cargs.subsysnqn, args->subsysnqn) &&
            !strcmp(cargs.transport, args->transport) &&
            (!strcmp(cargs.traddr, args->traddr) ||
             !strcmp(args->traddr, "none")) &&
@@ -1136,30 +1160,15 @@ static int do_discover(char *argstr, boo
        char *dev_name;
        int instance, numrec = 0, ret, err;
        int status = 0;
+       struct connect_args *cargs;
 
-       if (cfg.device) {
-               struct connect_args *cargs;
-
-               cargs = extract_connect_args(argstr);
-               if (!cargs)
-                       return -ENOMEM;
-
-               /*
-                * if the cfg.device passed in matches the connect args
-                *    cfg.device is left as-is
-                * else if there exists a controller that matches the
-                *         connect args
-                *    cfg.device is the matching ctrl name
-                * else if no ctrl matches the connect args
-                *    cfg.device is set to null. This will attempt to
-                *    create a new ctrl.
-                * endif
-                */
-               if (!ctrl_matches_connectargs(cfg.device, cargs))
-                       cfg.device = find_ctrl_with_connectargs(cargs);
+       cargs = extract_connect_args(argstr);
+       if (!cargs)
+               return -ENOMEM;
 
-               free_connect_args(cargs);
-       }
+       if (!cfg.device || !ctrl_matches_connectargs(cfg.device, cargs))
+               cfg.device = find_ctrl_with_connectargs(cargs);
+       free_connect_args(cargs);
 
        if (!cfg.device)
                instance = add_ctrl(argstr);
++++++ 0014-nvme-topology-no-error-message-when-openeing-of-cont.patch ++++++
From: Daniel Wagner <dwag...@suse.de>
Date: Wed, 2 Jun 2021 15:42:42 +0200
Subject: [PATCH] nvme-topology: no error message when openeing of controller
 fails
References: bsc#1186719
Git-commit: 7c2833a047ad9754ccb9b26b863f3967b85aad57

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 <dwag...@suse.de>
---
 nvme-topology.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -224,10 +224,8 @@ static int scan_ctrl(struct nvme_ctrl *c
                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)
++++++ 0015-nvme-ioctl-return-1-on-failure-from-nvme_get_nsid.patch ++++++
From: Hannes Reinecke <h...@suse.de>
Date: Tue, 22 Jun 2021 13:40:23 +0200
Subject: nvme-ioctl: return -1 on failure from nvme_get_nsid()
References: bsc#1186719
Git-commit: 22c19f6a5b58ad9ce99d2c2a95239eab911d908e

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 <h...@suse.de>
---
 nvme-ioctl.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -71,7 +71,7 @@ int nvme_get_nsid(int fd)
        int err = fstat(fd, &nvme_stat);
 
        if (err < 0)
-               return -errno;
+               return err;
 
        if (!S_ISBLK(nvme_stat.st_mode)) {
                fprintf(stderr,
++++++ 0016-nvme-topology-scan-all-controllers-in-scan_subsystem.patch ++++++
From: Hannes Reinecke <h...@suse.de>
Date: Tue, 22 Jun 2021 13:48:36 +0200
Subject: nvme-topology: scan all controllers in scan_subsystem()
References: bsc#1186719
Git-commit: ce9d818f420af6be0801004a77e91915587fc02f

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 <h...@suse.de>
---
 nvme-topology.c |   22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -102,21 +102,22 @@ static int scan_namespace(struct nvme_na
                return ret;
 
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
+               ret = fd;
                goto free;
+       }
 
-       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)
@@ -242,7 +243,7 @@ static int scan_subsystem(struct nvme_su
        struct dirent **ctrls, **ns;
        struct nvme_namespace *n;
        struct nvme_ctrl *c;
-       int i, ret;
+       int i, j, ret;
        char *path;
 
        ret = asprintf(&path, "%s%s", subsys_dir, s->name);
@@ -279,8 +280,11 @@ static int scan_subsystem(struct nvme_su
        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;
+               }
        }
 
        while (i--)
++++++ 0017-connect-all-add-m-matching-option.patch ++++++
From: Martin Wilck <mwi...@suse.com>
Date: Wed, 29 Apr 2020 19:03:57 +0200
Subject: connect-all: add -m/--matching option
References: bsc#1186719
Git-commit: a58556cc3022ec443f0db4a5218d8e2bfb3be481

Discovery controllers often return discovery records that belong
to a different traddr than the discovery controller itself, like here:

nvme discover -t fc \
   --host-traddr=nn-0x20000090fae06325:pn-0x10000090fae06325 \
   --traddr=nn-0x200900a09890f5bf:pn-0x200a00a09890f5bf

Discovery Log Number of Records 2, Generation counter 25
=====Discovery Log Entry 0======
trtype:  fc
adrfam:  fibre-channel
subtype: nvme subsystem
treq:    not specified
portid:  0
trsvcid: none
subnqn:  nqn...
traddr:  nn-0x200900a09890f5bf:pn-0x200b00a09890f5bf
=====Discovery Log Entry 1======
trtype:  fc
adrfam:  fibre-channel
subtype: nvme subsystem
treq:    not specified
portid:  1
trsvcid: none
subnqn:  nqn...
traddr:  nn-0x200900a09890f5bf:pn-0x200a00a09890f5bf

Note that the traddr of record 0 matches the traddr used for the
discovery, while that of record 1 does not.

For NVMeoF-autoconnect, this means that connection attempts will
be made multiple times (the two records above will also be returned
for a discovery on nn-0x200900a09890f5bf:pn-0x200b00a09890f5bf),
which is unnecessary and leads to lots of confusing error messages
in the system log.

Add an option "-m / --matching" to the "nvme connect-all" command
that causes nvme to connect only those discovery entries that match
the traddr given on the command line.
---
 fabrics.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

--- a/fabrics.c
+++ b/fabrics.c
@@ -80,6 +80,7 @@ static struct config {
        int  data_digest;
        bool persistent;
        bool quiet;
+       bool matching_only;
 } cfg = { NULL };
 
 struct connect_args {
@@ -1117,6 +1118,17 @@ static int connect_ctrl(struct nvmf_disc
        return ret;
 }
 
+static bool should_connect(struct nvmf_disc_rsp_page_entry *entry)
+{
+       int len;
+
+       if (!cfg.matching_only || !cfg.traddr)
+               return true;
+
+       len = space_strip_len(NVMF_TRADDR_SIZE, entry->traddr);
+       return !strncmp(cfg.traddr, entry->traddr, len);
+}
+
 static int connect_ctrls(struct nvmf_disc_rsp_page_hdr *log, int numrec)
 {
        int i;
@@ -1124,6 +1136,9 @@ static int connect_ctrls(struct nvmf_dis
        int ret = 0;
 
        for (i = 0; i < numrec; i++) {
+               if (!should_connect(&log->entries[i]))
+                       continue;
+
                instance = connect_ctrl(&log->entries[i]);
 
                /* clean success */
@@ -1322,6 +1337,7 @@ int discover(const char *desc, int argc,
                OPT_INT("queue-size",      'Q', &cfg.queue_size,      "number 
of io queue elements to use (default 128)"),
                OPT_FLAG("persistent",     'p', &cfg.persistent,      
"persistent discovery connection"),
                OPT_FLAG("quiet",          'S', &cfg.quiet,           "suppress 
already connected errors"),
+               OPT_FLAG("matching",       'm', &cfg.matching_only,   "connect 
only records matching the traddr"),
                OPT_END()
        };
 
++++++ 0018-fabrics-skip-connect-if-transport-type-doesn-t-match.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Sat, 5 Jun 2021 15:16:26 +0530
Subject: fabrics: skip connect if transport type doesn't match
References: bsc#1187287 bsc#1187860
Git-commit: edf0998f5a668b141c73a9648acf427105586372

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 <mart...@netapp.com>
---
 fabrics.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/fabrics.c
+++ b/fabrics.c
@@ -1122,6 +1122,10 @@ static bool should_connect(struct nvmf_d
 {
        int len;
 
+       /* skip connect if the transport type doesn't match */
+       if (strcmp(cfg.transport, trtype_str(entry->trtype)))
+               return false;
+
        if (!cfg.matching_only || !cfg.traddr)
                return true;
 
++++++ 0019-nvme-topology-fix-controller-check-in-scan_subsystem.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Mon, 19 Jul 2021 10:07:48 -0700
Subject: nvme-topology: fix controller check in scan_subsystem()
References: bsc#1186719 bsc#1187287
Git-commit: bace574bbe55739a49e7fada5483b3d3a5ef361c

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 <mart...@netapp.com>
Reviewed-by: Daniel Wagner <dwag...@suse.de>
Signed-off-by: Keith Busch <kbu...@kernel.org>
---
 nvme-topology.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/nvme-topology.c
+++ b/nvme-topology.c
@@ -282,7 +282,8 @@ static int scan_subsystem(struct nvme_su
                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;
                }
        }
++++++ 0020-gen-hostnqn-Remove-UUID-validation-heuristic.patch ++++++
From: Daniel Wagner <dwag...@suse.de>
Date: Fri, 23 Jul 2021 12:32:15 +0200
Subject: gen-hostnqn: Remove UUID validation heuristic
References: bsc#1187890
Git-commit: 7f608a5a920585d5c3b24c2270bf0369886f4576

The validation heuristic is getting triggered for valid system UUID
such as 37383638-3330-4d32-3237-33353032394e. The only UUID validation
is already implemented. Remove the heuristic as it blocks valid use
UUIDs and doesn't protect from misuse anyway.

Signed-off: Daniel Wagner <dwag...@suse.de>
---
 scripts/gen-hostnqn.sh |   18 ------------------
 1 file changed, 18 deletions(-)

--- a/scripts/gen-hostnqn.sh
+++ b/scripts/gen-hostnqn.sh
@@ -19,24 +19,6 @@ if ! [[ $UUID =~ ^[0-9a-f]{8}-[0-9a-f]{4
        exit 2
 fi
 
-# HEURISTIC:
-# (1) if any one given character occurs more than 50% of the time, it is likely
-# that the UUID is fake.
-# (2) if the first or the last group consists of mostly the same character, it
-# is likely that the UUID is fake.
-FIRST_GROUP="$(echo $UUID | cut -d'-' -f1)"
-LAST_GROUP="$(echo $UUID | cut -d'-' -f5)"
-for i in {{0..9},{a..f}} ; do
-       COUNT_TOTAL="${UUID//[^$i]}"
-       COUNT_FIRST="${FIRST_GROUP//[^$i]}"
-       COUNT_LAST="${LAST_GROUP//[^$i]}"
-       if [ ${#COUNT_TOTAL} -ge 16 ] || [ ${#COUNT_FIRST} -ge 7 ] || [ 
${#COUNT_LAST} -ge 11 ] ; then
-               >&2 echo "UUID is too repetitive. This may be a false alert."
-               >&2 echo "Repetitive UUID: ${UUID}"
-               exit 3
-       fi
-done
-
 HOSTNQN="nqn.2014-08.org.nvmexpress:uuid:${UUID}"
 
 echo $HOSTNQN
++++++ 0021-nvme-print-fix-nvme-list-segfault-if-controller-is-u.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Thu, 5 Aug 2021 18:01:24 +0530
Subject: nvme-print: fix 'nvme list' segfault if controller is
 unavailable
References: bsc#1189046
Git-commit: 59e7477c5a18ec4bcb1f9b1e20d2303b4e0cafb1

Check if the controller is available before dereferencing the
controller attributes.

Signed-off-by: Martin George <mart...@netapp.com>
---
 nvme-print.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- a/nvme-print.c
+++ b/nvme-print.c
@@ -4305,6 +4305,9 @@ static void nvme_show_list_item(struct n
        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,
@@ -4356,6 +4359,9 @@ static void nvme_show_details_ns(struct
        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,
@@ -4553,6 +4559,9 @@ static void json_simple_ns(struct nvme_n
        long long lba;
        char *devnode;
 
+       if (!n->ctrl)
+               return;
+
        if (asprintf(&devnode, "/dev/%s", n->name) < 0)
                return;
 
++++++ 0022-fabrics-add-default-port-number-for-NVMe-TCP-I-O-con.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Fri, 6 Aug 2021 17:35:20 +0530
Subject: fabrics: add default port number for NVMe/TCP I/O controllers
References: bsc#1189195 bsc#1187858
Git-commit: 362c90f364a8e96a2551e83e9fc5746bf4aed859

As per section 7.4.9.3 "Transport Service Identifier" of the NVMe over
Fabrics 1.1 specification, the default IANA port number for a NVMe/TCP
discovery controller is 8009. But at the same time, it also clearly
states that NVMe/TCP I/O controllers should not use TCP port number
8009, but may instead use 4420 as the default here.

So make sure to fill these values appropriately, and pass it down.

Signed-off-by: Martin George <mart...@netapp.com>
---
 fabrics.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -905,11 +905,16 @@ static int build_options(char *argstr, i
        return 0;
 }
 
-static void discovery_trsvcid(struct config *cfg)
+static void discovery_trsvcid(struct config *cfg, bool discover)
 {
        if (!strcmp(cfg->transport, "tcp")) {
-               /* Default port for NVMe/TCP discovery controllers */
-               cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+               if (discover) {
+                       /* Default port for NVMe/TCP discovery controllers */
+                       cfg->trsvcid = __stringify(NVME_DISC_IP_PORT);
+               } else {
+                       /* Default port for NVMe/TCP io controllers */
+                       cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
+               }
        } else if (!strcmp(cfg->transport, "rdma")) {
                /* Default port for NVMe/RDMA controllers */
                cfg->trsvcid = __stringify(NVME_RDMA_IP_PORT);
@@ -1292,7 +1297,7 @@ static int discover_from_conf_file(const
                set_discovery_kato(&cfg);
 
                if (!cfg.trsvcid)
-                       discovery_trsvcid(&cfg);
+                       discovery_trsvcid(&cfg, true);
 
                err = build_options(argstr, BUF_SIZE, true);
                if (err) {
@@ -1361,7 +1366,7 @@ int discover(const char *desc, int argc,
                set_discovery_kato(&cfg);
 
                if (!cfg.trsvcid)
-                       discovery_trsvcid(&cfg);
+                       discovery_trsvcid(&cfg, true);
 
                ret = build_options(argstr, BUF_SIZE, true);
                if (ret)
@@ -1407,6 +1412,9 @@ int connect(const char *desc, int argc,
        if (ret)
                goto out;
 
+       if (!cfg.trsvcid)
+               discovery_trsvcid(&cfg, false);
+
        ret = build_options(argstr, BUF_SIZE, false);
        if (ret)
                goto out;
++++++ 0023-Fixing-Alignment-Error-In-intel-smart-log-add.patch ++++++
From: Ben Reese <5884008+benree...@users.noreply.github.com>
Date: Tue, 3 Mar 2020 13:41:41 -0800
Subject: Fixing Alignment Error In intel smart-log-add
References: bsc#1177737
Git-commit: bb958d5e21eb788e2c2a2137f4b16fa15391cb3b

Fixing alignment in nvme_additional_smart_log_item introduced by switch
from '#pragma pack' semantics to '__attribute__((pack))'.

Per https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html each
union or struct requires it's own '__attribute__((pack))'.

Signed-off-by: Ben Reese <5884008+benree...@users.noreply.github.com>
---
 plugins/intel/intel-nvme.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

--- a/plugins/intel/intel-nvme.c
+++ b/plugins/intel/intel-nvme.c
@@ -20,25 +20,25 @@
 #define CREATE_CMD
 #include "intel-nvme.h"
 
-struct nvme_additional_smart_log_item {
+struct  __attribute__((packed)) nvme_additional_smart_log_item {
        __u8                    key;
        __u8                    _kp[2];
        __u8                    norm;
        __u8                    _np;
-       union {
+       union __attribute__((packed)) {
                __u8            raw[6];
-               struct wear_level {
+               struct __attribute__((packed))  wear_level {
                        __le16  min;
                        __le16  max;
                        __le16  avg;
                } wear_level;
-               struct thermal_throttle {
+               struct __attribute__((packed)) thermal_throttle {
                        __u8    pct;
                        __u32   count;
                } thermal_throttle;
-       };
+       } ;
        __u8                    _rp;
-} __attribute__((packed));
+} ;
 
 struct nvme_additional_smart_log {
        struct nvme_additional_smart_log_item   program_fail_cnt;
++++++ 0024-nvme-cli-ctrl-loss-tmo-should-accept-1-as-value.patch ++++++
From: Maurizio Lombardi <mlomb...@redhat.com>
Date: Mon, 8 Nov 2021 14:26:56 +0100
Subject: nvme-cli: ctrl-loss-tmo should accept -1 as value
References: bsc#1192348
Git-commit: 166f7453d7874dec25314c5148543e0577dd4e25

When passing the parameter --ctrl-loss-tmo=-1
nvme-cli silently drops it and replaces its value with the
default one (600) despite the fact that -1 is valid
and accepted by the kernel.
ctrl_loss_tmo < 0 means that it will try to reconnect forever

This is due to the fact that -1 is treated like "variable unset"
by nvme-cli and the add_int_argument() function ignores
all arguments with such a value if allow_zero is true (the latter seems
to be completely unintended).

This patch fixes the bug by:

1) removing the "arg == -1" condition from add_int_argument() and letting
   the caller take care of checking if -1 is an acceptable value
   for a particular argument.

2) initializing ctrl_loss_tmo to its default value instead of -1.

Signed-off-by: Maurizio Lombardi <mlomb...@redhat.com>
[dwagner: updated context, dropped hunks which depends missing code]
Signed-off-by: Daniel Wagner <dwag...@suse.de>
---
 fabrics.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -818,7 +818,7 @@ add_int_argument(char **argstr, int *max
 {
        int len;
 
-       if ((arg && !allow_zero) || (arg != -1 && allow_zero)) {
+       if (arg || allow_zero) {
                len = snprintf(*argstr, *max_len, ",%s=%d", arg_str, arg);
                if (len < 0)
                        return -EINVAL;
@@ -892,8 +892,9 @@ static int build_options(char *argstr, i
                                cfg.reconnect_delay, false) ||
            add_int_argument(&argstr, &max_len, "ctrl_loss_tmo",
                                cfg.ctrl_loss_tmo, false) ||
+           (cfg.tos != -1 &&
            add_int_argument(&argstr, &max_len, "tos",
-                               cfg.tos, true) ||
+                               cfg.tos, true)) ||
            add_bool_argument(&argstr, &max_len, "duplicate_connect",
                                cfg.duplicate_connect) ||
            add_bool_argument(&argstr, &max_len, "disable_sqflow",
++++++ 0025-Input-expects-device-name-without-dev.patch ++++++
From: Eric Curtin <ericcurti...@gmail.com>
Date: Wed, 10 Feb 2021 00:01:59 +0000
Subject: Input expects device name without /dev
References: bsc#1191935
Git-commit: dcfe0156360deaefa26b1d00053a791eefe397d1

But don't segfault if user gets this incorrect, instead provide helpful
info.

[dwagner: dropped hunk which was already present]
Signed-off-by: Daniel Wagner <dwag...@suse.de>
---
 fabrics.c |    5 +++++
 1 file changed, 5 insertions(+)

--- a/fabrics.c
+++ b/fabrics.c
@@ -294,6 +294,11 @@ static bool ctrl_matches_connectargs(cha
                return found;
 
        addr = nvme_get_ctrl_attr(path, "address");
+       if (!addr) {
+               fprintf(stderr, "nvme_get_ctrl_attr failed\n");
+               return found;
+       }
+
        cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
        cargs.transport = nvme_get_ctrl_attr(path, "transport");
        cargs.traddr = parse_conn_arg(addr, ' ', conarg_traddr);
++++++ 0026-fabrics-fix-nvme-discover-segfault-if-sysfs-path-is-.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Sat, 30 Oct 2021 15:13:22 +0530
Subject: fabrics: fix 'nvme discover' segfault if sysfs path is not available
References: bsc#11919
Git-commit: 1490c6a86ca8363f3d12a06298e47dbb5a539b70

Avoid dereferencing connect_args strings if the corresponding nvme
sysfs paths are not available.

Signed-off-by: Martin George <mart...@netapp.com>
---
 fabrics.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -294,13 +294,14 @@ static bool ctrl_matches_connectargs(cha
                return found;
 
        addr = nvme_get_ctrl_attr(path, "address");
-       if (!addr) {
+       cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
+       cargs.transport = nvme_get_ctrl_attr(path, "transport");
+
+       if (!addr || !cargs.subsysnqn || !cargs.transport) {
                fprintf(stderr, "nvme_get_ctrl_attr failed\n");
-               return found;
+               goto out;
        }
 
-       cargs.subsysnqn = nvme_get_ctrl_attr(path, "subsysnqn");
-       cargs.transport = nvme_get_ctrl_attr(path, "transport");
        cargs.traddr = parse_conn_arg(addr, ' ', conarg_traddr);
        cargs.trsvcid = parse_conn_arg(addr, ' ', conarg_trsvcid);
        cargs.host_traddr = parse_conn_arg(addr, ' ', conarg_host_traddr);
@@ -338,6 +339,7 @@ static bool ctrl_matches_connectargs(cha
             !strcmp(args->host_traddr, "none")))
                found = true;
 
+out:
        free(cargs.subsysnqn);
        free(cargs.transport);
        free(cargs.traddr);
++++++ 0027-fabrics-Only-free-initialized-valued-on-exit.patch ++++++
From: Daniel Wagner <dwag...@suse.de>
Date: Mon, 8 Nov 2021 10:22:17 +0100
Subject: fabrics: Only free initialized valued on exit
References: bsc#1191935
Git-commit: f868aa4cbbed813118acd5ff109e4bb82e1ed49f

ctrl_matches_connectargs() bails out if addr, subsysnqn or transport
are not valid. If this is the case only attempt to free those pointers
as these pointers are properly inialized, e.g. either NULL or a valid.

Signed-off-by: Daniel Wagner <dwag...@suse.de>
---
 fabrics.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/fabrics.c
+++ b/fabrics.c
@@ -339,12 +339,12 @@ static bool ctrl_matches_connectargs(cha
             !strcmp(args->host_traddr, "none")))
                found = true;
 
-out:
-       free(cargs.subsysnqn);
-       free(cargs.transport);
        free(cargs.traddr);
        free(cargs.trsvcid);
        free(cargs.host_traddr);
+out:
+       free(cargs.subsysnqn);
+       free(cargs.transport);
 
        return found;
 }
++++++ 0028-nvme-print-add-discovery-async-event-config-field.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Wed, 27 Oct 2021 14:30:24 +0530
Subject: nvme-print: add discovery async event config field
References: bsc#1191935
Git-commit: b7ccd742924ffcb8770ee5dd1a88adc39636451e

Add a new async event config field for discovery log page
change notices.

Signed-off-by: Martin George <mart...@netapp.com>
---
 nvme-print.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/nvme-print.c
+++ b/nvme-print.c
@@ -4199,10 +4199,12 @@ void nvme_feature_show_fields(__u32 fid,
                printf("\tDisable Normal (DN): %s\n", (result & 0x00000001) ? 
"True":"False");
                break;
        case NVME_FEAT_ASYNC_EVENT:
+               printf("\tDiscovery Log Page Change Notices: %s\n", ((result & 
0x80000000) >> 31) ? "Send async event":"Do not send async event");
                printf("\tTelemetry Log Notices           : %s\n", ((result & 
0x00000400) >> 10) ? "Send async event":"Do not send async event");
                printf("\tFirmware Activation Notices     : %s\n", ((result & 
0x00000200) >> 9) ? "Send async event":"Do not send async event");
                printf("\tNamespace Attribute Notices     : %s\n", ((result & 
0x00000100) >> 8) ? "Send async event":"Do not send async event");
                printf("\tSMART / Health Critical Warnings: %s\n", (result & 
0x000000ff) ? "Send async event":"Do not send async event");
+
                break;
        case NVME_FEAT_AUTO_PST:
                printf("\tAutonomous Power State Transition Enable (APSTE): 
%s\n", (result & 0x00000001) ? "Enabled":"Disabled");
++++++ 0029-fabrics-fix-nvme-connect-segfault-if-transport-type-.patch ++++++
From: Martin George <mart...@netapp.com>
Date: Mon, 15 Nov 2021 16:00:47 +0530
Subject: fabrics: fix 'nvme connect' segfault if transport type is omitted
References: bsc#1191935
Git-commit: f74ac1b841b0aae73969debaed0444f0ecb03dba

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 <mart...@netapp.com>
---
 fabrics.c |    2 ++
 1 file changed, 2 insertions(+)

--- a/fabrics.c
+++ b/fabrics.c
@@ -907,6 +907,8 @@ static int build_options(char *argstr, i
 
 static void discovery_trsvcid(struct config *cfg, bool discover)
 {
+       if (!cfg->transport)
+               return;
        if (!strcmp(cfg->transport, "tcp")) {
                if (discover) {
                        /* Default port for NVMe/TCP discovery controllers */
++++++ 0100-build-use-pkg-config-for-libuuid-detection.patch ++++++
From: Daniel Wagner <dwag...@suse.de>
Date: Fri, 23 Jul 2021 12:32:15 +0200
Subject: build: Use pkg-config for libuuid detection

The ppc64le build fails because libuuid is not correctly detected and
the final build doesn't inlcude support for generating uuids via 'nvme
gen-hostnqn'.

Use pkg-config to figure out if libuuid is installed or not.

Signed-off-by: Daniel Wagner <dwag...@suse.de>

---
 Makefile |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,7 @@
 CFLAGS ?= -O2 -g -Wall -Werror
 override CFLAGS += -std=gnu99 -I.
 override CPPFLAGS += -D_GNU_SOURCE -D__CHECK_ENDIAN__
-LIBUUID = $(shell $(LD) -o /dev/null -luuid >/dev/null 2>&1; echo $$?)
+LIBUUID = $(shell pkg-config --exists uuid; echo $$?)
 LIBHUGETLBFS = $(shell $(LD) -o /dev/null -lhugetlbfs >/dev/null 2>&1; echo 
$$?)
 HAVE_SYSTEMD = $(shell pkg-config --exists systemd  --atleast-version=232; 
echo $$?)
 NVME = nvme
++++++ _service ++++++
<services>
  <service name="tar_scm" mode="disabled">
    <param name="scm">git</param>
    <param name="url">https://github.com/linux-nvme/nvme-cli.git</param>
    <param name="filename">nvme-cli</param>
    <param name="version">1.10</param>
    <param name="revision">v1.10</param>
    <param name="exclude">.git</param>
    <param name="changesgenerate">enable</param>
  </service>
  <service name="recompress" mode="disabled">
    <param name="file">*.tar</param>
    <param name="compression">gz</param>    
  </service>
  <service name="set_version" mode="disabled">
    <param name="basename">nvme-cli</param>
  </service>
</services>
++++++ _servicedata ++++++
<servicedata>
<service name="tar_scm">
            <param name="url">https://github.com/linux-nvme/nvme-cli.git</param>
          <param 
name="changesrevision">d158aaefcfb063eca95f1bd0c522abf3a17a085d</param></service></servicedata>++++++
 nvme-cli-rpmlintrc ++++++
addFilter("W: systemd-service-without-service_del_preun")
addFilter("W: systemd-service-without-service_del_postun")

Reply via email to