From 5cbfb1859bc3ece55d10b51f92ec77587fccc765 Mon Sep 17 00:00:00 2001 From: Martin George Date: Mon, 8 Jul 2024 21:33:58 +0530 Subject: [PATCH] nvme: fix verbose logging The -v verbose option for certain nvme commands like id-ctrl, id-ns, smart-log, sanitize-log, etc. is practically a no-op since it only prints latency info in addition to the regular output. But at the same time, these commands already implement a -H human readable option which prints additional useful info. So fix the -v option to make it synonymous with the -H option here. And while we are at it, move the latency info from current INFO level (i.e. -v logging) to DEBUG level (i.e. -vv logging) since it is better suited there. Signed-off-by: Martin George --- nvme.c | 26 +++++++++++++------------- util/logging.c | 14 ++++++-------- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/nvme.c b/nvme.c index d998c800..b09f09a1 100644 --- a/nvme.c +++ b/nvme.c @@ -556,7 +556,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug if (cfg.raw_binary) flags = BINARY; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; smart_log = nvme_alloc(sizeof(*smart_log)); @@ -1066,7 +1066,7 @@ static int get_effects_log(int argc, char **argv, struct command *cmd, struct pl if (cfg.raw_binary) flags = BINARY; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; list_head_init(&log_pages); @@ -2405,7 +2405,7 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p if (cfg.raw_binary) flags = BINARY; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; sanitize_log = nvme_alloc(sizeof(*sanitize_log)); @@ -2454,7 +2454,7 @@ static int get_fid_support_effects_log(int argc, char **argv, struct command *cm return err; } - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; fid_support_log = nvme_alloc(sizeof(*fid_support_log)); @@ -2503,7 +2503,7 @@ static int get_mi_cmd_support_effects_log(int argc, char **argv, struct command return err; } - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; mi_cmd_support_log = nvme_alloc(sizeof(*mi_cmd_support_log)); @@ -3428,7 +3428,7 @@ int __id_ctrl(int argc, char **argv, struct command *cmd, struct plugin *plugin, if (cfg.vendor_specific) flags |= VS; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; ctrl = nvme_alloc(sizeof(*ctrl)); @@ -3748,7 +3748,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug if (cfg.vendor_specific) flags |= VS; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; if (!cfg.namespace_id) { @@ -3820,7 +3820,7 @@ static int cmd_set_independent_id_ns(int argc, char **argv, struct command *cmd, if (cfg.raw_binary) flags = BINARY; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; if (!cfg.namespace_id) { @@ -3974,7 +3974,7 @@ static int id_uuid(int argc, char **argv, struct command *cmd, struct plugin *pl if (cfg.raw_binary) flags = BINARY; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; uuid_list = nvme_alloc(sizeof(*uuid_list)); @@ -4214,7 +4214,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct return err; } - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; caps = nvme_alloc(sizeof(*caps)); @@ -5410,7 +5410,7 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu return err; } - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; bar = mmap_registers(dev, false); @@ -5686,7 +5686,7 @@ static int get_register(int argc, char **argv, struct command *cmd, struct plugi return err; } - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; bar = mmap_registers(dev, false); @@ -8479,7 +8479,7 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin if (err) return err; - if (cfg.human_readable) + if (cfg.human_readable || argconfig_parse_seen(opts, "verbose")) flags |= VERBOSE; if (cfg.raw_binary) flags = BINARY; diff --git a/util/logging.c b/util/logging.c index c26d9e22..8e59948e 100644 --- a/util/logging.c +++ b/util/logging.c @@ -92,15 +92,14 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd, struct timeval end; int err; - if (log_level >= LOG_INFO) + if (log_level >= LOG_DEBUG) gettimeofday(&start, NULL); err = ioctl(fd, ioctl_cmd, cmd); - if (log_level >= LOG_INFO) { + if (log_level >= LOG_DEBUG) { gettimeofday(&end, NULL); - if (log_level >= LOG_DEBUG) - nvme_show_command(cmd, err); + nvme_show_command(cmd, err); nvme_show_latency(start, end); } @@ -118,16 +117,15 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd, struct timeval end; int err; - if (log_level >= LOG_INFO) + if (log_level >= LOG_DEBUG) gettimeofday(&start, NULL); err = ioctl(fd, ioctl_cmd, cmd); - if (log_level >= LOG_INFO) { + if (log_level >= LOG_DEBUG) { gettimeofday(&end, NULL); - if (log_level >= LOG_DEBUG) - nvme_show_command64(cmd, err); + nvme_show_command64(cmd, err); nvme_show_latency(start, end); } -- 2.50.1