From be0db0c7d87c333ea632c06447f25035d9a50e45 Mon Sep 17 00:00:00 2001 From: Keith Busch Date: Wed, 14 Apr 2021 21:16:27 -0700 Subject: [PATCH] add timeout parameter to get-lba-status 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 --- nvme-ioctl.c | 3 ++- nvme-ioctl.h | 2 +- nvme.c | 6 +++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/nvme-ioctl.c b/nvme-ioctl.c index c56ff035..28010754 100644 --- a/nvme-ioctl.c +++ b/nvme-ioctl.c @@ -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); diff --git a/nvme-ioctl.h b/nvme-ioctl.h index 89815ace..b0184c7d 100644 --- a/nvme-ioctl.h +++ b/nvme-ioctl.h @@ -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 bbf78006..a99189ab 100644 --- 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) -- 2.50.1