Martin Wilck [Tue, 12 Jan 2021 18:50:05 +0000 (19:50 +0100)]
nvme-cli: add generic logging functionality
Add a msg() macro that allows more flexible customization of logging
both at build time and at run time. Allow several log levels, using
the well-known standard sylog levels. Also optionally allow printing
of log timestamps.
Put '#define LOG_FUNCNAME' before '#include "util/log.h"' to enable printing
the name of the calling function before the log message.
Use this functionality in the fabrics code for now, wherever fprintf(stderr, ...)
had been used.
No functional change except changing the output channel of 554db7d ("print
device name when creating a persistent device") from stdout to stderr.
Martin Wilck [Thu, 4 Mar 2021 17:16:03 +0000 (18:16 +0100)]
nvme: add some simplifying macros for __attribute__((cleanup()))
Using __attribute__((cleanup())) is very helpful for writing leak-free
code, but it requires lots of awkward boiler plate code. Add some
small helpers to make its use more comfortable.
Martin Wilck [Fri, 5 Mar 2021 20:19:10 +0000 (21:19 +0100)]
do_discover: free cfg.device when resetting it
cfg.device might have been allocated by a previous call to
find_ctrl_with_connectargs(), therefore free it. We must make sure
that cfg.device is always on the heap, thus change fabrics_discover()
accordingly.
If persistent controller connections are present they should be
preferred even if no --device option is given on the commandline.
To avoid selecting a temporary non-persistent controller the
'kato' attribute is checked; any controller for which the
attribute is '0' will be skipped. This logic is not applied on
older kernels that don't support the 'kato' attribute. On these
kernels, we just have to assume that the encountered discovery
controller is persistent.
Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin Wilck <mwilck@suse.de>
Hannes Reinecke [Wed, 24 Mar 2021 06:39:31 +0000 (07:39 +0100)]
fabrics: fix infinite loop on invalid parameters
When parsing the discovery entries results in invalid parameters
for a given connection we'll enter an infinite loop as the -EINVAL
error code is always assumed to indicate a wrong 'disable_sqflow'
setting.
Sagi Grimberg [Mon, 15 Mar 2021 20:52:09 +0000 (13:52 -0700)]
nvme-topology: have list-subsys print only controllers with attached namespace
When running list-subsys on a specific namespace, we output all the
controllers that belong to the subsystem regardless if the requested
namespace is actually attached to them.
Example:
$ nvme list-subsys /dev/nvme0n1
nvme-subsys0 - NQN=nqn.2016-01.com.lightbitslabs:uuid:07cfffe6-5a4f-4151-b663-e13cf835609b
\
+- nvme0 tcp traddr=10.113.5.1 trsvcid=4420 live optimized
+- nvme1 tcp traddr=10.133.3.1 trsvcid=4420 live
+- nvme2 tcp traddr=10.133.1.1 trsvcid=4420 live
+- nvme3 tcp traddr=10.113.1.1 trsvcid=4420 live inaccessible
+- nvme4 tcp traddr=10.133.5.1 trsvcid=4420 live
+- nvme5 tcp traddr=10.113.4.1 trsvcid=4420 live
+- nvme6 tcp traddr=10.133.4.1 trsvcid=4420 live
+- nvme7 tcp traddr=10.113.2.1 trsvcid=4420 live
+- nvme8 tcp traddr=10.133.2.1 trsvcid=4420 live
+- nvme9 tcp traddr=10.113.3.1 trsvcid=4420 live
This output is somewhat confusing and makes the user think the namespace
is actually attached to all of these controllers, instead we want the
output which provided by the change introduced here:
Do the same trick as we do in scan_subsystems, we add the ctrl to the
topology if either ns_instance wasn't passed (see all controllers) or
it was pased _and_ the controller has this namespace is attached to
the controller (to do that we add nsid down the call chain for that).
Gollu Appalanaidu [Sun, 14 Mar 2021 17:57:47 +0000 (23:27 +0530)]
nvme: address 1.4 to 1.4b changes for Change NS event type
In NVMe 1.4 spec. Change Namespace Event Type (06h) of persistent
event log Data Format - NCAP field was assigned with 16 bytes. Now
in 1.4b spec. its modified to 8 bytes.
Gollu Appalanaidu [Sun, 7 Mar 2021 18:32:35 +0000 (00:02 +0530)]
nvme-print: improve command support and effects log json format
Currently command support and effects log page on json format
printing all the opcodes irrespective of the command supported.
Most part of the log page is "Unkown" opcodes, fixed that. Also
added two json objects "acs" and "iocs" to print them seperately.
Martin George [Wed, 3 Mar 2021 06:19:19 +0000 (11:49 +0530)]
fabrics: ensure zero kato for non-persistent controllers
Add a helper function that sets the default kato value for the
discovery controllers. Along with ensuring a non-zero kato value
(i.e. NVMF_DEF_DISC_TMO) is passed to a persistent discovery
controller, it also ensures a zero kato value is passed to a
non-persistent discovery controller, as mandated by the NVMe spec.
Gollu Appalanaidu [Mon, 1 Mar 2021 18:37:07 +0000 (00:07 +0530)]
nvme-print: fix HMB get feature response in human readable format
For Host Memory Buffer(HMB) fearure as part of get feature Memory
Return(MR) bit is not part of the CQE CDW0 and add endianess conversion
for the get feature HMB attribute data structure.
Gollu Appalanaidu [Sat, 27 Feb 2021 19:40:01 +0000 (01:10 +0530)]
nvme: fix securuty send and receive commands result field
Security Send and Receive commands doesn't fill the CQE CDW0,
remove uncessary passing of result field in both the commands.
The changes are made in RPMB related files since it is dependent
on these commands. RPMB operations only result field as part of
the dataframe and this result is completely different from the
CQE CDW0.
Hannes Reinecke [Thu, 25 Feb 2021 15:53:00 +0000 (16:53 +0100)]
fabrics: correctly handle ctrl_loss_tmo settings for loop
The previous fix had an issue with referrals, as it would take
the default values and apply them to all referral entries.
And if the default entries were for 'loop', the default ctrl_loss_tmo
setting would not be used, but rather '-1'.
So this patch reverts the previous patch and correctly blanks
out the ctrl_loss_tmo setting when constructing the connect string.
Fixes: bdf4f3b ("fabrics: ctrl_loss_tmo setting is invalid for 'loop'") Signed-off-by: Hannes Reinecke <hare@suse.de>
The changes as per the Base NVMe 1.4b and NVMeOF 1.1 specification.
Optional Fabrics Command Support(OFCS) field added at wrong offset
of the structure, and other naming conventions fixed as per the Spec.
Gollu Appalanaidu [Tue, 23 Feb 2021 18:58:45 +0000 (00:28 +0530)]
nvme: add support for lba status log page
This log page is used to provide information about
subsequent actions the host may take to discover which
logical blocks, in namespaces that are attached to
the controller, may no longer be recoverable when read.
For more details see NVM Express 1.4 Spec. Section
5.14.1.14("LBA Status Information (Log Identifier 0Eh)")
Gollu Appalanaidu [Sat, 20 Feb 2021 16:30:09 +0000 (22:00 +0530)]
nvme: add support for endurance group event aggregate log
This log page indicates if an Endurance Group Event has
occurred for a particular Endurance Group, the details of
the particular event are included in the Endurance Group
Information log page for that Group. For details see
NVM Express 1.4 Spec. Section 5.14.1.15 ("Endurance Group
Event Aggregate (Log Identifier 0Fh)")
Hannes Reinecke [Wed, 17 Feb 2021 16:42:43 +0000 (17:42 +0100)]
fabrics: ctrl_loss_tmo setting is invalid for 'loop'
The 'ctrl_loss_tmo' setting is invalid for 'loop' devices, so move
the default to '-1' (for 'unset'), and only set the default timeout
if discovery is not done on a loop device and the user has not
specified another value.
Fixes: 68bc869 ("fabrics: fix passing ctrl_loss_tmo=0 by default") Signed-off-by: Hannes Reinecke <hare@suse.de>
Gollu Appalanaidu [Sun, 7 Feb 2021 11:30:09 +0000 (17:00 +0530)]
nvme: Round of the metadata size to fit into block count
If device formatted with non-zero metadata size and input
metadata size is less than that it can be fit into mentioned
block count from input then round it of to fit into block count.
Minwoo Im [Fri, 22 Jan 2021 15:20:38 +0000 (00:20 +0900)]
nvme-status: return negative status if !errno
'errno' is set to errno value when system calls are returning with an
error (e.g., ioctl). But, If a command fails without any system call,
then it needs to return the raw negative error value.
For example, if we don't provide any options for connect command:
root@vm:~# nvme connect
need a transport (-t) argument
root@vm:~# echo $?
0
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Minwoo Im [Thu, 14 Jan 2021 13:52:52 +0000 (22:52 +0900)]
zns: print select_all field for Zone Management Send
If Select All field in CDW13 is set to 1, SLBA(Starting LBA) will be
ignored. This patch added a select all field to print out when
successfully done. More informative success log with this field.
Minwoo Im [Sat, 23 Jan 2021 07:21:46 +0000 (16:21 +0900)]
nvme-topology: fix returning invalid value in scan_subsystems()
Let's say we have multiple three subsystems in the system. If we run
a simple 'nvme list' command, then scan_subsystems() will never set the
'ret' value which is a local variable. This should be initialized to a
initial value to avoid invalid value returning.
This patch fixes returning invalid value from the scan_subsystems() in
case of multi-subsystems found.
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Jeff Lien [Tue, 19 Jan 2021 14:31:21 +0000 (08:31 -0600)]
[nvme-cli] WDC plugin fixes for vs-fw-activate-history command
Change to use Power on Hours instead of Timestamp in certain cases
Fix Entry order so entries are displayed oldest to newest
Tomasz Zawadzki [Tue, 14 Jul 2020 08:18:46 +0000 (04:18 -0400)]
skip display of missing controller fields
'Transport' and 'address' fields are determined from sysfs
in legacy_get_pci_bdf(). Meanwhile 'state' field is only set
in scan_ctrl(), rather than legacy_list() path.
This patch fixes display of the fields to be empty.
Then resolves assumption that transport is set,
preventing a segfault.
Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>