Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvme: fix verbose logging for certain commands #2406

Merged
merged 1 commit into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -578,7 +578,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;

if (cfg.fahrenheit)
Expand Down Expand Up @@ -1091,7 +1091,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);
Expand Down Expand Up @@ -2432,7 +2432,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));
Expand Down Expand Up @@ -2481,7 +2481,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));
Expand Down Expand Up @@ -2530,7 +2530,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));
Expand Down Expand Up @@ -3455,7 +3455,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));
Expand Down Expand Up @@ -3775,7 +3775,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) {
Expand Down Expand Up @@ -3847,7 +3847,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) {
Expand Down Expand Up @@ -4001,7 +4001,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));
Expand Down Expand Up @@ -4241,7 +4241,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));
Expand Down Expand Up @@ -5440,7 +5440,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);
Expand Down Expand Up @@ -5716,7 +5716,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);
Expand Down Expand Up @@ -8509,7 +8509,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;
Expand Down
14 changes: 6 additions & 8 deletions util/logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
}

Expand Down