]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
add timeout parameter to get-lba-status
authorKeith Busch <kbusch@kernel.org>
Thu, 15 Apr 2021 04:16:27 +0000 (21:16 -0700)
committerKeith Busch <kbusch@kernel.org>
Thu, 15 Apr 2021 04:16:27 +0000 (21:16 -0700)
The spec suggests completing the command may take longer than typical
commands, so allow the user specify the timeout.

Link: https://github.com/linux-nvme/nvme-cli/issues/1010
Signed-off-by: Keith Busch <kbusch@kernel.org>
nvme-ioctl.c
nvme-ioctl.h
nvme.c

index c56ff035c5ecc4c13b7266a6a33e10763232f292..28010754b5e4a124f7794dd0e126a2e7d8f1a21c 100644 (file)
@@ -880,7 +880,7 @@ int nvme_sec_recv(int fd, __u32 nsid, __u8 nssf, __u16 spsp,
 }
 
 int nvme_get_lba_status(int fd, __u32 namespace_id, __u64 slba, __u32 mndw,
-               __u8 atype, __u16 rl, void *data)
+               __u8 atype, __u16 rl, void *data, __u32 timeout_ms)
 {
        struct nvme_admin_cmd cmd = {
                .opcode =  nvme_admin_get_lba_status,
@@ -891,6 +891,7 @@ int nvme_get_lba_status(int fd, __u32 namespace_id, __u64 slba, __u32 mndw,
                .cdw11 = slba >> 32,
                .cdw12 = mndw,
                .cdw13 = (atype << 24) | rl,
+               .timeout_ms = timeout_ms,
        };
 
        return nvme_submit_admin_passthru(fd, &cmd);
index 89815ace09a97c2feb5eec4a8fd013258525c4c9..b0184c7deae4c3ebb4f1be5d60d44910a4670380 100644 (file)
@@ -150,7 +150,7 @@ int nvme_reset_controller(int fd);
 int nvme_ns_rescan(int fd);
 
 int nvme_get_lba_status(int fd, __u32 namespace_id, __u64 slba, __u32 mndw,
-               __u8 atype, __u16 rl, void *data);
+               __u8 atype, __u16 rl, void *data, __u32 timeout_ms);
 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 bbf7800696938cf80d8e8254127869c7ce377ca5..a99189abd183b6c4a7a0133bd3da58819dd09feb 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -5175,6 +5175,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                             " Status Descriptors to return.";
        const char *rl = "Range Length(RL) specifies the length of the range"\
                          " of contiguous LBAs beginning at SLBA";
+       const char *timeout = "timeout value, in milliseconds";
 
        enum nvme_print_flags flags;
        unsigned long buf_len;
@@ -5187,6 +5188,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                __u32 mndw;
                __u8 atype;
                __u16 rl;
+               __u32 timeout;
                char *output_format;
        };
 
@@ -5196,6 +5198,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                .mndw = 0,
                .atype = 0,
                .rl = 0,
+               .timeout      = 0,
                .output_format = "normal",
        };
 
@@ -5205,6 +5208,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
                OPT_UINT("max-dw",       'm', &cfg.mndw,          mndw),
                OPT_BYTE("action",       'a', &cfg.atype,         atype),
                OPT_SHRT("range-len",    'l', &cfg.rl,            rl),
+               OPT_UINT("timeout",      't', &cfg.timeout,       timeout),
                OPT_FMT("output-format", 'o', &cfg.output_format, output_format),
                OPT_END()
        };
@@ -5232,7 +5236,7 @@ static int get_lba_status(int argc, char **argv, struct command *cmd,
        }
 
        err = nvme_get_lba_status(fd, cfg.namespace_id, cfg.slba, cfg.mndw,
-                       cfg.atype, cfg.rl, buf);
+                       cfg.atype, cfg.rl, buf, cfg.timeout);
        if (!err)
                nvme_show_lba_status(buf, buf_len, flags);
        else if (err > 0)