]> www.infradead.org Git - users/sagi/nvme-cli.git/log
users/sagi/nvme-cli.git
6 years agoMerge pull request #513 from kheitke/master
Keith Busch [Sat, 22 Jun 2019 04:10:42 +0000 (22:10 -0600)]
Merge pull request #513 from kheitke/master

nvme-print: add JSON for NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields

6 years agoMerge pull request #512 from minwooim/for-1.9/return-negative-errno-v7-reviewed
Keith Busch [Fri, 21 Jun 2019 12:42:02 +0000 (06:42 -0600)]
Merge pull request #512 from minwooim/for-1.9/return-negative-errno-v7-reviewed

Introduce errno mapping with NVMe stauts

6 years agonvme-print: add JSON for NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields
Kenneth Heitke [Tue, 11 Jun 2019 18:13:14 +0000 (12:13 -0600)]
nvme-print: add JSON for NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields

6 years agofabrics: Return errno mapped for fabrics error status
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.

Cc: Keith Busch <kbusch@kernel.org>
Cc: Chaitanya Kulkarni <chaitanya.Kulkarni@wdc.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaianya.kulkarni@wdc.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
6 years agofabrics: return error when discovery retry exhausted
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.

Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaianya.kulkarni@wdc.com>
6 years agonvme: Return errno mapped for nvme error status
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>
6 years agonvme-status: Introduce nvme status module to map errno
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>
6 years agonvme: Return negative error value for internal errors
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>
6 years agofabrics: Do not return in the middle of the subcommand
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.

Cc: Keith Busch <kbusch@kernel.org>
Cc: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Cc: Sagi Grimberg <sagi@grimberg.me>
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>
6 years agonvme: Do not return in the middle of the subcommand
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>
6 years agoMerge pull request #511 from bvanassche/master
Keith Busch [Thu, 20 Jun 2019 13:59:41 +0000 (07:59 -0600)]
Merge pull request #511 from bvanassche/master

Multiple nvme-cli patches

6 years agonvme-cli: Report the NVMe 1.4 NPWG, NPWA, NPDG, NPDA and NOWS fields
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>
6 years agoIntroduce NVMe 1.4 Identify Namespace fields in struct nvme_id_ns
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>
6 years agonvme-cli: Skip properties that are not supported
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>
6 years agonvme-cli: Rework the code for getting and setting NVMf properties
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>
6 years agoAvoid using arrays with a variable length
Bart Van Assche [Tue, 18 Jun 2019 20:16:56 +0000 (13:16 -0700)]
Avoid using arrays with a variable length

Since variable length arrays result in suboptimal code, avoid using
variable length arrays.

Cc: Patrick McCormick <patrick.m.mccormick@intel.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agowdc: Fix endianness bugs
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>
6 years agovirtium: Fix an endianness issue
Bart Van Assche [Wed, 19 Jun 2019 16:15:14 +0000 (09:15 -0700)]
virtium: Fix an endianness issue

Convert nsze from little endian to CPU endian before using it.

Cc: Quyen Truong <quyen.truong@virtium.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agolightnvm: Fix an endianness issue
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>
6 years agovirtium: Declare local symbols static
Bart Van Assche [Tue, 18 Jun 2019 18:14:15 +0000 (11:14 -0700)]
virtium: Declare local symbols static

This patch avoids that sparse complains about missing declarations.

Cc: Quyen Truong <quyen.truong@virtium.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agoseagate: Declare local functions static
Bart Van Assche [Tue, 18 Jun 2019 17:06:41 +0000 (10:06 -0700)]
seagate: Declare local functions static

This patch avoids that sparse complains about missing declarations.

Cc: Muhammad Ahmad <muhammad.ahmad@seagate.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agohuawei: Declare local functions static
Bart Van Assche [Tue, 18 Jun 2019 17:18:26 +0000 (10:18 -0700)]
huawei: Declare local functions static

This patch avoids that sparse complains about missing declarations.

Cc: Zou Ming <zouming.zouming@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agoUse NULL instead of 0 where a pointer is expected
Bart Van Assche [Tue, 18 Jun 2019 18:12:19 +0000 (11:12 -0700)]
Use NULL instead of 0 where a pointer is expected

This patch avoids that sparse reports the following:

warning: Using plain integer as NULL pointer

Cc: Muhammad Ahmad <muhammad.ahmad@seagate.com>
Cc: Quyen Truong <quyen.truong@virtium.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
6 years agoRemove superfluous casts
Bart Van Assche [Tue, 18 Jun 2019 16:16:46 +0000 (09:16 -0700)]
Remove superfluous casts

The le64_to_cpu() definition is as follows:

  #define le64_to_cpu(x) le64toh((__force __u64)(x))

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>
6 years agoMerge pull request #507 from YoavCohen/master
Keith Busch [Mon, 10 Jun 2019 15:45:59 +0000 (09:45 -0600)]
Merge pull request #507 from YoavCohen/master

Some Json enhancements

6 years agoMerge pull request #509 from Tonyongxing/master
Keith Busch [Mon, 10 Jun 2019 15:45:46 +0000 (09:45 -0600)]
Merge pull request #509 from Tonyongxing/master

NVMe-Cli Shannon Plugin-add support for shannon systems.

6 years agoMerge pull request #508 from kheitke/sanitize-pretty-print
Keith Busch [Mon, 10 Jun 2019 15:45:02 +0000 (09:45 -0600)]
Merge pull request #508 from kheitke/sanitize-pretty-print

nvme-print: add pretty print for estimated sanitize time

6 years agoNVMe-Cli Shannon Plugin-add support for shannon systems.
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.

    Any problems, please contact me with:

    Email:yongxing.sun@shannon-sys.com

6 years agonvme: fix coding style issue
Max Gurtovoy [Thu, 30 May 2019 09:43:26 +0000 (12:43 +0300)]
nvme: fix coding style issue

It's more common to use the following coding style:
if (condition) {
   do_that;
   do_this;
} else if (condition2) {
   do_this;
} else {
   do_that;
}

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
6 years agonvme-print: fix json object memory leak
Max Gurtovoy [Thu, 30 May 2019 09:43:25 +0000 (12:43 +0300)]
nvme-print: fix json object memory leak

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
6 years agofabrics: Fix memory leak of subsys list
Max Gurtovoy [Thu, 30 May 2019 09:43:24 +0000 (12:43 +0300)]
fabrics: Fix memory leak of subsys list

Reviewed-by: Minwoo Im <minwoo.im@samsung.com>
Signed-off-by: Max Gurtovoy <maxg@mellanox.com>
6 years agonvme: update description for "nvme list" command
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>
6 years agonvme: update list-ns nsid option
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>
6 years agonvme-print: add pretty print for estimated sanitize time
Kenneth Heitke [Mon, 3 Jun 2019 21:42:39 +0000 (15:42 -0600)]
nvme-print: add pretty print for estimated sanitize time

Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
6 years agoadd namespace to json output of nvme list
Yoav Cohen [Wed, 29 May 2019 14:15:19 +0000 (17:15 +0300)]
add namespace to json output of nvme list

6 years agoadd free call for json object for commands show-regs
Yoav Cohen [Wed, 29 May 2019 14:13:45 +0000 (17:13 +0300)]
add free call for json object for commands show-regs

6 years agoadd newline for command show-regs
Yoav Cohen [Wed, 29 May 2019 14:11:44 +0000 (17:11 +0300)]
add newline for command show-regs

6 years agonvme-cli: remove unnecessary initialize of local var
Minwoo Im [Thu, 16 May 2019 17:23:50 +0000 (10:23 -0700)]
nvme-cli: remove unnecessary initialize of local var

This patch does not have any functional changes here.  Just clean-up the
unnecessary initialize.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agonvme-cli: don't try to disconnect for ctrl with pcie transport
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.

Reviewed-by: Sagi Grimberg <sagi@grimberg.me>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoFix sprintf truncate
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.

Link: https://github.com/linux-nvme/nvme-cli/issues/506
Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoSpin documentation
Keith Busch [Wed, 22 May 2019 22:42:55 +0000 (16:42 -0600)]
Spin documentation

New man pages provided for 3rd party plugin.

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agodoc: fixup 3rd party man page
Keith Busch [Wed, 22 May 2019 22:42:16 +0000 (16:42 -0600)]
doc: fixup 3rd party man page

ensure it compiles with asciidoc

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoMerge pull request #504 from YoavCohen/master
Keith Busch [Wed, 22 May 2019 15:43:19 +0000 (09:43 -0600)]
Merge pull request #504 from YoavCohen/master

fix json print for list-subsys command

6 years agofix json print for list-subsys command
Yoav Cohen [Wed, 22 May 2019 15:34:17 +0000 (18:34 +0300)]
fix json print for list-subsys command

The bug was the instead of adding paths to to the subsystem object it
wass added as a new subsystem

6 years agoMerge pull request #503 from quyentruongvir/virtium-plugin-extensions
Keith Busch [Wed, 22 May 2019 14:11:27 +0000 (08:11 -0600)]
Merge pull request #503 from quyentruongvir/virtium-plugin-extensions

Add Virtium plugin extensions

6 years agoAdd Virtium plugin extension document
Quyen Truong [Wed, 22 May 2019 02:10:36 +0000 (09:10 +0700)]
Add Virtium plugin extension document

6 years agoAdd Virtium plugin extension
Quyen Truong [Tue, 21 May 2019 11:48:37 +0000 (18:48 +0700)]
Add Virtium plugin extension

6 years agonvme.h: Fix typos in status code values
Minwoo Im [Sun, 19 May 2019 18:39:10 +0000 (11:39 -0700)]
nvme.h: Fix typos in status code values

Fix typos in status code value.  linux/nvme.h in kernel project is going
to be fixed soon or later.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
Reviewed-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoMerge pull request #490 from minwooim/for-1.9/free-fd-in-err
Keith Busch [Mon, 20 May 2019 15:12:47 +0000 (09:12 -0600)]
Merge pull request #490 from minwooim/for-1.9/free-fd-in-err

nvme: Do not return directly without freeing fd

6 years agonvme-cli: remove unused NVME_AER_NOTICE_*
Akinobu Mita [Thu, 16 May 2019 16:41:29 +0000 (01:41 +0900)]
nvme-cli: remove unused NVME_AER_NOTICE_*

NVME_AER_NOTICE_* are unused and these values conflict with the values
defined in the kernel nvme.h.

Cc: Keith Busch <keith.busch@intel.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
6 years agonvme-cli: add kernel-doc comment for struct telemetry_log_page_hdr
Akinobu Mita [Thu, 16 May 2019 16:40:28 +0000 (01:40 +0900)]
nvme-cli: add kernel-doc comment for struct telemetry_log_page_hdr

This adds the kernel-doc data structure comment for struct
telemetry_log_page_hdr.

This also replaces spaces with tabs to align the structure fields.

Cc: Keith Busch <keith.busch@intel.com>
Cc: Chaitanya Kulkarni <Chaitanya.Kulkarni@wdc.com>
Cc: Bart Van Assche <bvanassche@acm.org>
Suggested-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
6 years agorespin documentation
Keith Busch [Thu, 16 May 2019 15:47:11 +0000 (09:47 -0600)]
respin documentation

For format man page updates.

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoAdd a note to format on device naming conventions
Keith Busch [Thu, 16 May 2019 15:45:34 +0000 (09:45 -0600)]
Add a note to format on device naming conventions

Provide some help in the documentation on common user pitfalls.

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoremove non-portable compile-time check
Keith Busch [Thu, 16 May 2019 15:19:42 +0000 (09:19 -0600)]
remove non-portable compile-time check

_Static_assert is a C11 feature, and we're only targeting to be
compatible from C99.

Link: https://github.com/linux-nvme/nvme-cli/issues/502
Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agonvme-cli: use uniform if .. else format
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:20 +0000 (11:58 -0700)]
nvme-cli: use uniform if .. else format

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agonvme-cli: use uniform if .. else format
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:19 +0000 (11:58 -0700)]
nvme-cli: use uniform if .. else format

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agonvme-cli: use uniform if .. else format
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:18 +0000 (11:58 -0700)]
nvme-cli: use uniform if .. else format

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agonvme-cli: remove trailing space
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:17 +0000 (11:58 -0700)]
nvme-cli: remove trailing space

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agonvme-cli: code cleanup adjust if statement
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:16 +0000 (11:58 -0700)]
nvme-cli: code cleanup adjust if statement

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agonvme-cli: cmbloc code cleanup
Chaitanya Kulkarni [Sun, 12 May 2019 18:58:15 +0000 (11:58 -0700)]
nvme-cli: cmbloc code cleanup

This patch removes the unnecessary else condition which is out of
format anyway.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni@wdc.com>
6 years agoMerge pull request #498 from kheitke/revert-oncs-change
Keith Busch [Fri, 10 May 2019 22:46:42 +0000 (16:46 -0600)]
Merge pull request #498 from kheitke/revert-oncs-change

nvme-print: remove Virtual Management support from ONCS

6 years agonvme-print: remove Virtual Management support from ONCS
Kenneth Heitke [Fri, 10 May 2019 21:55:57 +0000 (15:55 -0600)]
nvme-print: remove Virtual Management support from ONCS

Revert commit 096fd4d which mistakenly reported Virtual Management
support in the ONCS field of the Identify Controller data structure.
Virtual Management support is part of OACS instead of ONCS and was
already correctly being displayed.

Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
6 years agoMerge pull request #494 from minwooim/for-1.9/fit-print-property-size
Keith Busch [Thu, 9 May 2019 20:03:24 +0000 (14:03 -0600)]
Merge pull request #494 from minwooim/for-1.9/fit-print-property-size

For 1.9/fit print property size

6 years agonvme-cli: cleanup comments for telemetry log structure
Akinobu Mita [Thu, 9 May 2019 15:43:17 +0000 (00:43 +0900)]
nvme-cli: cleanup comments for telemetry log structure

This removes three comments for struct nvme_telemetry_log_page_hdr.

- The comment on top of the definision doesn't describe more than the
  struct name itself.

- The rsvd1 field has already been verified.

- The structures with trailing zero size array are commonly used in
  nvme-cli, so we don't need special comment for telemetry_dataarea[0].

Cc: Keith Busch <keith.busch@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Kenneth Heitke <kenneth.heitke@intel.com>
Suggested-by: Kenneth Heitke <kenneth.heitke@intel.com>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
6 years agoMerge pull request #497 from kheitke/master
Keith Busch [Wed, 8 May 2019 17:38:46 +0000 (11:38 -0600)]
Merge pull request #497 from kheitke/master

nvme-print: update self-test log to include 'aborted due to sanitize'

6 years agonvme-print: update self-test log to include 'aborted due to sanitize'
Kenneth Heitke [Wed, 8 May 2019 17:13:29 +0000 (11:13 -0600)]
nvme-print: update self-test log to include 'aborted due to sanitize'

TP 4022 states that when a sanitize operation is started, self-test
operations in progress shall be aborted. The device-self test log page
includes a new result code that indicates if a self-test was aborted due
to a sanitize operation.

Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
6 years agoMerge pull request #496 from DimStar77/master
Keith Busch [Wed, 8 May 2019 16:51:11 +0000 (10:51 -0600)]
Merge pull request #496 from DimStar77/master

DOC: Move to DocBook 5 when using asciidoctor

6 years agoDOC: Move to DocBook 5 when using asciidoctor
Dominique Leuenberger [Wed, 8 May 2019 16:48:02 +0000 (18:48 +0200)]
DOC: Move to DocBook 5 when using asciidoctor

DocBook 5 has been released about a decade ago. Newer versions of
asciidoctor (since version 2.x) no longer support the previously
used DocBook 4.x format, so it is about time for us to switch too.

Fixes #495

6 years agonvme-cli: add missing endianness conversions for telemetry log page
Akinobu Mita [Sun, 5 May 2019 17:55:27 +0000 (10:55 -0700)]
nvme-cli: add missing endianness conversions for telemetry log page

Add missing endianness conversions for data area last block fields of
telemetry log page.

Cc: Keith Busch <keith.busch@intel.com>
Cc: Jens Axboe <axboe@fb.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Sagi Grimberg <sagi@grimberg.me>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
6 years agoproperty: Fit print size for a property
Minwoo Im [Sun, 5 May 2019 11:58:59 +0000 (20:58 +0900)]
property: Fit print size for a property

We may or may not be able to see the following output in nvme-loop env.
  # nvme get-property /dev/nvme0 -o 0x14
  property: 0x14 (Controller Configuration), value: 7f7800460001
The register CC is not in 64bit, but the upper bits are showing some values
even it's reserved in spec.

This patch makes this print size to fit to its own size of register.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
6 years agoproperty: Remove unnecessary wrapper function
Minwoo Im [Sun, 5 May 2019 11:52:40 +0000 (20:52 +0900)]
property: Remove unnecessary wrapper function

nvme_get_property_helper() used to be an actual function who is getting the
value of the given property with offset.  But, Now we don't have any 'advance'
argument to get back to the caller so that we can remove the helper function by
making it nvme_get_property() which is more intuitive.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
6 years agoproperty: Introduce inline function to check 64bit reg
Minwoo Im [Sun, 5 May 2019 11:46:39 +0000 (20:46 +0900)]
property: Introduce inline function to check 64bit reg

This patch removes 'advance' argument used in get_property_helper() to tell
the register of the given offset is whether 64bit or not, instead introduce a
inline function to check it simply.

This kind of check might be needed at the print module to figure out if given
register should be printed out in 32bit format or 64bit format.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
6 years agoAdd Disable IO flag to wdc_dump_dui_data function
Jeffrey Lien [Tue, 30 Apr 2019 18:48:32 +0000 (18:48 +0000)]
Add Disable IO flag to wdc_dump_dui_data function

Signed-off-by: Jeff Lien <jeff.lien@wdc.com>
6 years agolist-ctrl: Do not return directly without freeing fd
Minwoo Im [Thu, 25 Apr 2019 14:21:45 +0000 (23:21 +0900)]
list-ctrl: Do not return directly without freeing fd

It was returning an error value without freeding open fd for the device.
This patch replaces 'return' with 'goto' to free fd.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agocreate-ns: Do not return directly without freeing fd
Minwoo Im [Thu, 25 Apr 2019 14:20:29 +0000 (23:20 +0900)]
create-ns: Do not return directly without freeing fd

It was returning an error value without freeding open fd for the device.
This patch replaces 'return' with 'goto' to free fd.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoformat: Do not return directly without freeing fd
Minwoo Im [Thu, 25 Apr 2019 14:15:56 +0000 (23:15 +0900)]
format: Do not return directly without freeing fd

It was returning an error value without freeding open fd for the device.
This patch replaces 'return' with 'goto' to free fd.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoMerge pull request #488 from minwooim/for-1.9/djust-uniformity-of-code
Keith Busch [Fri, 26 Apr 2019 13:45:07 +0000 (07:45 -0600)]
Merge pull request #488 from minwooim/for-1.9/djust-uniformity-of-code

nvme-print: Few code clean-ups here

6 years agoReorder primary commands
Keith Busch [Thu, 25 Apr 2019 20:16:02 +0000 (14:16 -0600)]
Reorder primary commands

Group the identify commands together.

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoMerge pull request #491 from kheitke/secondary-controller-list
Keith Busch [Thu, 25 Apr 2019 20:20:37 +0000 (14:20 -0600)]
Merge pull request #491 from kheitke/secondary-controller-list

nvme-cli: add identify secondary controller list

6 years agonvme-cli: add identify secondary controller list
Kenneth Heitke [Wed, 24 Apr 2019 23:32:20 +0000 (17:32 -0600)]
nvme-cli: add identify secondary controller list

Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
6 years agospec, make: Add discovery.conf to the package files list
Sagi Grimberg [Wed, 24 Apr 2019 21:49:42 +0000 (14:49 -0700)]
spec, make: Add discovery.conf to the package files list

Lets add it as part of the package with a little documentation.

Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
6 years agospec, Makefile: add /etc/nvme files to package files
Sagi Grimberg [Wed, 24 Apr 2019 21:49:41 +0000 (14:49 -0700)]
spec, Makefile: add /etc/nvme files to package files

This way it can automatically be removed upon uninstallation
and we don't need %preun target. Also, this will also allow
to get these files on manual installation from sources.

Also, don't settle on the "file exists" check, use the '-s'
to check that it is not empty as well.

Lastly, in order to have hostnqn and hostid updated upon pkg
install, we have install-spec target that would omit hostnqn and
hostid files, and let the rpm %post do it (otherwise we
use the normal install target).

Reviewed-by: Minwoo Im <minwoo.im.dev@gmail.com>
Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
6 years agosanitize: Print nvme status in case ret > 0
Minwoo Im [Thu, 25 Apr 2019 13:57:44 +0000 (22:57 +0900)]
sanitize: Print nvme status in case ret > 0

If given 'err' is negative, then it's an internal error so that it needs
to be with perror().  If it's positive, then we can print nvme status
out.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoget-telemtry-log: Print nvme status in case err > 0
Minwoo Im [Thu, 25 Apr 2019 13:53:01 +0000 (22:53 +0900)]
get-telemtry-log: Print nvme status in case err > 0

If given 'err' is negative, then it's an internal error so that it needs
to be with perror().  If it's positive, then we can print nvme status
out.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoprint: Add const to return type of string
Minwoo Im [Thu, 25 Apr 2019 13:27:26 +0000 (22:27 +0900)]
print: Add const to return type of string

All those strings are supposed to be const.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoprint: Introduce show_nvme_status to print nvme status
Minwoo Im [Thu, 25 Apr 2019 12:40:14 +0000 (21:40 +0900)]
print: Introduce show_nvme_status to print nvme status

We have so many subcommands so that we need to have a function in
common to print out status of nvme command.

The nvme status will be printed out in case the subcommand itself fails
due to a reason.  In case of command which is in the middle of the
subcommand, it will be printed as "<cmd> failed" before status.

This patch has nothing to do with functional change.

Signed-off-by: Minwoo Im <minwoo.im.dev@gmail.com>
6 years agoMerge pull request #485 from kheitke/master
Keith Busch [Wed, 24 Apr 2019 21:29:11 +0000 (15:29 -0600)]
Merge pull request #485 from kheitke/master

nvme: fix minor type in id-ctrl human readable output

6 years agonvme: fix minor type in id-ctrl human readable output
Kenneth Heitke [Wed, 24 Apr 2019 21:22:21 +0000 (15:22 -0600)]
nvme: fix minor type in id-ctrl human readable output

Signed-off-by: Kenneth Heitke <kenneth.heitke@intel.com>
6 years agoMerge pull request #483 from minwooim/for-1.9/fix-double-free-in-a-loop
Keith Busch [Wed, 24 Apr 2019 13:47:53 +0000 (07:47 -0600)]
Merge pull request #483 from minwooim/for-1.9/fix-double-free-in-a-loop

For 1.9/fix double free in a loop

6 years agoioctl: Fix wrong return case of get_property
Minwoo Im [Wed, 24 Apr 2019 00:48:58 +0000 (01:48 +0100)]
ioctl: Fix wrong return case of get_property

If get_property_helper() succeeds in the first time, and then fails in
the next time, then the ret value will not be updated to an error value.
This patch removes 'ret' variable to make 'err' to return being updated
everytime get_property_helper() invoked.

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
6 years agoioctl: Fix double-free in a loop of get_property
Minwoo Im [Wed, 24 Apr 2019 00:46:29 +0000 (01:46 +0100)]
ioctl: Fix double-free in a loop of get_property

As it was reported, *pbar could be double-freed in case
get_property_helper() fails in the middle of the loop.

This issue was reported by Ken Heitke on:
  https://github.com/linux-nvme/nvme-cli/pull/471

Signed-off-by: Minwoo Im <minwoo.im@samsung.com>
6 years agonvme-cli: Increase size of ONTAP namespace path variable
Simon Schricker [Tue, 16 Apr 2019 13:27:40 +0000 (06:27 -0700)]
nvme-cli: Increase size of ONTAP namespace path variable

nspath's size is ONTAP_NS_PATHLEN and is written to by:

snprintf(nspath, ONTAP_NS_PATHLEN, "%s%s%s%s", ontap_vol,
                        vol_name, "/", ns_name);

Required bytes:

- ontap_vol is a constant char pointer, set to "/vol/", so 5 bytes
- vol_name's size is ONTAP_LABEL_LEN, which is 260, deducting the
  null-byte for termination makes 259 required bytes
- "/" is 1 byte
- ns_name's size is also ONTAP_LABEL_LEN, which is 260, deducting
  the null-byte for termination makes 259 required bytes
- the final null-byte: 1

That makes in total 5 + 259 + 1 + 259 + 1 = 525 required bytes

Signed-off-by: Simon Schricker <sschricker@suse.de>
6 years agoMerge pull request #480 from amluto/master
Keith Busch [Mon, 15 Apr 2019 17:53:44 +0000 (11:53 -0600)]
Merge pull request #480 from amluto/master

Fix passing CFLAGS on the make command line.

6 years agoFix passing CFLAGS on the make command line.
Andy Lutomirski [Mon, 15 Apr 2019 17:48:05 +0000 (10:48 -0700)]
Fix passing CFLAGS on the make command line.

Commit 254bcd6b2343 ("Fix CFLAGS parameter") only fixed the problem
if the variable came from the environment, not if it came from the
command line.  Fix it using 'override'.  See the GNU Make manual,
section 6.7 ("Overriding variables") for details.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
6 years agoRegen docs
Keith Busch [Mon, 15 Apr 2019 14:38:14 +0000 (08:38 -0600)]
Regen docs

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agonvme-cli: fix typo, removing the duplicate 'are'
Simon Schricker [Thu, 11 Apr 2019 09:23:16 +0000 (11:23 +0200)]
nvme-cli: fix typo, removing the duplicate 'are'

Signed-off-by: Simon Schricker <sschricker@suse.de>
6 years agoRevert "plugin: Return EINVAL instead of ENOTTY"
Keith Busch [Fri, 12 Apr 2019 20:48:29 +0000 (14:48 -0600)]
Revert "plugin: Return EINVAL instead of ENOTTY"

This reverts commit 048cd68c8f32c42b7098e1d21c06966f7fc6f099.

The wrong help information is being printed, so just doing a simple revert to
fix it.

Signed-off-by: Keith Busch <keith.busch@intel.com>
6 years agoMerge pull request #479 from yaznahar/use_hex_prefix_in_idctrl_output
Keith Busch [Thu, 11 Apr 2019 14:39:39 +0000 (08:39 -0600)]
Merge pull request #479 from yaznahar/use_hex_prefix_in_idctrl_output

Always use 0x prefix for hexdecimal values of id-ctrl output

6 years agoUse 0x prefix for all hex values of id-ctrl output
Alexander Larin [Thu, 11 Apr 2019 14:11:50 +0000 (17:11 +0300)]
Use 0x prefix for all hex values of id-ctrl output

Sometimes human-readable id-ctrl output could be confusing, e.g.
$ nvme id-ctrl /dev/nvme0
NVME Identify Controller:
vid       : 0x144d
ssvid     : 0x144d
sn        : S3HDNX0K601842
mn        : SAMSUNG MZWLL1T6HEHP-00003
fr        : GPNA5B3Q
rab       : 8
ieee      : 002538
cmic      : 0x3
mdts      : 5
cntlid    : 21
...
Here cntlid value is hexdecimal and equals 33, but nothing shows that.
In the same time some other values have 0x prefix. Let's use the prefix
for all hexdecimal values of the output.

Signed-off-by: Alexander Larin <znahar@yandex-team.ru>
6 years agoMerge pull request #478 from minwooim/for-v1.9/return-einval-instead-of-enotty
Keith Busch [Thu, 11 Apr 2019 14:06:36 +0000 (08:06 -0600)]
Merge pull request #478 from minwooim/for-v1.9/return-einval-instead-of-enotty

plugin: Return EINVAL instead of ENOTTY