]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme: Use opcode directly in submit_io
authorTokunori Ikegami <ikegami.t@gmail.com>
Wed, 6 Jul 2022 17:34:30 +0000 (02:34 +0900)
committerDaniel Wagner <dwagner@suse.de>
Thu, 7 Jul 2022 09:34:20 +0000 (11:34 +0200)
submit_io is an internal functions and all callers pass the correct
opcode in. Thus no need to reparse and select the right wrapper
function (nvme_read, nvme_write, ...). Instead just pass the opcode to
the generic nvme_io function.

Note, the compare was fixed in 9b6d3fca4289 ("submit_io(): fix "nvme
compare" to pass correct command") but missed the opportunity to
cleanup this part.

Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[dwagner: reworded commit message]
Signed-off-by: Daniel Wagner <dwagner@suse.de>
nvme.c

diff --git a/nvme.c b/nvme.c
index a54a5f6f2100c414e29a2c7abebefef5a84603ec..08fbcbb2c149730b518e4457f50eb4083a21bd92 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -6602,12 +6602,7 @@ static int submit_io(int opcode, char *command, const char *desc,
                .result         = NULL,
        };
        gettimeofday(&start_time, NULL);
-       if (opcode == nvme_cmd_compare)
-               err = nvme_compare(&args);
-       else if (opcode & 1)
-               err = nvme_write(&args);
-       else
-               err = nvme_read(&args);
+       err = nvme_io(&args, opcode);
        gettimeofday(&end_time, NULL);
        if (cfg.latency)
                printf(" latency: %s: %llu us\n",