Skip to content

Commit

Permalink
nvme: Add latency default option instead of passthru, submit_io and d…
Browse files Browse the repository at this point in the history
…sm options

Also change passthru short option to -t from -T as same with submit_io and dsm.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
  • Loading branch information
ikegami-t committed Dec 18, 2023
1 parent 5c0fc28 commit 5d390c4
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
4 changes: 2 additions & 2 deletions Documentation/nvme-admin-passthru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ SYNOPSIS
[--metadata-len=<len> | -m <len>]
[--input-file=<file> | -i <file>]
[--read | -r] [--write | -w]
[--timeout=<to> | -t <to>]
[--timeout=<to> | -T <to>]
[--show-command | -s]
[--dry-run | -d]
[--raw-binary | -b]
[--prefill=<prefill> | -p <prefill>]
[--latency | -T]
[--latency | -t]
[--output-format=<fmt> | -o <fmt>] [--verbose | -v]

DESCRIPTION
Expand Down
4 changes: 2 additions & 2 deletions Documentation/nvme-io-passthru.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ SYNOPSIS
[--read | -r] [--write | -w]
[--input-file=<file> | -i <file>]
[--metadata=<file> | -M <file>]
[--timeout=<to> | -t <to>] [--show-command | -s]
[--timeout=<to> | -T <to>] [--show-command | -s]
[--dry-run | -d] [--raw-binary | -b]
[--prefill=<prefill> | -p <prefill>]
[--latency | -T]
[--latency | -t]
[--output-format=<fmt> | -o <fmt>] [--verbose | -v]

DESCRIPTION
Expand Down
8 changes: 6 additions & 2 deletions completions/_nvme
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ _nvme () {
--metadata-len=':length for metadata buffer'
-m':alias of --metadata-len'
--timeout=':value for timeout'
-t':alias of --timeout'
-T':alias of --timeout'
--cdw2=':value for command dword 2'
-2':alias for --cdw2'
--cdw3=':value for command dword 3'
Expand Down Expand Up @@ -1260,6 +1260,8 @@ _nvme () {
-r':alias for --read'
--write':set dataflow direction to send'
-w':alias for --write'
--latency':latency statistics will be output following admin-passthru'
-t':alias of --latency'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme admin-passthru options" _admin
Expand All @@ -1281,7 +1283,7 @@ _nvme () {
--metadata-len=':length for metadata buffer'
-m':alias of --metadata-len'
--timeout=':value for timeout'
-t':alias of --timeout'
-T':alias of --timeout'
--cdw2=':value for command dword 2'
-2':alias for --cdw2'
--cdw3=':value for command dword 3'
Expand Down Expand Up @@ -1310,6 +1312,8 @@ _nvme () {
-r':alias for --read'
--write':set dataflow direction to send'
-w':alias for --write'
--latency':latency statistics will be output following io-passthru'
-t':alias of --latency'
)
_arguments '*:: :->subcmds'
_describe -t commands "nvme io-passthru options" _io
Expand Down
8 changes: 4 additions & 4 deletions completions/bash-nvme-completion.sh
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,20 @@ nvme_list_opts () {
"admin-passthru")
opts+=" --opcode= -O --flags= -f --prefil= -p --rsvd= -R \
--namespace-id= -n --data-len= -l --metadata-len= -m \
--timeout= -t --cdw2= -2 --cdw3= -3 --cdw10= -4 \
--timeout= -T --cdw2= -2 --cdw3= -3 --cdw10= -4 \
--cdw11= -5 --cdw12= -6 --cdw13= -7 --cdw14= -8 \
--cdw15= -9 --input-file= -i --raw-binary -b \
--show-command -s --dry-run -d --read -r --write -w \
--latency -T"
--latency -t"
;;
"io-passthru")
opts+=" --opcode= -O --flags= -f --prefill= -p --rsvd= -R \
--namespace-id= -n --data-len= -l --metadata-len= -m \
--timeout= -t --cdw2= -2 --cdw3= -3 --cdw10= -4 \
--timeout= -T --cdw2= -2 --cdw3= -3 --cdw10= -4 \
--cdw11= -5 --cdw12= -6 --cdw13= -7 --cdw14= -8 \
--cdw15= -9 --input-file= -i --raw-binary -b \
--show-command -s --dry-run -d --read -r --write -w \
--latency -T"
--latency -t"
;;
"security-send")
opts+=" --namespace-id= -n --file= -f --nssf= -N --secp= -p \
Expand Down
22 changes: 7 additions & 15 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,13 @@ struct passthru_config {
bool read;
bool write;
__u8 prefill;
bool latency;
};

#define NVME_ARGS(n, c, ...) \
struct argconfig_commandline_options n[] = { \
OPT_FLAG("verbose", 'v', NULL, verbose), \
OPT_FMT("output-format", 'o', &output_format_val, output_format), \
OPT_FLAG("latency", 't', NULL, latency), \
##__VA_ARGS__, \
OPT_END() \
}
Expand Down Expand Up @@ -6378,7 +6378,6 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
bool idw;
bool idr;
__u32 cdw11;
bool latency;
};

struct config cfg = {
Expand All @@ -6390,7 +6389,6 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
.idw = false,
.idr = false,
.cdw11 = 0,
.latency = false,
};

NVME_ARGS(opts, cfg,
Expand All @@ -6401,8 +6399,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
OPT_FLAG("ad", 'd', &cfg.ad, ad),
OPT_FLAG("idw", 'w', &cfg.idw, idw),
OPT_FLAG("idr", 'r', &cfg.idr, idr),
OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11),
OPT_FLAG("latency", 't', &cfg.latency, latency));
OPT_UINT("cdw11", 'c', &cfg.cdw11, cdw11));

err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
Expand Down Expand Up @@ -6453,7 +6450,7 @@ static int dsm(int argc, char **argv, struct command *cmd, struct plugin *plugin
nvme_show_status(err);
} else {
printf("NVMe DSM: success\n");
if (cfg.latency)
if (argconfig_parse_seen(opts, "latency"))
printf(" latency: %llu us\n", elapsed_utime(start_time, end_time));
}

Expand Down Expand Up @@ -7093,7 +7090,6 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
__u8 dsmgmt;
bool show;
bool dry_run;
bool latency;
bool force;
};

Expand All @@ -7118,7 +7114,6 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
.dsmgmt = 0,
.show = false,
.dry_run = false,
.latency = false,
.force = false,
};

Expand All @@ -7143,7 +7138,6 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
OPT_BYTE("dsm", 'D', &cfg.dsmgmt, dsm),
OPT_FLAG("show-command", 'V', &cfg.show, show),
OPT_FLAG("dry-run", 'w', &cfg.dry_run, dry),
OPT_FLAG("latency", 't', &cfg.latency, latency),
OPT_FLAG("force", 0, &cfg.force, force));

if (opcode != nvme_cmd_write) {
Expand Down Expand Up @@ -7364,7 +7358,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
gettimeofday(&start_time, NULL);
err = nvme_io(&args, opcode);
gettimeofday(&end_time, NULL);
if (cfg.latency)
if (argconfig_parse_seen(opts, "latency"))
printf(" latency: %s: %llu us\n", command, elapsed_utime(start_time, end_time));
if (err < 0) {
nvme_show_error("submit-io: %s", nvme_strerror(errno));
Expand Down Expand Up @@ -8093,7 +8087,6 @@ static int passthru(int argc, char **argv, bool admin,
.dry_run = false,
.read = false,
.write = false,
.latency = false,
};

NVME_ARGS(opts, cfg,
Expand All @@ -8104,7 +8097,7 @@ static int passthru(int argc, char **argv, bool admin,
OPT_UINT("namespace-id", 'n', &cfg.namespace_id, namespace_desired),
OPT_UINT("data-len", 'l', &cfg.data_len, data_len),
OPT_UINT("metadata-len", 'm', &cfg.metadata_len, metadata_len),
OPT_UINT("timeout", 't', &cfg.timeout, timeout),
OPT_UINT("timeout", 'T', &cfg.timeout, timeout),
OPT_UINT("cdw2", '2', &cfg.cdw2, cdw2),
OPT_UINT("cdw3", '3', &cfg.cdw3, cdw3),
OPT_UINT("cdw10", '4', &cfg.cdw10, cdw10),
Expand All @@ -8119,8 +8112,7 @@ static int passthru(int argc, char **argv, bool admin,
OPT_FLAG("show-command", 's', &cfg.show_command, show),
OPT_FLAG("dry-run", 'd', &cfg.dry_run, dry),
OPT_FLAG("read", 'r', &cfg.read, re),
OPT_FLAG("write", 'w', &cfg.write, wr),
OPT_FLAG("latency", 'T', &cfg.latency, latency));
OPT_FLAG("write", 'w', &cfg.write, wr));

err = parse_and_open(&dev, argc, argv, desc, opts);
if (err)
Expand Down Expand Up @@ -8235,7 +8227,7 @@ static int passthru(int argc, char **argv, bool admin,

gettimeofday(&end_time, NULL);
cmd_name = nvme_cmd_to_string(admin, cfg.opcode);
if (cfg.latency)
if (argconfig_parse_seen(opts, "latency"))
printf("%s Command %s latency: %llu us\n", admin ? "Admin" : "IO",
strcmp(cmd_name, "Unknown") ? cmd_name : "Vendor Specific",
elapsed_utime(start_time, end_time));
Expand Down

0 comments on commit 5d390c4

Please sign in to comment.