]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: fix get lba status command nsid and data len fields
authorGollu Appalanaidu <anaidu.gollu@samsung.com>
Thu, 14 Jan 2021 17:18:56 +0000 (22:48 +0530)
committerKeith Busch <kbusch@kernel.org>
Thu, 14 Jan 2021 17:24:53 +0000 (10:24 -0700)
In get lba status admin command, host shall specify valid and
desired namespace, adding NSID field to receive from user and
also assign data len fields as per the given MNDW value.

Signed-off-by: Gollu Appalanaidu <anaidu.gollu@samsung.com>
nvme-ioctl.c
nvme-ioctl.h
nvme.c

index 7e0ec155a6d8aca50cb4d17544c78ae86ffce51c..a99d4909872c327c83af4a4999e9e27c05058c2f 100644 (file)
@@ -880,12 +880,14 @@ int nvme_sec_recv(int fd, __u32 nsid, __u8 nssf, __u16 spsp,
        return err;
 }
 
-int nvme_get_lba_status(int fd, __u64 slba, __u32 mndw, __u8 atype, __u16 rl,
-               void *data)
+int nvme_get_lba_status(int fd, __u32 namespace_id, __u64 slba, __u32 mndw,
+               __u8 atype, __u16 rl, void *data)
 {
        struct nvme_admin_cmd cmd = {
                .opcode =  nvme_admin_get_lba_status,
+               .nsid = namespace_id,
                .addr = (__u64)(uintptr_t) data,
+               .data_len = (mndw + 1) * 4,
                .cdw10 = slba & 0xffffffff,
                .cdw11 = slba >> 32,
                .cdw12 = mndw,
index 24eb2eb71b5fe4b2b1c852793ed6b8b9379d8d38..23c657fe07ff4028d0870feff6ae7c047d0c138c 100644 (file)
@@ -155,8 +155,8 @@ int nvme_subsystem_reset(int fd);
 int nvme_reset_controller(int fd);
 int nvme_ns_rescan(int fd);
 
-int nvme_get_lba_status(int fd, __u64 slba, __u32 mndw, __u8 atype, __u16 rl,
-               void *data);
+int nvme_get_lba_status(int fd, __u32 namespace_id, __u64 slba, __u32 mndw,
+               __u8 atype, __u16 rl, void *data);
 int nvme_dir_send(int fd, __u32 nsid, __u16 dspec, __u8 dtype, __u8 doper,
                  __u32 data_len, __u32 dw12, void *data, __u32 *result);
 int nvme_dir_recv(int fd, __u32 nsid, __u16 dspec, __u8 dtype, __u8 doper,
diff --git a/nvme.c b/nvme.c
index 72064e130e6ec6bcf24b295d8fa56b9acfa500b8..f84eef10cdc85fc5c311bc102c881d2d13f2dab4 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -4815,6 +4815,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                struct plugin *plugin)
 {
        const char *desc = "Information about potentially unrecoverable LBAs.";
+       const char *namespace_id = "Desired Namespace";
        const char *slba = "Starting LBA(SLBA) in 64-bit address of the first"\
                            " logical block addressed by this command";
        const char *mndw = "Maximum Number of Dwords(MNDW) specifies maximum"\
@@ -4831,6 +4832,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
        void *buf;
 
        struct config {
+               __u32 namespace_id;
                __u64 slba;
                __u32 mndw;
                __u8 atype;
@@ -4839,6 +4841,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
        };
 
        struct config cfg = {
+               .namespace_id = 0,
                .slba = 0,
                .mndw = 0,
                .atype = 0,
@@ -4847,6 +4850,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
        };
 
        OPT_ARGS(opts) = {
+               OPT_UINT("namespace-id", 'n', &cfg.namespace_id,  namespace_id),
                OPT_SUFFIX("start-lba",  's', &cfg.slba,          slba),
                OPT_UINT("max-dw",       'm', &cfg.mndw,          mndw),
                OPT_BYTE("action",       'a', &cfg.atype,         atype),
@@ -4876,8 +4880,8 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                goto close_fd;
        }
 
-       err = nvme_get_lba_status(fd, cfg.slba, cfg.mndw, cfg.atype, cfg.rl,
-                       buf);
+       err = nvme_get_lba_status(fd, cfg.namespace_id, cfg.slba, cfg.mndw,
+                       cfg.atype, cfg.rl, buf);
        if (!err)
                nvme_show_lba_status(buf, buf_len, flags);
        else if (err > 0)