Skip to content

Commit 946029c

Browse files
ikegami-tigaw
authored andcommitted
nvme: add flush command chardev handle error message
Since IO commands rejected by the chardev if more than one namespace. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent 565b30e commit 946029c

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

nvme.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7435,6 +7435,23 @@ static int copy_cmd(int argc, char **argv, struct command *cmd, struct plugin *p
74357435
return err;
74367436
}
74377437

7438+
static void io_cmd_show_error(struct nvme_dev *dev, int err, const char *cmd)
7439+
{
7440+
if (err > 0) {
7441+
nvme_show_status(err);
7442+
return;
7443+
}
7444+
7445+
nvme_show_init();
7446+
7447+
nvme_show_error("%s: %s", cmd, nvme_strerror(errno));
7448+
7449+
if (is_chardev(dev))
7450+
nvme_show_result("char device provided but blkdev is needed, e.g. /dev/nvme0n1");
7451+
7452+
nvme_show_finish();
7453+
}
7454+
74387455
static int flush_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin)
74397456
{
74407457
const char *desc = "Commit data and metadata associated with\n"
@@ -7470,10 +7487,8 @@ static int flush_cmd(int argc, char **argv, struct command *cmd, struct plugin *
74707487
}
74717488

74727489
err = nvme_flush(dev_fd(dev), cfg.namespace_id);
7473-
if (err < 0)
7474-
nvme_show_error("flush: %s", nvme_strerror(errno));
7475-
else if (err != 0)
7476-
nvme_show_status(err);
7490+
if (err)
7491+
io_cmd_show_error(dev, err, "flush");
74777492
else
74787493
printf("NVMe Flush: success\n");
74797494

0 commit comments

Comments
 (0)