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>
Martin Belanger [Tue, 19 Oct 2021 18:34:03 +0000 (14:34 -0400)]
Make Python Bindings optional
Added a new configuration parameter "python". By default it is set to 'auto',
which means that the Python bindings will be built if all dependencies can be
found on the host. If not, Python bindings won;t be built. The option can
also be set to 'true' or 'false' to force Python bindings to be built or not.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Tue, 19 Oct 2021 08:15:32 +0000 (10:15 +0200)]
build: Add fallback dependency for json-c
meson supports embedded library build. This is very handy for system
which ship outdated an really outdated json-c library.
The include path for json.h has to be adapted. The json-c upstream
project is not clear which include prefix should be used ('#include
<json-c/json.h>" vs '#include <json.h>'. In order to support embedded
builds, we need to use the second version of the include. The source
code is added to the build, hence we use the include directory path of
the project layout. And json-c has all include files in the root
directory. This is no problem when using a installed version of json-c
as pkg-config adds '-I/usr/inlude/json-c' to the include paths:
$pkg-config --cflags json-c
-I/usr/include/json-c
So the simplest thing to support both build cased (external/embedded)
just drop the include prefix.
While at it also fix the 'requires' argument which expects strings not
dependencies objects.
Klaus Jensen [Mon, 18 Oct 2021 21:00:10 +0000 (23:00 +0200)]
meson: use library() and rely on user settings
There is no need to have both _static and _shared targets. Just use
library(). Project using libnvme as a subproject can now just set
default_options: ['default_library=static']
in the subproject statement to choose the library version.
For pkgconfig, simplify and let the module figure out Libs and Requires.
This has the effect of removing Requires and making it a
Requires.private so we don't require libnvme consumers to link with
libuuid and json-c (unless they specifically needs to use it like
test/test.c).
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
Daniel Wagner [Mon, 18 Oct 2021 11:58:53 +0000 (13:58 +0200)]
build: Split libtool versioning from project versioning
As described in GNU autotools manuals, libtool versioning is not the
same as the project versioning.
The project versioning string is defined in project_version. meson
uses this string for all operations such a creating the tarball. I
decided against using something fancy as 'git describe' for it,
because meson is not supporting this kind of dynamic project
versioning.
Instead we just need to increment the version after the release and
before the first commit. With this scheme we basically know by looking
at the version string if it is an official released version. If this
is not good enough we can try to adopt the approach other project are
doing such as systemd which introduced an additional package
versioning which depends on 'git describe'.
There is little point in fighting the tool if it can be done quite
easily by the described approach from above.
Daniel Wagner [Mon, 18 Oct 2021 09:24:34 +0000 (11:24 +0200)]
build: Set minimum version for json-c
Set minimum version for json-c to 0.13.
libnvme uses json_util_get_last_err() which got introduced in 0.13,
released in December 2017.
While at it, drop the cc.find_library() lookup logic. First, we don't
do this for libuuid and second, dependency() is using pkg-config to
figure out the dependency, thus we can set the minimum version
number. Instead, cc.find_library() will try to link a test program
with '-libjson-c' and have no way to figure out which version it
actually is. Avoid any confusion and make the meson.build script
simpler.
Daniel Wagner [Tue, 12 Oct 2021 15:18:48 +0000 (17:18 +0200)]
build: Allow subproject meson builds
meson has a very fancy feature called subproject. This allows bundle
third party libraries in a project. In order to be able to use this
for nvme-cli we need to drop all global config settings and declare
all dependencies.
Daniel Wagner [Tue, 12 Oct 2021 12:26:57 +0000 (14:26 +0200)]
fabrics: Remove 'UUID derived from machine-id' feature
Commit 3e0520ecad13 ("Read system UUID from DMI and merge hostnqn
generation functions") in nvme-cli introduced the feature to create
the UUID derived from machine-id using the systemd's
sd_id128_get_machine_app_specific function. This adds many library
dependencies to libnvme.
The feature is not really necessary as we have nvme-gen-hostnqn
already in place. So drop the feature entirely.
If the feature needs to be added back, it's probably better to
reimplement this function (e.g. move the hmac_sha256 function from
nvme-cli and use this to derive the UUID from machine-id).