Sagi Grimberg [Thu, 1 Aug 2019 23:13:47 +0000 (16:13 -0700)]
nvme-cli: add --quiet option
Now we are going to have discovery log change events, so
instead of trying to figure out which NVM subsystem ports
are already connected, we let the driver do that and
only suppress the failure messages.
Example:
nvme connect-all ... --quiet
This option will be used by the discovery log change corresponding
udev rule.
Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
James Smart [Thu, 1 Aug 2019 23:13:46 +0000 (16:13 -0700)]
nvme-cli: Expand --device argument processing
The connect-all --device argument was used to specify a specific device
to be used as the discovery controller. The device is typically a
long-lived discovery controller that posted a discovery event.
No attempt was made to ensure the device is who it is supposed to be
before using it.
Revised the code to use the other arguments in the connect-all request
to validate that the device is the entity that was expected. If the
device doesn't match, the cli will look for an existing matching device
in the system (should be a discovery controller due to nqn) with the
same connect parameters and use it. If one is not found on the system,
a new discovery controller will be created for the connect-all request.
The revision uses new routines to parse the connect arguments given
in the argstr parameter. As a couple of new fieldnames are needed, the
parse routine constants were expanded for them.
The revision uses the new routines to match the specified device vs
it's attributes as well as the search routine that looks for a device
with the connect arguments.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
James Smart [Thu, 1 Aug 2019 23:13:45 +0000 (16:13 -0700)]
nvme-cli: Add routine to search for controller with specific attributes
In preparation for searching controllers to match with connect args:
Create a new routine find_ctrl_with_connectargs() that will search the
controllers that exist in the system to find one that has attributes
that match the connect arguments specified. If found, the routine
returns the controller name ("nvme?"). If not found, a NULL is returned.
Routine is defined as a global as a subsequent patch will use it
from the fabrics routines.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.com>
James Smart [Thu, 1 Aug 2019 23:13:44 +0000 (16:13 -0700)]
nvme-cli: Add routine to compare ctrl_list_item to connect args
In preparation for searching controllers to match with connect args:
Create a new routine that receives a structure containing connect
arguments and a device name. The routine will build and fill in a
ctrl_list_item for the device and compare its attributes with the
connect arguments. The routine returns true/false on whether they
match.
Routine is defined as a global as a subsequent patch will use it
from the fabrics routines.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
James Smart [Thu, 1 Aug 2019 23:13:43 +0000 (16:13 -0700)]
nvme-cli: extend ctrl_list_item for connect attributes
In preparation for searching controllers to match with connect args:
Extend the ctrl_list_item with elements that can be compared against
connect arguments. Extend the get_nvme_ctrl_info() routine to set
the fields.
subsysnqn was added as the ctrl_list_item may now be used outside of
a subsystem listing.
traddr, trsvid, and host_traddr are added. Their values come from
the address attribute. A new parsing routine was added that extracts
the values from the address string.
The new parsing routine and supporting field names strings are
declared as a global interface as a subsequent patch will call it
from the fabrics routines.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: Hannes Reinecke <hare@suse.com>
James Smart [Thu, 1 Aug 2019 23:13:42 +0000 (16:13 -0700)]
nvme-cli: Refactor to create a get_nvme_ctrl_info routine
In preparation for searching controllers to match with connect args:
Refactor the get_nvme_subsystem_info() routine to take the portion
that creates a ctrl_list_item and sets its values and put it in a
separate get_nvme_ctrl_info() routine.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
James Smart [Thu, 1 Aug 2019 23:13:41 +0000 (16:13 -0700)]
nvme-cli: allow discover to address discovery controller by persistent name
To support discovery (connect/connect-all) to operate against a
persistent discovery controller, let the discovery controller to
be specified by its device node name rather than new connection
attributes.
Example:
nvme connect-all ... --device=nvme5
Also centralize extraction of controller instance from the controller
name to a common helper.
Signed-off-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Sagi Grimberg [Thu, 1 Aug 2019 23:13:40 +0000 (16:13 -0700)]
nvme-cli: support persistent connections to a discovery controller
Simply don't destroy the discovery controller after getting the
log pages. Note that persistent connection to a discovery subsystem
require to pass in a non-zero kato value, so if not provided we
simply use a default of 30 seconds kato.
Example:
nvme connect-all ... --persistent
Signed-off-by: Sagi Grimberg <sagi@grimberg.me> Reviewed-by: James Smart <jsmart2021@gmail.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Reviewed-by: Max Gurtovoy <maxg@mellanox.com> Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
James Smart [Thu, 1 Aug 2019 23:13:39 +0000 (16:13 -0700)]
nvme-cli: ignore arguments that pass in "none"
As we want to support discovery uevents over different
transports, we want to allow the kernel to provide missing
information in the form of none and have nvme-cli properly
ignore it.
One example is the host_traddr. If it is not set (which means
that the default route determined the host address) we will
want to do the same for newly discovered controllers.
nvme-print: show new CMBLOC bit fields added in NVMe 1.4
* Bit 8 - CMB Queue Dword Alignment (CQDA)
* Bit 7 - CMB Data Metadata Mixed Memory Support (CDMMMS)
* Bit 6 - CMB Data Pointer and Command Independent Locations Support (CDPCILS)
* Bit 5 - CMB Data Pointer Mixed Locations Support (CDPMLS)
* Bit 4 - CMB Queue Physically Discontiguous Support (CQPDS)
* Bit 3 - CMB Queue Mixed Memory Support (CQMMS)
Reviewed-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
Kenneth Heitke [Wed, 29 May 2019 22:29:49 +0000 (16:29 -0600)]
nvme: sanitize enhancements
Added display of new SANICAP fields of the Identify Controller data structure
* No-Deallocate Inhibited
* No-Deallocate Modifies Media After Sanitize
Updated Sanitize Status Log Page to include new fields
* Sanitize Status (SSTAT) field value (100b - completed successfully with deallocation)
* Estimated Time For Overwrite With No-Deallocate Media Modification (bytes 23:20)
* Estimated Time For Block Erase With No-Deallocate Media Modification (bytes 27:24)
* Estimated Time For Crypto Erase With No-Deallocate Media Modification (bytes 31:28)
Added Get/Set Feature - Sanitize Configuration
Reviewed-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
Hannes Reinecke [Thu, 1 Aug 2019 08:47:41 +0000 (10:47 +0200)]
nvme-cli: mask out invalid options during discovery
When compiling the option string in build_options() we should ensure
to not add invalid options when doing a discovery. So add an additional
option 'discovery' to build_options() to identify these cases.
Kenneth Heitke [Thu, 27 Jun 2019 19:01:07 +0000 (13:01 -0600)]
nvme: Enhanced Command Retry
* Show CRDT fields of Identify Controller data structure
* Show Host Behavior Supported state for Get Feature 16h
* Add support for error status NVME_SC_CMD_INTERRUPTED
Reviewed-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
Minwoo Im [Tue, 23 Jul 2019 17:30:57 +0000 (02:30 +0900)]
lnvm: introduce alias geometry for id-ns for lnvm
Now we have 2.0 OCSSD spec which introudces Geometry command instead of
Identity or something else. This patch just adds an alias for this
command for the given NVMe namespace with backward compatibility.
Cc: Keith Busch <kbusch@kernel.org> Cc: Matias Bjorling <mb@lightnvm.io> Cc: Javier González <javier@javigon.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Signed-off-by: Matias Bjørling <mb@lightnvm.io>
Minwoo Im [Tue, 23 Jul 2019 17:26:04 +0000 (02:26 +0900)]
lnvm: introduce chunk-log command for chunk info
To retrieve the chunk information from the nvme namespae for the given
OCSSD, we can just do like:
nvme lnvm chunk-log /dev/nvme0n1 --output-format=normal
This will calculate the data length from the geometry data structure
which might be retrieved by a Geometry command(Identity for 1.2 spec.).
Then it will request get log page API for 1.3 NVMe spec to get the
entries which indicate chunk information.
Cc: Keith Busch <kbusch@kernel.org> Cc: Matias Bjorling <mb@lightnvm.io> Cc: Javier González <javier@javigon.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Minwoo Im [Sat, 20 Jul 2019 08:50:54 +0000 (17:50 +0900)]
lnvm: cast identity structure to (void *) directly
If we use "tmp" or something like this, we can expect that it just
stores the previous pointer and do something else with the previous
pointer. But, in this function, it just to cast it out.
Cc: Keith Busch <kbusch@kernel.org> Cc: Matias Bjorling <mb@lightnvm.io> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Javier González <javier@javigon.com>
Kenneth Heitke [Thu, 27 Jun 2019 16:56:03 +0000 (10:56 -0600)]
nvme-print: Show value for Transport SGL Data Block Descriptor support
The Transport SGL Data Block Descriptor is a new SGL Descriptor Type added in
NVMe 1.4. Support for this descriptor type is added to the SGL Support (SGLS)
field of the Identify Controller data structure.
Bart Van Assche [Mon, 24 Jun 2019 15:47:27 +0000 (08:47 -0700)]
nvme-cli: Fix more endianness issues
Declare little endian variables as __le*. Use the proper le*_to_cpu()
conversion functions for little endian integers. Do not use le*_to_cpu()
for variables of type uint8_t.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Mon, 24 Jun 2019 13:55:21 +0000 (06:55 -0700)]
nvme-cli: Restore RHEL 7 compatibility
With glibc version 2.24 and before the endianness conversion macros
return a value with an incorrect type. Avoid that this causes the
nvme-cli build to fail on e.g. RHEL 7. A side effect of this patch
is that it allows sparse to verify the type of the endianness
conversion functions.
See also https://sourceware.org/bugzilla/show_bug.cgi?id=16458
Bart Van Assche [Mon, 24 Jun 2019 17:41:37 +0000 (10:41 -0700)]
nvme-cli: Restore support for older gcc versions
Older versions of gcc do not support initializing another than the first
member of a union in an initializer. Rewrite some code such that support
for older gcc versions is restored.
Fixes: 301e263c34e8 ("nvme-cli: Rework the code for getting and setting NVMf properties") Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Minwoo Im [Thu, 23 May 2019 14:33:48 +0000 (23:33 +0900)]
fabrics: Return errno mapped for fabrics error status
If discover has been failed due to a nvme status, it will be returned to
main() with mapped value for fabrics get log page command.
Now connect command related status cannot be added in this patch because
kernel is not currently returning the nvme status, it's instead
returning -EIO if fails. errno for connect command can be added once
kernel is ready to return the proper value for nvme status.
Minwoo Im [Tue, 18 Jun 2019 12:53:38 +0000 (21:53 +0900)]
fabrics: return error when discovery retry exhausted
If the discovery page is not updated to the latest one over the 10
times, it's currently returning DISC_OK if the numrec has no problem.
If so, the caller might think that the discovery has been successfully
done without any errors even there is.
This patch makes it return an error -EAGAIN if retry(10 times) has been
exhausted.
Minwoo Im [Thu, 23 May 2019 14:28:11 +0000 (23:28 +0900)]
nvme: Return errno mapped for nvme error status
If ioctl module has returned a nvme error status, it will be returned
by being converted to a mapped errno value which has been provided by
previous commits.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.Kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Tue, 21 May 2019 16:36:57 +0000 (01:36 +0900)]
nvme-status: Introduce nvme status module to map errno
Background:
It's not enough to return the nvme status value in main() because it's
allowed to be in 8bits, but nvme status is indicated in 16bits. So we
has not been able to figure out what kind of nvme status has been
returned by return value.
This patch introduces nvme-status module that manages mapping between
nvme status and errno. It's not possible to make 1:1 mapping relations,
but we can map it as a groups.
All the internal errors which has been returned in a negative value will
be returned with ECOMM that indicates communication errors. In this
case, we can see what happened via stderr.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.Kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Thu, 23 May 2019 14:09:09 +0000 (23:09 +0900)]
nvme: Return negative error value for internal errors
To support the mapping of error values which will be introduced in the
next patches, All the internal errors caused in the middle of the
subcommands preparation or teardown should be returned as a negative
value to make it distinguished from nvme error status which is positive.
This patch makes all the internal error values which used to be returned
as a positive value to be returned as a negative value.
Cc: Keith Busch <kbusch@kernel.org> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Minwoo Im [Thu, 23 May 2019 14:16:54 +0000 (23:16 +0900)]
fabrics: Do not return in the middle of the subcommand
This patch also makes fabrics module to not return the internal error
status in the middle of the subcommands to support uniformed mapped
error value which will be introduced in the next patches.
Minwoo Im [Thu, 23 May 2019 14:02:48 +0000 (23:02 +0900)]
nvme: Do not return in the middle of the subcommand
To make nvme-cli subcommand return a mapped errno value to main(), it
should return the error status in a single place because it would be
great if the return statements and free operations are in an one shot
place.
This patch makes all the subcommands in nvme module return the error
which means internal error which should be in negative and nvme error
status which is in positive at the end of the subcommand.
Most of the changed parts are file descriptors which is returned from
parse_and_open() function. The "fd" could be in a negative value so
that it needs to be mapped to a uniformed errno value which will be
applied by the next patches.
Cc: Keith Busch <kbusch@kernel.org> Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com> Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com> Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Bart Van Assche [Tue, 18 Jun 2019 16:13:52 +0000 (09:13 -0700)]
nvme-cli: Report the NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields
From the NVMe 1.4 paragraph about NSFEAT:
"Bit 4 if set to 1: indicates that the fields NPWG, NPWA, NPDG, NPDA, and
NOWS are defined for this namespace and should be used by the host for I/O
optimization; and NOWS defined for this namespace shall adhere to Optimal
Write Size field setting defined in NVM Sets Attributes Entry (refer to
Figure 251) for the NVM Set with which this namespace is associated."
Hence only report these fields if bit 4 in NSFEAT has been set.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Tue, 18 Jun 2019 16:07:27 +0000 (09:07 -0700)]
Introduce NVMe 1.4 Identify Namespace fields in struct nvme_id_ns
Several new fields have been introduced in version 1.4 of the NVMe spec
at offsets that were defined as reserved in version 1.3d of the NVMe
spec. Update the definition of the nvme_id_ns data structure such that
it is in sync with version 1.4 of the NVMe spec. This change preserves
backwards compatibility.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 17:09:54 +0000 (10:09 -0700)]
nvme-cli: Skip properties that are not supported
Instead of causing the show-regs command to fail if a property is
encountered that is not supported by the target side, do not display
the property. With this patch applied the following output is displayed
for the Linux NVMf target:
$ nvme show-regs /dev/nvme0
cap : f0003ff
version : 10300
cc : 460001
csts : 1
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 15:07:50 +0000 (08:07 -0700)]
nvme-cli: Rework the code for getting and setting NVMf properties
The current nvme_property() implementation is much harder to read
because it uses an nvme_admin_cmd structure to represent the
nvmf_property_get_command and nvmf_property_set_command data structures.
Verifying the implementation of nvme_property() requires to compare the
offsets of members of nvme_admin_cmd with the offsets of members of
nvmf_property_[gs]et_command. Make the code easier to read by using the
nvmf_property_get_command and nvmf_property_set data structures directly.
This patch fixes the sparse complaints about endianness mismatches in the
nvme_property(), nvme_get_property() and nvme_set_property() functions.
Cc: Eyal Ben David <eyalbe@il.ibm.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Tue, 18 Jun 2019 17:15:06 +0000 (10:15 -0700)]
wdc: Fix endianness bugs
Insert le16_to_cpu() / le32_to_cpu() where required.
Cc: Dong Ho <Dong.Ho@wdc.com> Fixes: 6bd8ab436693 ("wdc: Add data area extraction for DUI command"). Signed-off-by: Bart Van Assche <bvanassche@acm.org>
Bart Van Assche [Wed, 19 Jun 2019 15:30:47 +0000 (08:30 -0700)]
lightnvm: Fix an endianness issue
This patch avoids that sparse reports the following:
nvme-lightnvm.c:497:35: warning: incorrect type in initializer (different base types)
nvme-lightnvm.c:497:35: expected unsigned int [usertype] data_len
nvme-lightnvm.c:497:35: got restricted __le32 [usertype]
Cc: Matias Bjorling <m@bjorling.me> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
According to the le64toh() man page, the return type of that function
is uint64_t. Hence drop the cast from (uint64_t)le64_to_cpu(x)
expressions. This patch has been generated as follows:
git ls-tree --name-only -r HEAD |
while read f; do
[ -f "$f" ] && sed -i 's/(uint64_t)le64_to_cpu(/le64_to_cpu(/g' "$f"
done
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
yongxing [Mon, 10 Jun 2019 14:56:33 +0000 (22:56 +0800)]
NVMe-Cli Shannon Plugin-add support for shannon systems.
Hello,current NVMe-Cli tools hasn't supprot for shannon systems, we want to add it.
May we add some specific commands?
We add four NVMe commands for shannon temporarily,smart-log-add, get-feature-add, set-feature-add,
and id-ctrl.
Max Gurtovoy [Thu, 30 May 2019 09:43:23 +0000 (12:43 +0300)]
nvme: update description for "nvme list" command
The "nvme list" command doesn't get any device handle as an input
argument. This operation prints out a basic information for all NVMe
namespaces in the system.
Reviewed-by: Minwoo Im <minwoo.im@samsung.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Max Gurtovoy [Thu, 30 May 2019 09:43:22 +0000 (12:43 +0300)]
nvme: update list-ns nsid option
This commit updates the optional nsid argument to define the wanted
nsid for start, instead of starting from nsid + 1. E.g. in case we've
wanted to get the list of namespaces starting from 1, before this
commit, we used the "--namespace-id=0" option. Nsid 0 is not valid in
NVMe spec, thus change it to start counting from the given nsid.
Reviewed-by: Minwoo Im <minwoo.im@samsung.com> Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
Minwoo Im [Thu, 16 May 2019 17:23:49 +0000 (10:23 -0700)]
nvme-cli: don't try to disconnect for ctrl with pcie transport
If a host system has both pcie and fabrics controllers, the following
nvme-cli disconnect-all command will might not be working because
contrlller with pcie transport does not have delete_controller in sysfs.
root@target:~# nvme list
Node SN Model Namespace Usage Format FW Rev
---------------- -------------------- ---------------------------------------- --------- -------------------------- ---------------- --------
/dev/nvme0n1 foo QEMU NVMe Ctrl 1 536.87 MB / 536.87 MB 512 B + 0 B 1.0
/dev/nvme1n1 b92326b9b2323bf0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc
/dev/nvme2n1 65fa04eddd9bbac0 Linux 1 134.22 MB / 134.22 MB 512 B + 0 B 5.1.0-rc
root@target:~/nvme-cli.git# nvme disconnect-all
Failed to open /sys/class/nvme/nvme0/delete_controller: No such file or directory
This patch checks the transport type of the controller in iteration.
Keith Busch [Thu, 23 May 2019 21:04:56 +0000 (15:04 -0600)]
Fix sprintf truncate
Buffer was 16k, __builtin___snprintf_chk says it may require 18834. Up
to 20k. Note, we'd usually prefer dynamic buffers for such strings:
asprintf is your friend.