examples/nvme/identify: add a limit to the zns zone report dump option
Add an optional limit, -z N, to the zone report dump option -z. The variable g_zone_report_limit replaces the MAX_ZONE_DESC_ENTRIES such that the maximum-number of zone-descriptors is overwritable. It also replaces g_zone_report_full as it is represented by the limit-value 0, e.g. "no limit" dump the full report. The print of the section-header now includes the total amount of zones and the limit. With this information, the header's width varies. A helper-function, print_uline(), for printing an "underline" using a given marker, is also added. Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com> Change-Id: Ic8abead693ed83bb8612eef1f35605098ccade84 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6036 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Community-CI: Mellanox Build Bot Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com> Reviewed-by: Paul Luse <paul.e.luse@intel.com>
This commit is contained in:
parent
1b0134e0a9
commit
a587d90dcb
@ -50,7 +50,6 @@
|
|||||||
#define MAX_DISCOVERY_LOG_ENTRIES ((uint64_t)1000)
|
#define MAX_DISCOVERY_LOG_ENTRIES ((uint64_t)1000)
|
||||||
|
|
||||||
#define NUM_CHUNK_INFO_ENTRIES 8
|
#define NUM_CHUNK_INFO_ENTRIES 8
|
||||||
#define MAX_ZONE_DESC_ENTRIES 8
|
|
||||||
|
|
||||||
static int outstanding_commands;
|
static int outstanding_commands;
|
||||||
|
|
||||||
@ -87,7 +86,7 @@ static struct spdk_ocssd_geometry_data geometry_data;
|
|||||||
|
|
||||||
static struct spdk_ocssd_chunk_information_entry g_ocssd_chunk_info_page[NUM_CHUNK_INFO_ENTRIES ];
|
static struct spdk_ocssd_chunk_information_entry g_ocssd_chunk_info_page[NUM_CHUNK_INFO_ENTRIES ];
|
||||||
|
|
||||||
static bool g_zone_report_full = false;
|
static int64_t g_zone_report_limit = 8;
|
||||||
|
|
||||||
static bool g_hex_dump = false;
|
static bool g_hex_dump = false;
|
||||||
|
|
||||||
@ -648,6 +647,16 @@ print_ascii_string(const void *buf, size_t size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Underline a "line" with the given marker, e.g. print_uline("=", printf(...)); */
|
||||||
|
static void
|
||||||
|
print_uline(char marker, int line_len)
|
||||||
|
{
|
||||||
|
for (int i = 1; i < line_len; ++i) {
|
||||||
|
putchar(marker);
|
||||||
|
}
|
||||||
|
putchar('\n');
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
print_ocssd_chunk_info(struct spdk_ocssd_chunk_information_entry *chk_info, int chk_num)
|
print_ocssd_chunk_info(struct spdk_ocssd_chunk_information_entry *chk_info, int chk_num)
|
||||||
{
|
{
|
||||||
@ -742,15 +751,10 @@ get_and_print_zns_zone_report(struct spdk_nvme_ns *ns, struct spdk_nvme_qpair *q
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_zone_report_full) {
|
zones_to_print = g_zone_report_limit ? spdk_min(total_zones, (uint64_t)g_zone_report_limit) : \
|
||||||
zones_to_print = total_zones;
|
total_zones;
|
||||||
printf("NVMe ZNS Zone Report\n");
|
|
||||||
printf("====================\n");
|
print_uline('=', printf("NVMe ZNS Zone Report (first %zu of %zu)\n", zones_to_print, total_zones));
|
||||||
} else {
|
|
||||||
zones_to_print = spdk_min(total_zones, MAX_ZONE_DESC_ENTRIES);
|
|
||||||
printf("NVMe ZNS Zone Report Glance\n");
|
|
||||||
printf("===========================\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
while (handled_zones < zones_to_print) {
|
while (handled_zones < zones_to_print) {
|
||||||
memset(report_buf, 0, report_bufsize);
|
memset(report_buf, 0, report_bufsize);
|
||||||
@ -1951,7 +1955,7 @@ usage(const char *program_name)
|
|||||||
printf(" -d DPDK huge memory size in MB\n");
|
printf(" -d DPDK huge memory size in MB\n");
|
||||||
printf(" -g use single file descriptor for DPDK memory segments\n");
|
printf(" -g use single file descriptor for DPDK memory segments\n");
|
||||||
printf(" -x print hex dump of raw data\n");
|
printf(" -x print hex dump of raw data\n");
|
||||||
printf(" -z For NVMe Zoned Namespaces, dump the full zone report\n");
|
printf(" -z For NVMe Zoned Namespaces, dump the full zone report (-z) or the first N entries (-z N)\n");
|
||||||
printf(" -v verbose (enable warnings)\n");
|
printf(" -v verbose (enable warnings)\n");
|
||||||
printf(" -V enumerate VMD\n");
|
printf(" -V enumerate VMD\n");
|
||||||
printf(" -H show this usage\n");
|
printf(" -H show this usage\n");
|
||||||
@ -1966,7 +1970,7 @@ parse_args(int argc, char **argv)
|
|||||||
spdk_nvme_trid_populate_transport(&g_trid, SPDK_NVME_TRANSPORT_PCIE);
|
spdk_nvme_trid_populate_transport(&g_trid, SPDK_NVME_TRANSPORT_PCIE);
|
||||||
snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
snprintf(g_trid.subnqn, sizeof(g_trid.subnqn), "%s", SPDK_NVMF_DISCOVERY_NQN);
|
||||||
|
|
||||||
while ((op = getopt(argc, argv, "d:gi:p:r:xzHL:V")) != -1) {
|
while ((op = getopt(argc, argv, "d:gi:p:r:xz::HL:V")) != -1) {
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'd':
|
case 'd':
|
||||||
g_dpdk_mem = spdk_strtol(optarg, 10);
|
g_dpdk_mem = spdk_strtol(optarg, 10);
|
||||||
@ -2020,7 +2024,18 @@ parse_args(int argc, char **argv)
|
|||||||
g_hex_dump = true;
|
g_hex_dump = true;
|
||||||
break;
|
break;
|
||||||
case 'z':
|
case 'z':
|
||||||
g_zone_report_full = true;
|
if (optarg == NULL && argv[optind] != NULL && argv[optind][0] != '-') {
|
||||||
|
g_zone_report_limit = spdk_strtol(argv[optind], 10);
|
||||||
|
++optind;
|
||||||
|
} else if (optarg) {
|
||||||
|
g_zone_report_limit = spdk_strtol(optarg, 10);
|
||||||
|
} else {
|
||||||
|
g_zone_report_limit = 0;
|
||||||
|
}
|
||||||
|
if (g_zone_report_limit < 0) {
|
||||||
|
fprintf(stderr, "Invalid Zone Report limit\n");
|
||||||
|
return g_zone_report_limit;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
rc = spdk_log_set_flag(optarg);
|
rc = spdk_log_set_flag(optarg);
|
||||||
|
Loading…
Reference in New Issue
Block a user