]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: fix verbose logging
authorMartin George <marting@netapp.com>
Mon, 8 Jul 2024 16:03:58 +0000 (21:33 +0530)
committerDaniel Wagner <wagi@monom.org>
Wed, 10 Jul 2024 06:23:44 +0000 (08:23 +0200)
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 <marting@netapp.com>
nvme.c
util/logging.c

diff --git a/nvme.c b/nvme.c
index d998c80083b7c2f0689f34d4c9c1708c0027e1bc..b09f09a13d3a5b4fb54cf5e0c9c1917245d8cc55 100644 (file)
--- 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;
index c26d9e228eed4ecc6fc53a72ac171e6a5179551d..8e59948ec22d0d0dd026b89f6a102b56389d114e 100644 (file)
@@ -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);
        }