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.
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().
Martin George [Sat, 5 Jun 2021 09:46:26 +0000 (15:16 +0530)]
fabrics: skip connect if transport type doesn't match
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:
Gollu Appalanaidu [Fri, 28 May 2021 13:52:45 +0000 (19:22 +0530)]
nvme: add zone desc changed notice async event
Add the Zone Descriptor Changed Notices in get feature
human readble output for the Async Event config feature
(FID = 0x0B) as per the TP4053 Zoned Namespaces
Daniel Wagner [Wed, 2 Jun 2021 13:42:42 +0000 (15:42 +0200)]
nvme-topology: no error message when openeing of controller fails
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.
Keith Busch [Tue, 1 Jun 2021 14:01:44 +0000 (07:01 -0700)]
default flush to use block device nsid
Kernel 5.13 added checks to ensure the ioctl path can't be abused to
access a different namespace than the one user space has permission to
open. This unfortunately breaks the all-nsid flush usage, so user
tooling needs to default to the device's namespace id.
Sagi Grimberg [Mon, 17 May 2021 18:26:16 +0000 (11:26 -0700)]
fabrics: add fast_io_fail_tmo option
Option to fail fast I/O when connecting to a controller. It is useful
to set a fast-fail timeout for nvme in case upper layer SW wants to
detect unresponsive controllers early (e.g. mdraid).
Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <kbusch@kernel.org>
Sagi Grimberg [Wed, 26 May 2021 07:25:15 +0000 (00:25 -0700)]
systemd/nvmf-autoconnect.service: load nvme-fabrics before autoconnect
Upon boot nvme-fabrics needs to be loaded, so make sure to load
it before executing ExecStart. The driver will know to request
the transport module according to the transport parameter.