]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
report all zones if no user override
authorKeith Busch <kbusch@kernel.org>
Tue, 16 Jun 2020 20:57:46 +0000 (13:57 -0700)
committerKeith Busch <kbusch@kernel.org>
Tue, 16 Jun 2020 20:57:46 +0000 (13:57 -0700)
default to report all zones if the user didn't request a specific number
of descriptors.

Signed-off-by: Keith Busch <kbusch@kernel.org>
plugins/zns/zns.c

index 8218a91ef8fbd677e95c44d9e6e8a1a371ecc1a5..2a9fc9fe558c0103e19c32c61a61b62a9dc10d52 100644 (file)
@@ -486,7 +486,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
 {
        const char *desc = "Retrieve the Report Zones data structure";
        const char *zslba = "starting lba of the zone";
-       const char *num_descs = "number of descriptors to retrieve";
+       const char *num_descs = "number of descriptors to retrieve (default: all of them)";
        const char *state = "state of zones to list";
        const char *ext = "set to use the extended report zones";
        const char *part = "set to use the partial report";
@@ -511,6 +511,7 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
 
        struct config cfg = {
                .output_format = "normal",
+               .num_descs = -1,
        };
 
        OPT_ARGS(opts) = {
@@ -551,6 +552,18 @@ static int report_zones(int argc, char **argv, struct command *cmd, struct plugi
                }
        }
 
+       if (cfg.num_descs == -1) {
+               struct nvme_zone_report r;
+
+               err = nvme_zns_report_zones(fd, cfg.namespace_id, 0,
+                       0, cfg.state, 0, sizeof(r), &r);
+               if (err) {
+                       nvme_show_status(err);
+                       goto close_fd;
+               }
+               cfg.num_descs = le64_to_cpu(r.nr_zones);
+       }
+
        report_size = sizeof(struct nvme_zone_report) + cfg.num_descs *
                (sizeof(struct nvme_zns_desc) + zdes);