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>
Jeremy Kerr [Tue, 12 Jul 2022 06:45:29 +0000 (14:45 +0800)]
plugins/solidigm: fix return value on format parse failure
If validate_output_format() fails, there are a couple of paths in the
solidgm code that will return a (closed) file descriptor, rather than an
error status. This looks to be a couple of copy-and-paste errors.
This change fixes the return value for these failure path, ensuring that
we'll actually have an error return.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Daniel Wagner [Mon, 1 Aug 2022 11:52:31 +0000 (13:52 +0200)]
fabrics: Remove dhchap-ctrl-secret from discover/connect-all
The dhchap-ctrl-secret is per controller but discover and connect-all
operate on several controllers.
As this get's very fast complicated how to express this on the command
line, just drop the it. It was not implemented anyway and not listed
in the documentation.
Daniel Wagner [Fri, 22 Jul 2022 12:12:00 +0000 (14:12 +0200)]
nvme: Set default rae value for nvme_get_nsid_log users
libnvme 1.0 hard codes the rae value for all nvme_get_nsid_log to
false. The upcoming 1.1 release will pass the rae value through
to the kernel. This is causing a behavior change. To be on the safe
side set all rae=true to false.
At least for nvme_get_log_error and nvme_get_log_smart this seems also
what the spec recommends.
Reported-by: Jeremy Kerr <jk@codeconstruct.com.au> Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Tue, 19 Jul 2022 09:53:12 +0000 (11:53 +0200)]
fabrics: Avoid nvme_scan_ctrl when disconnecting
In certain corner cases, the kernel will not populate a nvme subsystem
but only create a nvme controller. nvme_scan_ctrl will fail in such
scenarios to find the controller object. Let's do the lookup based on
the ctrl name only.
Daniel Wagner [Mon, 18 Jul 2022 14:08:38 +0000 (16:08 +0200)]
build: Update release version rules
Include the release candidate version string into the project
version. This allows to upload every release candidate to PyPI instead
just the final release.
Martin George [Tue, 12 Jul 2022 08:31:08 +0000 (14:01 +0530)]
nvme: fix nvme get-feature with -H option
Currently, nvme get-feature with the -H option fails to print detailed
info for specific feature ids such as number of IO queues (fid=0x07),
async event config (fid=0x0b), KATO value (fid=0x0f), etc. This is
because nvme_feature_show_fields() is invoked only if the corresponding
'buf' pointer is valid, which is not necessary for the above feature
ids. So fix this by removing this restriction while invoking
nvme_feature_show_fields(). At the same time, ensure this 'buf' pointer
is appropriately validated before use in this function.
Fixes: bcab212 ("nvme: coverity fixes") Signed-off-by: Martin George <marting@netapp.com>
Jeremy Kerr [Tue, 12 Jul 2022 07:27:55 +0000 (15:27 +0800)]
plugins/wdc: prevent double close in wdc_do_cap_telemetry_log
Currently, wdc_do_cap_telemetry_log will close the NVMe fd before
returning, but so it all of its call sites. Since we'd be better off
making the fd open/close symmetrical, drop the close from
wdc_do_cap_telemetry_log.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Daniel Wagner [Fri, 8 Jul 2022 10:18:03 +0000 (12:18 +0200)]
nvme: Use correct json serializing for long doubles
Fixup all places which use json_object_add_value_float() to serialize
long double types with json_object_add_value_double(). The float
version cuts off the upper 64 bits of the 128 bit long double type.