Sagi Grimberg [Sun, 28 Nov 2021 13:03:03 +0000 (15:03 +0200)]
fabrics: fix endless loop in connect-all for NVME_NQN_CURR
For a discovery log page entry that indicates the discovery controller
that returned it (i.e. itself), we need to set the controller as
discovered (because we got the discovery log page by connecting to it).
Without this connect-all goes in an endless loop keep connecting and
retrieving the log page from the same discovery subsystem port.
Daniel Wagner [Fri, 19 Nov 2021 10:25:37 +0000 (11:25 +0100)]
build: Do not use the configurator for meson
meson does the feature detection itself and we don't have to rely on
the configurator. So don't use it.
To avoid touching the ccan files, we have to rethink our config.h to
libnvme-config.h rename change. Since the ccan files include
'config.h' we have to use the second option to avoid including it into
external include paths. This is moving the config.h file into a
private folder and drop the include path '.'.
Hannes Reinecke [Thu, 18 Nov 2021 16:35:53 +0000 (17:35 +0100)]
Sanitize zns command arguments
With the recent up the calling convention has been sanitzed to always
have the 'timeout' argument as second-to-last, and the 'result' as the
laster argument.
Modify the zns commands accordingly.
Hannes Reinecke [Wed, 11 Aug 2021 06:04:38 +0000 (08:04 +0200)]
Implement 'dhchap_key' host and controller attributes
Implement a 'dhchap_key' attribute for the nvme_host structure to
support the 'dhchap_secret' connection argument, and a
'dhchap_key' attribute for the nvme_controller structure to support
the 'dhchap_ctrl_secret' connection argument.
Hannes Reinecke [Thu, 18 Nov 2021 09:29:10 +0000 (10:29 +0100)]
Add 'result' argument to ioctl wrapper functions
The ioctl wrapper function are pretty inconsistent as to whether
the NVME cqe result is returned or not.
We'd better add it to every function to have a consistent interface.
Daniel Wagner [Thu, 18 Nov 2021 09:04:13 +0000 (10:04 +0100)]
build: Rename config.h to libnvme-config.h
The meson documentation recommends not to put a config.h file in the
external search path. This will clash with any project consuming this
library. There are two ways to workaround, either renaming the config
header file or put it under a different path which isn't added into
the default include path.
Minwoo Im [Mon, 15 Nov 2021 14:46:00 +0000 (23:46 +0900)]
tree: add namespace chrdev name to nvme_ns
Namespace device node is initialized into two different nodes: block
device and character device which is a generic device used when block
device is not available due to initialization failure in the kernel.
This can be directly retrieved from the `struct nvme_ns` to print out
the generic node in somewhere like `nvme list` command in nvme-cli.
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Hannes Reinecke [Wed, 17 Nov 2021 13:01:02 +0000 (14:01 +0100)]
fabrics: add nvmf_default_config()
'struct nvme_fabrics_config' has some default values, and the output
functions key off these values to filter the values being printed.
So to avoid applications having to know these default values this
patch introduces a function nvmf_default_config() to ensure that
every application is using the same defaults.
Daniel Wagner [Wed, 17 Nov 2021 12:38:30 +0000 (13:38 +0100)]
build: Lower json-c dependencies
libnvme has no hard requirement on json-c 0.14. It was updated to
match to min version for nvme-cli. But nvme-cli has added a
workaround, to avoid requiring a newer version of json-c. Let's drop
the requirement here too.
Hannes Reinecke [Tue, 16 Nov 2021 08:59:42 +0000 (09:59 +0100)]
fabrics: set 'discovery' argument for unique discovery controllers
Discovery controllers providing a unique NQN cannot be distinguished
by the NQN from 'normal' I/O controllers, so we need to add the keyword
'discovery' when creating the connection to indicate that this is a
disocvery connection.
Hannes Reinecke [Mon, 15 Nov 2021 14:27:27 +0000 (15:27 +0100)]
Distinguish between 'nvm' and 'discovery' subsystems
Add a 'subsystype' value to the subsystem to determine if a given
subsystem is a 'discovery' or a 'nvm' subsystem.
And also add a flags 'discovery_ctrl' to specify if a given controller
is a discovery controller; this allows connection to discovery controllers
with unique subsystem NQNs, as these cannot distinguished by the NQN
anymore.
Daniel Wagner [Thu, 11 Nov 2021 10:57:16 +0000 (11:57 +0100)]
build: Adopt libsystemd versioning scheme
systemd increases the micro version for every release which is
compatible to what libtool expects. This means we just have to add the
patch level to the version string which happens to be always 0.
Steven Seungcheol Lee [Thu, 4 Nov 2021 14:19:38 +0000 (15:19 +0100)]
types: Add Identify for CNS 08h NVMe spec 2.0a based
I/O Command Set Independent Identify Namespace data structure (CNS
08h) Most of data comes from existing data of id-ns which is common
from All I/O command set
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
[dwagner: ported from nvme-cli-monolithic] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Gollu Appalanaidu [Wed, 3 Nov 2021 14:31:45 +0000 (15:31 +0100)]
ioctl: Change IOCTL for read, write and compare commands
Change the IOCTL and depricate SQE structure for NVM commands
Read, Write and Compare Commands to add support for the Storage
Tag field (CDW2 and CDW3).
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Gollu Appalanaidu [Wed, 3 Nov 2021 13:13:46 +0000 (14:13 +0100)]
ioctl: add CDW2 and CDW3 support for Write Zeroes and Verify Command
Added support for the Variable Sized Expected Logical Block Storage Tag(ELBST)
and Expected Logical Block Reference Tag (ELBRT), CDW2 and CDW3 (00:47) bits
for NVM commands Write Zeroes and Verify commands.
Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
[dwagner: ported from nvme-cli-monolithic] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Jonathan Teh [Mon, 15 Nov 2021 18:02:00 +0000 (18:02 +0000)]
tree: fix memory leak in nvme_ctrl_lookup_subsystem_name
Ensure all dirents are freed when a successful stat(2) causes an early
break out of the loop.
Reproduced with valgrind running "nvme discover" against an NVMe-oF
target:
==34612== 32 bytes in 1 blocks are definitely lost in loss record 2 of 2
==34612== at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==34612== by 0x4963A4C: __scandir64_tail (scandir-tail-common.c:69)
==34612== by 0x16E77D: nvme_ctrl_lookup_subsystem_name.isra.0 (tree.c:1024)
==34612== by 0x170081: nvme_init_ctrl (tree.c:1100)
==34612== by 0x16DA1F: nvmf_add_ctrl (fabrics.c:558)
==34612== by 0x136B03: nvmf_discover (fabrics.c:516)
==34612== by 0x139999: handle_plugin (plugin.c:155)
==34612== by 0x1131E9: main (nvme.c:5967)
Signed-off-by: Jonathan Teh <jonathan.teh@mayadata.io> Reviewed-by: Keith Busch <kbusch@kernel.org> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Saw the segmentation fault. Also looks only the first event is good. Other events are like random stuff.
Persistent Event Log for device: nvme0
Action for Persistent Event Log: 0
Log Identifier: 13
Total Number of Events: 6963
Total Log Length : 674496
Log Revision: 1
Log Header Length: 492
Timestamp: 564586531692487
Power On Hours (POH): 5,576
Power Cycle Count: 92
PCI Vendor ID (VID): 5197
PCI Subsystem Vendor ID (SSVID): 4116
Serial Number (SN): S4WANE0N300041
Model Number (MN): PCIe4 1.6TB NVMe Flash Adapter x8
NVM Subsystem NVMe Qualified Name (SUBNQN): nqn.1994-11.com.samsung:nvme:PM1735::
HHHL:S4WANE0N300041
Supported Events Bitmap: BitMap[0] is 0xfe
BitMap[1] is 0x3f
Persistent Event Entries:
Event Type: 1
Event Type Revision: 1
Event Header Length: 21
Controller Identifier: 66
Event Timestamp: 0
Vendor Specific Information Length: 512
Event Length: 10496
Smart Health Event:
Smart Log for NVME device:nvme0 namespace-id:ffffffff
critical_warning : 0
temperature : 24°C (297 Kelvin)
available_spare : 100%
available_spare_threshold : 10%
percentage_used : 1%
endurance group critical warning summary: 0
data_units_read : 0
data_units_written
Event Type: 82 --------------->wrong event type??
Event Type Revision: 69
Event Header Length: 86
Controller Identifier: 20563
Event Timestamp: 65
Vendor Specific Information Length: 0
Event Length: 88
Reserved Event
Event Type: 242 -------->wrong event type?
Event Type Revision: 206
Event Header Length: 4
Controller Identifier: 0
Event Timestamp: 5039920509769225473
Vendor Specific Information Length: 0
Event Length: 0
Reserved Event
Location 1) is present on all the systems I've tested: SUSE, Red Hat,
Fedora, and Ubuntu. Unfortunately, location 2) does not exist on
Debian-based systems.
Currently, uuid_from_dmi() only reads from location 2), which fails
on Debian.
This patch adds code that reads from location 1) first, and will
only try location 2) if reading from 1) fails.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: Updated return value from -1 to -ENXIO] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Martin Belanger [Wed, 27 Oct 2021 12:20:10 +0000 (08:20 -0400)]
Add Python tests to meson framework.
Python has this strict directory layout requirement. A Python package is a
directory that must contain a __init__.py file in addition to containing
modules.
To be able to run Python tests and load modules directly from the build
directory, the Python package (libnvme) and module (nvme.py) must be organized
in the build directory the same way they would be in the install directory. And
the PYTHONPATH must be set to point to the build directory. In other words,
like this:
This patch changes the directory layout so that meson will organize the Python
package and module as shown above. The patch also defines Python tests and sets
the PYTHONPATH to allow importing directly from the build directory.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>