Skip to content

Commit 12e657d

Browse files
committed
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 <[email protected]>
1 parent f0365cf commit 12e657d

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
@@ -7415,6 +7415,23 @@ static int copy_cmd(int argc, char **argv, struct command *cmd, struct plugin *p
74157415
return err;
74167416
}
74177417

7418+
static void io_cmd_show_error(struct nvme_dev *dev, int err)
7419+
{
7420+
if (err > 0) {
7421+
nvme_show_status(err);
7422+
return;
7423+
}
7424+
7425+
nvme_show_init();
7426+
7427+
nvme_show_error("flush: %s", nvme_strerror(errno));
7428+
7429+
if (is_chardev(dev))
7430+
nvme_show_result("char device provided but blkdev is needed, e.g. /dev/nvme0n1");
7431+
7432+
nvme_show_finish();
7433+
}
7434+
74187435
static int flush_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin)
74197436
{
74207437
const char *desc = "Commit data and metadata associated with\n"
@@ -7450,10 +7467,8 @@ static int flush_cmd(int argc, char **argv, struct command *cmd, struct plugin *
74507467
}
74517468

74527469
err = nvme_flush(dev_fd(dev), cfg.namespace_id);
7453-
if (err < 0)
7454-
nvme_show_error("flush: %s", nvme_strerror(errno));
7455-
else if (err != 0)
7456-
nvme_show_status(err);
7470+
if (err)
7471+
io_cmd_show_error(dev, err);
74577472
else
74587473
printf("NVMe Flush: success\n");
74597474

0 commit comments

Comments
 (0)