From 2bc373a9cab0aed3ec2397c09fcdcc8fea1b8b02 Mon Sep 17 00:00:00 2001 From: Brandon Paupore Date: Wed, 23 Jun 2021 12:31:22 -0500 Subject: [PATCH] Add Timeout Parameter for Zone Management Commands Signed-off-by: Brandon Paupore --- Documentation/nvme-zns-close-zone.1 | 12 +++++++--- Documentation/nvme-zns-finish-zone.1 | 12 +++++++--- Documentation/nvme-zns-offline-zone.1 | 12 +++++++--- Documentation/nvme-zns-open-zone.1 | 12 +++++++--- Documentation/nvme-zns-reset-zone.1 | 10 +++++++-- Documentation/nvme-zns-set-zone-desc.1 | 10 +++++++-- Documentation/nvme-zns-zone-mgmt-send.1 | 16 ++++++++----- plugins/zns/zns.c | 30 ++++++++++++++++--------- 8 files changed, 83 insertions(+), 31 deletions(-) diff --git a/Documentation/nvme-zns-close-zone.1 b/Documentation/nvme-zns-close-zone.1 index d9624c16..5f80a39b 100644 --- a/Documentation/nvme-zns-close-zone.1 +++ b/Documentation/nvme-zns-close-zone.1 @@ -32,9 +32,10 @@ nvme-zns-close-zone \- Closes one or all zones .SH "SYNOPSIS" .sp .nf -\fInvme zns close\-zone nvme zns id\-ctrl\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba= | \-s ] - [\-\-select\-all | \-a] +\fInvme zns close\-zone\fR [\-\-namespace\-id= | \-n ] + [\-\-start\-lba= | \-s ] + [\-\-select\-all | \-a] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -57,6 +58,11 @@ The starting LBA of the zone to close\&. .RS 4 Select all zones for this action .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-finish-zone.1 b/Documentation/nvme-zns-finish-zone.1 index 764c6836..b34801ff 100644 --- a/Documentation/nvme-zns-finish-zone.1 +++ b/Documentation/nvme-zns-finish-zone.1 @@ -32,9 +32,10 @@ nvme-zns-finish-zone \- Finishes one or all zones .SH "SYNOPSIS" .sp .nf -\fInvme zns finish\-zone nvme zns id\-ctrl\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba= | \-s ] - [\-\-select\-all | \-a] +\fInvme zns finish\-zone\fR [\-\-namespace\-id= | \-n ] + [\-\-start\-lba= | \-s ] + [\-\-select\-all | \-a] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -57,6 +58,11 @@ The starting LBA of the zone to finish\&. .RS 4 Select all zones for this action\&. .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-offline-zone.1 b/Documentation/nvme-zns-offline-zone.1 index 9d2d0837..2e6c1788 100644 --- a/Documentation/nvme-zns-offline-zone.1 +++ b/Documentation/nvme-zns-offline-zone.1 @@ -32,9 +32,10 @@ nvme-zns-offline-zone \- Offlines one or all zones .SH "SYNOPSIS" .sp .nf -\fInvme zns offline\-zone nvme zns id\-ctrl\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba= | \-s ] - [\-\-select\-all | \-a] +\fInvme zns offline\-zone\fR [\-\-namespace\-id= | \-n ] + [\-\-start\-lba= | \-s ] + [\-\-select\-all | \-a] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -57,6 +58,11 @@ The starting LBA of the zone to offline\&. .RS 4 Select all zones for this action .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-open-zone.1 b/Documentation/nvme-zns-open-zone.1 index 8ea78f20..41209426 100644 --- a/Documentation/nvme-zns-open-zone.1 +++ b/Documentation/nvme-zns-open-zone.1 @@ -32,9 +32,10 @@ nvme-zns-open-zone \- Opens one or all zones .SH "SYNOPSIS" .sp .nf -\fInvme zns open\-zone nvme zns id\-ctrl\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba= | \-s ] - [\-\-select\-all | \-a] +\fInvme zns open\-zone\fR [\-\-namespace\-id= | \-n ] + [\-\-start\-lba= | \-s ] + [\-\-select\-all | \-a] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -57,6 +58,11 @@ The starting LBA of the zone to open\&. .RS 4 Select all zones for this action .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-reset-zone.1 b/Documentation/nvme-zns-reset-zone.1 index b02d0427..7452e8bd 100644 --- a/Documentation/nvme-zns-reset-zone.1 +++ b/Documentation/nvme-zns-reset-zone.1 @@ -33,8 +33,9 @@ nvme-zns-reset-zone \- Resets one or all zones .sp .nf \fInvme zns reset\-zone\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba= | \-s ] - [\-\-select\-all | \-a] + [\-\-start\-lba= | \-s ] + [\-\-select\-all | \-a] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -57,6 +58,11 @@ The starting LBA of the zone to reset\&. .RS 4 Select all zones for this action .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-set-zone-desc.1 b/Documentation/nvme-zns-set-zone-desc.1 index a33b06a3..7b9a52a5 100644 --- a/Documentation/nvme-zns-set-zone-desc.1 +++ b/Documentation/nvme-zns-set-zone-desc.1 @@ -33,8 +33,9 @@ nvme-zns-set-zone-desc \- Set extended descriptor data for a zone .sp .nf \fInvme zns setzone\-desc\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba=, \-s ] - [\-data=, \-d ] + [\-\-start\-lba=, \-s ] + [\-data=, \-d ] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -55,6 +56,11 @@ The starting LBA of the zone to manage send\&. .RS 4 Optional file for data (default stdin) .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/Documentation/nvme-zns-zone-mgmt-send.1 b/Documentation/nvme-zns-zone-mgmt-send.1 index f74d8a3e..5b58bbcd 100644 --- a/Documentation/nvme-zns-zone-mgmt-send.1 +++ b/Documentation/nvme-zns-zone-mgmt-send.1 @@ -33,11 +33,12 @@ nvme-zns-zone-mgmt-send \- Zone Management Send command .sp .nf \fInvme zns zone\-mgmt\-send\fR [\-\-namespace\-id= | \-n ] - [\-\-start\-lba=, \-s ] - [\-\-select\-all, \-a] - [\-\-zsa=, \-z ] - [\-\-data\-len=, \-l ] - [\-data=, \-d ] + [\-\-start\-lba=, \-s ] + [\-\-select\-all, \-a] + [\-\-zsa=, \-z ] + [\-\-data\-len=, \-l ] + [\-data=, \-d ] + [\-\-timeout= | \-t ] .fi .SH "DESCRIPTION" .sp @@ -78,6 +79,11 @@ Buffer length if data required .RS 4 Optional file for data (default stdin) .RE +.PP +\-t , \-\-timeout= +.RS 4 +Override default timeout value\&. In milliseconds\&. +.RE .SH "EXAMPLES" .sp .RS 4 diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index ba0c3e42..a8ec6767 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -225,12 +225,13 @@ close_fd: return nvme_status_to_errno(err, false); } -static int __zns_mgmt_send(int fd, __u32 namespace_id, __u64 zslba, - bool select_all, enum nvme_zns_send_action zsa, __u32 data_len, void *buf) +static int __zns_mgmt_send(int fd, __u32 namespace_id, __u64 zslba, + bool select_all, __u32 timeout, enum nvme_zns_send_action zsa, + __u32 data_len, void *buf) { int err; - err = nvme_zns_mgmt_send(fd, namespace_id, zslba, select_all, zsa, + err = nvme_zns_mgmt_send(fd, namespace_id, zslba, select_all, timeout, zsa, data_len, buf); close(fd); return err; @@ -241,6 +242,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug { const char *zslba = "starting LBA of the zone for this command"; const char *select_all = "send command to all zones"; + const char *timeout = "timeout value, in milliseconds"; int err, fd; char *command; @@ -249,6 +251,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug __u64 zslba; __u32 namespace_id; bool select_all; + __u32 timeout; }; struct config cfg = {}; @@ -257,6 +260,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("select-all", 'a', &cfg.select_all, select_all), + OPT_UINT("timeout", 't', &cfg.timeout, timeout), OPT_END() }; @@ -277,7 +281,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug } err = __zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, - cfg.select_all, zsa, 0, NULL); + cfg.select_all, cfg.timeout, zsa, 0, NULL); if (!err) printf("%s: Success, action:%d zone:%"PRIx64" all:%d nsid:%d\n", command, zsa, (uint64_t)cfg.zslba, (int)cfg.select_all, @@ -331,6 +335,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu const char *zsa = "zone send action"; const char *data_len = "buffer length if data required"; const char *data = "optional file for data (default stdin)"; + const char *timeout = "timeout value, in milliseconds"; int fd, ffd = STDIN_FILENO, err = -1; void *buf = NULL; @@ -340,8 +345,9 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu __u32 namespace_id; bool select_all; __u8 zsa; - int data_len; + int data_len; char *file; + __u32 timeout; }; struct config cfg = {}; @@ -351,8 +357,9 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), OPT_FLAG("select-all", 'a', &cfg.select_all, select_all), OPT_BYTE("zsa", 'z', &cfg.zsa, zsa), - OPT_UINT("data-len", 'l', &cfg.data_len, data_len), - OPT_FILE("data", 'd', &cfg.file, data), + OPT_UINT("data-len", 'l', &cfg.data_len, data_len), + OPT_FILE("data", 'd', &cfg.file, data), + OPT_UINT("timeout", 't', &cfg.timeout, timeout), OPT_END() }; @@ -417,7 +424,7 @@ static int zone_mgmt_send(int argc, char **argv, struct command *cmd, struct plu } err = __zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, cfg.select_all, - cfg.zsa, cfg.data_len, buf); + cfg.timeout, cfg.zsa, cfg.data_len, buf); if (!err) printf("zone-mgmt-send: Success, action:%d zone:%"PRIx64" " "all:%d nsid:%d\n", @@ -478,6 +485,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug const char *desc = "Set Zone Descriptor Extension\n"; const char *zslba = "starting LBA of the zone for this command"; const char *data = "optional file for zone extention data (default stdin)"; + const char *timeout = "timeout value, in milliseconds"; int fd, ffd = STDIN_FILENO, err; void *buf = NULL; @@ -487,6 +495,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug __u64 zslba; __u32 namespace_id; char *file; + __u32 timeout; }; struct config cfg = {}; @@ -494,7 +503,8 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug OPT_ARGS(opts) = { OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_id), OPT_SUFFIX("start-lba", 's', &cfg.zslba, zslba), - OPT_FILE("data", 'd', &cfg.file, data), + OPT_FILE("data", 'd', &cfg.file, data), + OPT_UINT("timeout", 't', &cfg.timeout, timeout), OPT_END() }; @@ -542,7 +552,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug goto close_ffd; } - err = __zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, 0, + err = __zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, 0, cfg.timeout, NVME_ZNS_ZSA_SET_DESC_EXT, data_len, buf); if (!err) printf("set-zone-desc: Success, zone:%"PRIx64" nsid:%d\n", -- 2.50.1