]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
zns: small cleanups to zrwa
authorMatias Bjørling <matias.bjorling@wdc.com>
Mon, 13 Dec 2021 13:38:21 +0000 (13:38 +0000)
committerMatias Bjørling <matias.bjorling@wdc.com>
Mon, 13 Dec 2021 13:38:21 +0000 (13:38 +0000)
A couple of cleanups for the ZRWA to align it with the existing
style.

Signed-off-by: Matias Bjørling <matias.bjorling@wdc.com>
nvme-print.c
plugins/zns/zns.c
plugins/zns/zns.h

index 4f7433b4df926c3d4f04fcc9ce76bfe9809723b2..932c0d4303a1968311d555ce324a81dbc5f2b117 100644 (file)
@@ -4419,8 +4419,8 @@ static void show_nvme_id_ns_zoned_ozcs(__le16 ns_ozcs)
                printf(" [15:1] : %#x\tReserved\n", rsvd);
        printf("  [0:0] : %#x\t  Read Across Zone Boundaries: %s\n",
                razb, razb ? "Yes" : "No");
-       printf("  [1:1] : %#x\tZone Random Write Area: %sSupported\n", zrwasup,
-                               zrwasup ? "" : "Not ");
+       printf("  [1:1] : %#x\t  Zone Random Write Area: %s\n", zrwasup,
+                               zrwasup ? "Yes" : "No");
 }
 
 static void nvme_show_zns_id_ns_recommandeded_limit(__le32 ns_rl, int human, 
@@ -4440,8 +4440,8 @@ static void nvme_show_zns_id_ns_zrwacap(__u8 zrwacap)
 
        if (rsvd)
                printf(" [7:1] : %#x\tReserved\n", rsvd);
-       printf("  [0:0] : %#x\t  Explicit ZRWA Flush %sSupported\n",
-               expflushsup, expflushsup ? "" : "Not ");
+       printf("  [0:0] : %#x\t  Explicit ZRWA Flush Operations: %s\n",
+               expflushsup, expflushsup ? "Yes" : "No");
 }
 
 void nvme_show_zns_id_ns(struct nvme_zns_id_ns *ns,
@@ -4501,9 +4501,9 @@ void nvme_show_zns_id_ns(struct nvme_zns_id_ns *ns,
        nvme_show_zns_id_ns_recommandeded_limit(ns->frl,  human, "frl2");
        nvme_show_zns_id_ns_recommandeded_limit(ns->frl,  human, "frl3");
 
-       printf("numzrwa : %u\n", le32_to_cpu(ns->numzrwa));
+       printf("numzrwa : %#x\n", le32_to_cpu(ns->numzrwa));
        printf("zrwafg  : %u\n", le16_to_cpu(ns->zrwafg));
-       printf("zrwasz   : %u\n", le16_to_cpu(ns->zrwasz));
+       printf("zrwasz  : %u\n", le16_to_cpu(ns->zrwasz));
        if (human) {
                printf("zrwacap : %u\tZone Random Write Area Capability\n", ns->zrwacap);
                nvme_show_zns_id_ns_zrwacap(ns->zrwacap);
index e5797f1b56cec5f51cf53471830b7716c904b5e6..0dac0e62a5916076c82285f8be2b0f52003689f3 100644 (file)
@@ -232,7 +232,7 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug
        const char *select_all = "send command to all zones";
        const char *timeout = "timeout value, in milliseconds";
 
-       int err, fd;
+       int err, fd, zcapc = 0;
        char *command;
        __u32 result;
 
@@ -272,13 +272,12 @@ static int zns_mgmt_send(int argc, char **argv, struct command *cmd, struct plug
        err = nvme_zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, zsa,
                cfg.select_all, 0, 0, NULL, cfg.timeout, &result);
        if (!err) {
-               printf("%s: Success, action:%d zone:%"PRIx64" all:%d nsid:%d\n",
+    if (zsa == NVME_ZNS_ZSA_RESET)
+      zcapc = result & 0x1;
+
+               printf("%s: Success, action:%d zone:%"PRIx64" all:%d zcapc:%u nsid:%d\n",
                        command, zsa, (uint64_t)cfg.zslba, (int)cfg.select_all,
-                       cfg.namespace_id);
-               if(result && zsa == NVME_ZNS_ZSA_RESET) {
-                       if(result & 0x1)
-                               printf("Zone Capacity has Changed by the command\n");
-               }
+      zcapc, cfg.namespace_id);
        }
        else if (err > 0)
                nvme_show_status(err);
@@ -461,7 +460,7 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin *
 {
        const char *desc = "Open zones\n";
        const char *zslba = "starting LBA of the zone for this command";
-       const char *zrwa = "Zone Random Write Area Allocation";
+       const char *zrwaa = "Allocate Zone Random Write Area to zone";
        const char *select_all = "send command to all zones";
        const char *timeout = "timeout value, in milliseconds";
 
@@ -470,7 +469,7 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin *
        struct config {
                __u64   zslba;
                __u32   namespace_id;
-               bool    zrwa;
+               bool  zrwaa;
                bool    select_all;
                __u32   timeout;
        };
@@ -481,7 +480,7 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin *
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id,  namespace_id),
                OPT_SUFFIX("start-lba",  's', &cfg.zslba,         zslba),
-               OPT_FLAG("zrwa",         'r', &cfg.zrwa,          zrwa),
+               OPT_FLAG("zrwaa",         'r', &cfg.zrwaa,          zrwaa),
                OPT_FLAG("select-all",   'a', &cfg.select_all,    select_all),
                OPT_UINT("timeout",      't', &cfg.timeout,       timeout),
                OPT_END()
@@ -500,7 +499,7 @@ static int open_zone(int argc, char **argv, struct command *cmd, struct plugin *
        }
 
        err = nvme_zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba, NVME_ZNS_ZSA_OPEN,
-               cfg.select_all, cfg.zrwa, 0, NULL, cfg.timeout, NULL);
+               cfg.select_all, cfg.zrwaa, 0, NULL, cfg.timeout, NULL);
        if (!err)
                printf("zns-open-zone: Success zone slba:%"PRIx64" nsid:%d\n",
                        (uint64_t)cfg.zslba, cfg.namespace_id);
@@ -529,7 +528,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 *zrwa = "Zone Random Write Area Allocation";
+       const char *zrwaa = "Allocate Zone Random Write Area to zone";
        const char *data = "optional file for zone extention data (default stdin)";
        const char *timeout = "timeout value, in milliseconds";
 
@@ -539,7 +538,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug
 
        struct config {
                __u64   zslba;
-               bool    zrwa;
+               bool    zrwaa;
                __u32   namespace_id;
                char   *file;
                __u32   timeout;
@@ -550,7 +549,7 @@ 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_FLAG("zrwa",         'r', &cfg.zrwa,          zrwa),
+               OPT_FLAG("zrwaa",         'r', &cfg.zrwaa,          zrwaa),
                OPT_FILE("data",         'd', &cfg.file,          data),
                OPT_UINT("timeout",      't', &cfg.timeout,       timeout),
                OPT_END()
@@ -601,7 +600,7 @@ static int set_zone_desc(int argc, char **argv, struct command *cmd, struct plug
        }
 
        err = nvme_zns_mgmt_send(fd, cfg.namespace_id, cfg.zslba,
-               NVME_ZNS_ZSA_SET_DESC_EXT, 0, cfg.zrwa, data_len, buf,
+               NVME_ZNS_ZSA_SET_DESC_EXT, 0, cfg.zrwaa, data_len, buf,
                cfg.timeout, NULL);
        if (!err)
                printf("set-zone-desc: Success, zone:%"PRIx64" nsid:%d\n",
@@ -621,16 +620,16 @@ close_fd:
 }
 
 
-static int flush_zone(int argc, char **argv, struct command *cmd, struct plugin *plugin)
+static int zrwa_flush_zone(int argc, char **argv, struct command *cmd, struct plugin *plugin)
 {
        const char *desc = "Flush Explicit ZRWA Range";
-       const char *zllba = "The last LBA of the zone to be flushed";
+       const char *slba = "LBA to flush up to";
        const char *timeout = "timeout value, in milliseconds";
 
        int err, fd;
 
        struct config {
-               __u64   zllba;
+               __u64   lba;
                __u32   namespace_id;
                __u32   timeout;
        };
@@ -639,7 +638,7 @@ static int flush_zone(int argc, char **argv, struct command *cmd, struct plugin
 
        OPT_ARGS(opts) = {
                OPT_UINT("namespace-id", 'n', &cfg.namespace_id,  namespace_id),
-               OPT_SUFFIX("last-lba",   'l', &cfg.zllba,         zllba),
+               OPT_SUFFIX("lba",   'l', &cfg.lba,         slba),
                OPT_UINT("timeout",      't', &cfg.timeout,       timeout),
                OPT_END()
        };
@@ -656,11 +655,11 @@ static int flush_zone(int argc, char **argv, struct command *cmd, struct plugin
                }
        }
 
-       err = nvme_zns_mgmt_send(fd, cfg.namespace_id, cfg.zllba,
+       err = nvme_zns_mgmt_send(fd, cfg.namespace_id, cfg.lba,
                NVME_ZNS_ZSA_ZRWA_FLUSH, 0, 0, 0, NULL, cfg.timeout, NULL);
        if (!err)
-               printf("zns-flush-zone: Success, last lba:%"PRIx64" nsid:%d\n",
-                       (uint64_t)cfg.zllba, cfg.namespace_id);
+               printf("zrwa-flush-zone: Success, lba:%"PRIx64" nsid:%d\n",
+                       (uint64_t)cfg.lba, cfg.namespace_id);
        else
                nvme_show_status(err);
 close_fd:
index 29af49b368f25e111750ff8010202e20b3190b3d..1bdd4d9716cf1d85a5d8def4eb498f2c73b27355 100644 (file)
@@ -18,7 +18,7 @@ PLUGIN(NAME("zns", "Zoned Namespace Command Set", NVME_VERSION),
                ENTRY("open-zone", "Open one or more zones", open_zone)
                ENTRY("offline-zone", "Offline one or more zones", offline_zone)
                ENTRY("set-zone-desc", "Attach zone descriptor extension data to a zone", set_zone_desc)
-               ENTRY("flush-zone", "Flushes a range of logical blocks from a ZRWA to a zone.", flush_zone)
+               ENTRY("zrwa-flush-zone", "Flush LBAs associated with a ZRWA to a zone.", zrwa_flush_zone)
                ENTRY("changed-zone-list", "Retrieve the changed zone list log", changed_zone_list)
                ENTRY("zone-mgmt-recv", "Send the zone management receive command", zone_mgmt_recv)
                ENTRY("zone-mgmt-send", "Send the zone management send command", zone_mgmt_send)