Skip to content

Commit 5cbfb18

Browse files
martin-gpyigaw
authored andcommitted
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 <marting@netapp.com>
1 parent 92eaf9a commit 5cbfb18

File tree

2 files changed

+19
-21
lines changed

2 files changed

+19
-21
lines changed

nvme.c

+13-13
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
556556
if (cfg.raw_binary)
557557
flags = BINARY;
558558

559-
if (cfg.human_readable)
559+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
560560
flags |= VERBOSE;
561561

562562
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
10661066
if (cfg.raw_binary)
10671067
flags = BINARY;
10681068

1069-
if (cfg.human_readable)
1069+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
10701070
flags |= VERBOSE;
10711071

10721072
list_head_init(&log_pages);
@@ -2405,7 +2405,7 @@ static int sanitize_log(int argc, char **argv, struct command *command, struct p
24052405
if (cfg.raw_binary)
24062406
flags = BINARY;
24072407

2408-
if (cfg.human_readable)
2408+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
24092409
flags |= VERBOSE;
24102410

24112411
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
24542454
return err;
24552455
}
24562456

2457-
if (cfg.human_readable)
2457+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
24582458
flags |= VERBOSE;
24592459

24602460
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
25032503
return err;
25042504
}
25052505

2506-
if (cfg.human_readable)
2506+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
25072507
flags |= VERBOSE;
25082508

25092509
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,
34283428
if (cfg.vendor_specific)
34293429
flags |= VS;
34303430

3431-
if (cfg.human_readable)
3431+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
34323432
flags |= VERBOSE;
34333433

34343434
ctrl = nvme_alloc(sizeof(*ctrl));
@@ -3748,7 +3748,7 @@ static int id_ns(int argc, char **argv, struct command *cmd, struct plugin *plug
37483748
if (cfg.vendor_specific)
37493749
flags |= VS;
37503750

3751-
if (cfg.human_readable)
3751+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
37523752
flags |= VERBOSE;
37533753

37543754
if (!cfg.namespace_id) {
@@ -3820,7 +3820,7 @@ static int cmd_set_independent_id_ns(int argc, char **argv, struct command *cmd,
38203820
if (cfg.raw_binary)
38213821
flags = BINARY;
38223822

3823-
if (cfg.human_readable)
3823+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
38243824
flags |= VERBOSE;
38253825

38263826
if (!cfg.namespace_id) {
@@ -3974,7 +3974,7 @@ static int id_uuid(int argc, char **argv, struct command *cmd, struct plugin *pl
39743974
if (cfg.raw_binary)
39753975
flags = BINARY;
39763976

3977-
if (cfg.human_readable)
3977+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
39783978
flags |= VERBOSE;
39793979

39803980
uuid_list = nvme_alloc(sizeof(*uuid_list));
@@ -4214,7 +4214,7 @@ static int primary_ctrl_caps(int argc, char **argv, struct command *cmd, struct
42144214
return err;
42154215
}
42164216

4217-
if (cfg.human_readable)
4217+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
42184218
flags |= VERBOSE;
42194219

42204220
caps = nvme_alloc(sizeof(*caps));
@@ -5410,7 +5410,7 @@ static int show_registers(int argc, char **argv, struct command *cmd, struct plu
54105410
return err;
54115411
}
54125412

5413-
if (cfg.human_readable)
5413+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
54145414
flags |= VERBOSE;
54155415

54165416
bar = mmap_registers(dev, false);
@@ -5686,7 +5686,7 @@ static int get_register(int argc, char **argv, struct command *cmd, struct plugi
56865686
return err;
56875687
}
56885688

5689-
if (cfg.human_readable)
5689+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
56905690
flags |= VERBOSE;
56915691

56925692
bar = mmap_registers(dev, false);
@@ -8479,7 +8479,7 @@ static int dir_receive(int argc, char **argv, struct command *cmd, struct plugin
84798479
if (err)
84808480
return err;
84818481

8482-
if (cfg.human_readable)
8482+
if (cfg.human_readable || argconfig_parse_seen(opts, "verbose"))
84838483
flags |= VERBOSE;
84848484
if (cfg.raw_binary)
84858485
flags = BINARY;

util/logging.c

+6-8
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,14 @@ int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
9292
struct timeval end;
9393
int err;
9494

95-
if (log_level >= LOG_INFO)
95+
if (log_level >= LOG_DEBUG)
9696
gettimeofday(&start, NULL);
9797

9898
err = ioctl(fd, ioctl_cmd, cmd);
9999

100-
if (log_level >= LOG_INFO) {
100+
if (log_level >= LOG_DEBUG) {
101101
gettimeofday(&end, NULL);
102-
if (log_level >= LOG_DEBUG)
103-
nvme_show_command(cmd, err);
102+
nvme_show_command(cmd, err);
104103
nvme_show_latency(start, end);
105104
}
106105

@@ -118,16 +117,15 @@ int nvme_submit_passthru64(int fd, unsigned long ioctl_cmd,
118117
struct timeval end;
119118
int err;
120119

121-
if (log_level >= LOG_INFO)
120+
if (log_level >= LOG_DEBUG)
122121
gettimeofday(&start, NULL);
123122

124123

125124
err = ioctl(fd, ioctl_cmd, cmd);
126125

127-
if (log_level >= LOG_INFO) {
126+
if (log_level >= LOG_DEBUG) {
128127
gettimeofday(&end, NULL);
129-
if (log_level >= LOG_DEBUG)
130-
nvme_show_command64(cmd, err);
128+
nvme_show_command64(cmd, err);
131129
nvme_show_latency(start, end);
132130
}
133131

0 commit comments

Comments
 (0)