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>
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>
Jeremy Kerr [Wed, 20 Oct 2021 03:59:03 +0000 (11:59 +0800)]
types.h: heal -> health
We currently have an abbreviation 'heal' in nvme_mi_ctrl_heal_status;
while the subsystem health status uses the full 'health'. This change
unifies these by using the full term instead of the abbreviation.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Klaus Jensen [Wed, 29 Sep 2021 19:07:41 +0000 (21:07 +0200)]
types: remove endian/mmio helpers
The endian/mmio helpers do not belong in types.h.
Since we are already using ccan and have ccan/endian available, just
include that where needed. The implementation is 100% equivalent, even
with sparse annotations.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Klaus Jensen [Wed, 29 Sep 2021 17:44:55 +0000 (19:44 +0200)]
types: move command parameters from ioctl.h
Move spec-defined command parameters out of nvme/ioctl.h and into
nvme/types.h. This allows third-party libraries and applications to use
the type definitions of libnvme without potentially clashing with
various function prototypes that are ioctl specific.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Klaus Jensen [Tue, 19 Oct 2021 20:13:53 +0000 (22:13 +0200)]
meson: revert to using the ccan configurator
Something fishy is going on with the -include config.h and #include
"config.h" in the ccan sources. If examples/tests use ccan, they end up
with redefinitions caused by the ccan config defines not being properly set.
Revert to generating a ccan-specific config.h using the configurator (like the
Make-based setup).
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Klaus Jensen [Tue, 19 Oct 2021 19:34:38 +0000 (21:34 +0200)]
src/Makefile: fix ccan config.h
The ccan/ccan-config.h generated by the ccan configurator is never read
by the ccan sources which expect config.h. Instead, because of -I.. in
src/Makefile, the ccan sources picks up the base config.h (as generated
by configure). All kinds of wrong since config.h should actually have
been config-host.h.
Fix the compiler args to not include the base directory and generate the
ccan config file as ccan/config.h. Rename ./config.h to ./config-host.h.
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>