Daniel Wagner [Mon, 18 Oct 2021 15:40:18 +0000 (17:40 +0200)]
build: Set minimum version for json-c and add fallback support
Set minimum version for json-c to 0.13.
nvme-cli uses json_util_get_last_err() which got introduced in 0.13,
released in December 2017.
Also, 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.
Olaf Schmerse [Mon, 18 Oct 2021 13:42:29 +0000 (15:42 +0200)]
nvme: fail on busy namespace
To avoid formarting a busy namespace accidently a new function called
open_exclusive() is implemented. Instead of opening it always it opens
the device file in exclusive mode (O_EXCL). If this fails with the error EBUSY an error
messages hints to the --force command line option. By calling nvme format with the --force option it
will continue formating the namespace.
This patch fixes issue: #1095 Signed-off-by: Olaf Schmerse <olaf.schmerse@ionos.com>
nvme-rpmb: Add limits.h due to missing PATH_MAX definition
Commit 21f40f38b introduced new use of PATH_MAX, but did not add the
limits.h header. This resulted in nvme-cli failing to build on
ppc64le systems using the musl C library.
Daniel Wagner [Mon, 11 Oct 2021 16:59:22 +0000 (18:59 +0200)]
build: Add support for meson build system
Add meson build system. I tried to mimic the existing Makefile style
but there are a couple of noteworthy differentiation.
- meson has the concept of subprojects. It is able to download (via
git) the dependencies (libnvme) and add them directly into the
build system unless the library is found on the host machine
(PKG_CONFIG_PATH needs to point to libnvme). This makes git
submodules unnecessary. The nice thing is that we get a very simple
setup for CI. meson knows how to download and the dependencies into
the build.
To make all this work the git submodule needs to be removed when we
start using meson to build the project. 'meson dist' bundles
libnvme into the final tar. We could obviously remove it again via
add_dist_script but this seems not worth the time.
- meson uses project_version() to set the version string. This is
usually just a string (or read from a file). I added the script
hack so that we keep the versioning consistent with the Makefile,
e.g. that tar file has the 'git describe' version and 'nvme
--version' says the same. For a new release, the script
'nvme-cli-version' needs to be updated (like NVME-VERSION_GEN) and
the release needs to be tagged before one runs 'meson dist'. I
guess in the long run we could just set the project_version string
in meson.build and introduce a package_version which is based on
git. This is how systemd handles this.
- The github workflow disables the unit tests for nvme-cli (but not
for libnvme) by not installing nose2. Those tests fail at the
moment.
There are still many things very rough or missing, e.g. the install
targets. But this seems like a good first version to get things going.
Daniel Wagner [Thu, 7 Oct 2021 07:06:28 +0000 (09:06 +0200)]
nvme-print: Use array array instead of ccan/list
Commit 155fbebfe7b7 ("Update effects-log to handle multiple command
sets") added a dependency to libvnme/ccan which conflicts with making
the libnvme shared library.
We can simply replace the list by an fixed sized array as we know we
either have 1 or 2 elements in the list.
Andreas Hindborg [Thu, 9 Sep 2021 07:27:25 +0000 (07:27 +0000)]
Update effects-log to handle multiple command sets
This patch updates the effects-log command to correctly handle multiple
supported command sets. As each command set is allowed to support a distinct
subset of commands, the log page must to be reported for each command set.
Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
fabrics: restore discover_from_conf_file to actually work
With all the rework, discover_from_conf_file was completely
broken. Have both discover and connect-all working with
params passed from /etc/nvme/discovery.conf
Daniel Wagner [Mon, 27 Sep 2021 14:07:41 +0000 (16:07 +0200)]
Makefile: Add support to build against shared libnvme library
Support building nvme-cli using a shared version of libvnme. The
Makefile checks first if libnvme has been checked out as git submodule
in under libvnme and uses this as first preference. If this fails
pkg-config is used to determine if a shared libnvme exists.
Daniel Wagner [Mon, 27 Sep 2021 13:58:08 +0000 (15:58 +0200)]
Makefile: Fix pattern rules
The pattern rules can't have additional dependency as input. make skips
the rule and falls back to use the build in rule, which accidentally
works.. Drop the non-functional dependency list.
Francisco Munoz [Thu, 23 Sep 2021 00:10:23 +0000 (17:10 -0700)]
Optane clears latency stats evey time the log page is pulled.
We only perfom a single query and place the result in a byte
array. Then, we determine the right log page layout in terms of
the media version.
Signed-off-by: Francisco Munoz <francisco.munoz.ruiz@intel.com>
chengjike [Mon, 23 Aug 2021 12:40:47 +0000 (20:40 +0800)]
fix list command bugs
When execute the "nvme list" command in a multipath environment, it generate a core dump. Such as:
[root@localhost ~]# nvme list
Node SN Model Namespace Usage Format FW Rev
--------------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
Segmentation fault (core dumped)
[root@localhost ~]#
The reason is that when a device is a multipath disk, the value of "nvme_ns_t->c" is NULL.
This also happens when you execute "nvme list -o json" and "nvme list -v -o json" commands.
Signed-off-by: chengjike <chengjike.cheng@huawei.com> Signed-off-by: Keith Busch <kbusch@kernel.org>
Hannes Reinecke [Thu, 12 Aug 2021 08:19:53 +0000 (10:19 +0200)]
fabrics: skip '/dev/' prefix for persistent discovery controllers
When calling 'nvme discover --device' one has to remember to strip the
'/dev/' prefix from the nvme controller device name, which is
quite cumbersome and pointless, as we might as well do it internally.
So be a bit more lenient and accept full device node names on discover.
Hannes Reinecke [Thu, 12 Aug 2021 08:19:53 +0000 (10:19 +0200)]
fabrics: skip '/dev/' prefix on disconnect
When calling 'nvme disconnect -d' one has to remember to strip the
'/dev/' prefix from the nvme controller device name, which is
quite cumbersome and pointless, as we might as well do it internally.
So be a bit more lenient and accept full device node names on disconnect.
Hannes Reinecke [Thu, 12 Aug 2021 06:28:12 +0000 (08:28 +0200)]
fabrics: rework nvmf_discover()
The logic to check for matching controller devices was backwards,
and resulted in stale discovery controllers upon failure.
So rework the logic to first scan the controller device (if present),
and then check if it matches the command line options.
And with that we can rework the entire logic to be easier to follow.
Hannes Reinecke [Thu, 12 Aug 2021 07:03:57 +0000 (09:03 +0200)]
util/argconfig: fixup OPT_INCR
To implement OPT_INCR we cannot simply increase the value in
'value_addr', as getopt() will load the value in 'val' into this
location upon every call to getopt().
As such we need to increase the 'val' setting for getopt() to
get the correct behaviour.
Hannes Reinecke [Wed, 11 Aug 2021 08:38:43 +0000 (10:38 +0200)]
github-workflow: do not build for PPC
For some reason the library is build for PowerPC in addition to the
standard target, but that will make the CI unhappy as libnvme will
build and execute the 'configurator' program during building.
Which clearly will fail, as libnvme doesn't distinguish between
a host and target compiler.
So kill this step as it's of doubtful value anyway.
Hannes Reinecke [Wed, 11 Aug 2021 07:50:15 +0000 (09:50 +0200)]
nvme: use libnvme for printing status
With commit fe62ba7 ("util: Add nvme_status_to_string()") libnvme
now has a 'nvme_status_to_string()' function, which clashes with
the one provided here.
So drop the function in favour of the libnvme one, and convert
all plugins to use nvme_show_status().