fabrics: re-read the discovery log page when a discovery controller reconnected
When using persistent discovery controllers, if the discovery controller
loses connectivity and manage to reconnect after a while, we need to
retrieve again the discovery log page in order to learn about possible
changes that may have occurred during this time as discovery log change
events were lost.
Upon reception of a udev EVENT=rediscover we can kickstart discovery on
the existing discovery controller device node that generated the event.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: James Smart <jsmart2021@gmail.com>
[dwagner: added --host_iface argument] Signed-off-by: Daniel Wagner <dwagner@suse.de
Jeremy Kerr [Mon, 26 Sep 2022 10:04:08 +0000 (18:04 +0800)]
nvme, plugins: fix __u64 -> unsigned long long assumptions
We have a couple of instances which assume __u64 is an unsigned long,
which is not always the case.
For the printf() formats, we would ideally used PRId64, but on ll64
platforms, it looks this macro is broken: it expands to "ld", where
__u64 is an unsigned long long. So, do an explicit cast to unsigned long
long instead, and just use %lld.
With this change, we can compile without warnings on amd64, armhf and
powerpc64le.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Sun, 25 Sep 2022 12:12:34 +0000 (20:12 +0800)]
utils: Fix uint128_t usage
Currently, nvme-cli will not compile on 32-bit platforms, as uint128_t
is not available.
This change, based on suggestions from Daniel Wagner <dwagner@suse.de>,
adds our own nvme_uint128_t type, which needs a custom to_string()
function.
In order to make the latter straightforward, we use four 32-bit words
for the internal representation of the 128-bit type. We then use 64-bit
arithmetic to avoid having to handle the carry-bit explicitly.
Also, add a small test case for the printing.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Martin Belanger [Tue, 13 Sep 2022 15:19:13 +0000 (11:19 -0400)]
udev: Add HOST_IFACE to udev rule
The HOST_IFACE only applies to TCP connections. When provided, it forces TCP
connections on a specific interface instead of letting the routing table
decide. Some users may prefer to force connections on specific interfaces
instead of configuring the routing table. This change makes sure that the
HOST_IFACE used to set up the persistent connection to the discovery
controller also gets applied to the I/O controller connections.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Fri, 23 Sep 2022 11:43:57 +0000 (13:43 +0200)]
plugins/wdc: Add type case for feature id
clang reports
../plugins/wdc/wdc-nvme.c:9000:36: warning: implicit conversion from enumeration type 'NVME_FEATURE_IDENTIFIERS' (aka 'enum _NVME_FEATURE_IDENTIFIERS') to different enumeration type 'enum nvme_features_id' [-Wenum-conversion]
deFeatureIdList[listIdx].featureId,
~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
Add type case to avoid the warning. Ideally, the plugin would not
introduce their own enum value.
Daniel Wagner [Wed, 14 Sep 2022 09:12:19 +0000 (11:12 +0200)]
doc: Update examples in nvme-list-subsys.txt
The examples show the output from nvme-cli 1.x. The address field
shows the attributes separated by spaces. The corresponding code in
libnvme doesn't do this. Instead the exact output from sysfs, e.g.
Daniel Wagner [Wed, 31 Aug 2022 07:41:54 +0000 (09:41 +0200)]
doc: Add 'how to contribute' section
Document how to contribute to the project. Highlight the fact, that
it expected that the PRs are also following the Linux community
contributions guidelines (clean series).
Jeremy Kerr [Wed, 24 Aug 2022 01:20:53 +0000 (09:20 +0800)]
tree: fail on non-negative return values from parse_and_open
Currently, we see a warning with specific compilers:
../nvme/nvme.c: In function 'ns_rescan':
../nvme/nvme.c:4389:19: warning: 'dev' may be used uninitialized in this function [-Wmaybe-uninitialized]
This is due to a theoretical failure path in parse_and_open(), where
argconfig_parse() returns a positive value - this would require the
global errno to be negative.
Even though the unintialised use of dev is only possible with negative
error (which shouldn't happen), we should still consider any non-zero
return value of parse_and_open a failure. This change fixes the
instances of:
err = parse_and_open(...);
if (err < 0)
changing to:
err = parse_and_open(...);
if (err)
... and also applies this to the single use of open_exclusive().
The positive return values from parse_and_open() were removed in 11542bbd; beforehand, parse_and_open() would return a fd.
Fixes: 11542bbd ("tree: Combine NVMe file descriptor into struct nvme_dev") Fixes: https://github.com/linux-nvme/nvme-cli/issues/1647 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeff Lien [Wed, 3 Aug 2022 13:34:04 +0000 (08:34 -0500)]
wdc: OCP Log page updates and fixes
Add support for Version 1 Error Recovery log page
Fix fw-activate-history timestamp json data
Update OCP log page capabiliites for SN550, SN650,
and SN655
Jeremy Kerr [Wed, 17 Aug 2022 05:08:58 +0000 (13:08 +0800)]
subprojects/libnvme: update for MI admin command coverage
In upcoming changes, we'll want to use the expanded Admin command
coverage for the MI transport. This change bumps to the merge commit
adding that support:
Daniel Wagner [Tue, 16 Aug 2022 06:12:24 +0000 (08:12 +0200)]
json: Support uint64 types serialization for older json-c versions
Notable json-c 0.13 is lacking support for serializing uint64_t
types. At this point of writing the 0.13 version is widely
deployed. Let's add our own version of the serialization function as
fallback.
Jeremy Kerr [Wed, 13 Jul 2022 06:56:59 +0000 (14:56 +0800)]
tree: Add NVMe-MI support
Now that we have a struct containing the NVMe device file descriptor, we
can abstract this to support different transport types.
This change adds support for NVMe-MI transports, by adding a `mi` member
to struct nvme_dev's union, and allowing devices to be specified by an
MCTP address:
mctp:<network>,<endpoint-id>:<controller-id>
- where the `controller-id` is optional, and defaults to 0 if not
specified.
For this, we need to add suitable linkage to the libnvme-mi component of
the libnvme codebase.
None of the actual commands can use the MI transport at present, as they
currently assume access to dev->direct.fd. We will add facilities for
that in upcoming changes.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 13 Jul 2022 05:19:24 +0000 (13:19 +0800)]
nvme: Introduce a union in struct nvme_dev for different transport types
This change modifies struct nvme_dev to allow for future transport
types, by moving the transport-specific data into a union. We will add
new types in a future change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Jul 2022 10:09:39 +0000 (18:09 +0800)]
nvme: Remove static nvme_dev, allocate on open instead
This change completes the transition to a all-local device data. Instead
of using the static nvme_dev, allocate a struct nvme_dev instead, and
free on dev_close()
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Jul 2022 09:20:25 +0000 (17:20 +0800)]
tree: Change nvme_dev from global to static
We're currently exposing the global struct nvme_dev, to allow the old
users access to the name and statbuf data. Now that users have their
local reference (along with the fd) through parse_and_open instead, we
can drop the public definition, and declare it static to nvme.c.
We still keep the static declaration; this will be removed in an
upcoming change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Jul 2022 09:14:09 +0000 (17:14 +0800)]
plugins/wdc: pass struct nvme_dev rather than using global nvme_dev
We have a couple of uses of the global nvme_dev variable, where we could
be passing a local instead. This change updates some of the wdc log
print functions to take a struct nvme_dev, rather than using the global.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Jul 2022 07:22:47 +0000 (15:22 +0800)]
plugins/wdc: pass a struct nvme_dev around rather than a fd
Currently, the wdc plugin (internally) passes the device fd around. This
change passes the struct nvme_dev instead, so we can access other
members in a future change.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Tue, 12 Jul 2022 06:55:34 +0000 (14:55 +0800)]
tree: Combine NVMe file descriptor into struct nvme_dev
Currently, our references to the nvme device are fragmented: we have the
device name and stat buf stored in the global nvme_dev, and then a
separate nvme device file descriptor passed between functions
This change moves the fd into the struct nvme_dev:
struct nvme_dev {
+ int fd;
struct stat stat;
const char *name;
};
and changes parse_and_open to now populate a pointer to the dev on
successful return. Callers can now access the fd through dev->fd,
unifying this with the name and statbuf.
[At the moment, this just uses the global nvme_dev variable, but we'll
make that neater in a future change]
There are a large number of functions that use the fd directly, hence
the size of this patch. I've attempted to make this as atomic as
possible, but there are some call sites which warrant some reformatting
as we go here.
There may be some future opportunities to pass around the struct
nvme_dev * rather than the fd, but this change just implements the
minimal change to group our nvme device into the one struct.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Francis Pravin Antony Michael Raj [Sun, 14 Aug 2022 02:30:08 +0000 (22:30 -0400)]
nvme: Add helper function to parse 16-bit comma separated list
In copy command, nlbs is declared as __u16. While parsing command line argument,
it is typecast to integer pointer. So nlbs[1], nlbs[3], nlbs[5], ... are stored
as zero after getting parsed. Therefore it is passing wrong value to controller.
Hence, adding a helper function to parse the 16-bit comma separated list
Signed-off-by: Francis Pravin Antony Michael Raj <francis.michael@solidigm.com> Signed-off-by: Jonathan Derrick <jonathan.derrick@solidigm.com>
Observing unwanted side-effects with nvme discovery. For e.g., running
a simple 'nvme discover' command ends up invoking connect-all as well,
creating namespaces on the host.
One can also see spurious discovery controllers in the 'nvme
list-subsys' output, despite having not created any persistent
discovery controllers at all.
Reported-by: Martin George <Martin.George@netapp.com> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Jeremy Kerr [Thu, 14 Jul 2022 07:01:22 +0000 (15:01 +0800)]
nvme: Simplify ns list identify
Rather than multiplexing over four functions (which all then call
nvme_identify) just use nvme_identify directly, and set the identify
parameters according to the 'csi' and 'all' parameters.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
[dwagner: changed how the struct args is initialized] Signed-off-by: Daniel Wagner <dwagner@suse.de>