From: Keith Busch Date: Tue, 16 Jun 2020 20:57:46 +0000 (-0700) Subject: report all zones if no user override X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=e71dcdeaa1557fd3ad66cafe4cd53830f05a17ee;p=users%2Fhch%2Fnvme-cli.git report all zones if no user override default to report all zones if the user didn't request a specific number of descriptors. Signed-off-by: Keith Busch --- diff --git a/plugins/zns/zns.c b/plugins/zns/zns.c index 8218a91..2a9fc9f 100644 --- a/plugins/zns/zns.c +++ b/plugins/zns/zns.c @@ -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);