Skip to content

Commit a1db296

Browse files
committed
nvme: add delete ns error message output
Print it if delete NS failed and NS management not supported. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
1 parent fe3b962 commit a1db296

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

nvme.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,26 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *cmd,
27832783
return err;
27842784
}
27852785

2786+
static void delete_ns_show_error(struct nvme_dev *dev, int err)
2787+
{
2788+
_cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
2789+
2790+
nvme_show_status(err);
2791+
2792+
ctrl = nvme_alloc(sizeof(*ctrl));
2793+
if (!ctrl)
2794+
return;
2795+
2796+
err = nvme_cli_identify_ctrl(dev, ctrl);
2797+
if (err) {
2798+
nvme_show_error("identify-ctrl: %s", nvme_strerror(errno));
2799+
return;
2800+
}
2801+
2802+
if (!(le16_to_cpu(ctrl->oacs) & NVME_CTRL_OACS_NS_MGMT))
2803+
nvme_show_error("NS Management and Attachment Not Supported");
2804+
}
2805+
27862806
static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *plugin)
27872807
{
27882808
const char *desc = "Delete the given namespace by "
@@ -2825,7 +2845,7 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *
28252845
if (!err)
28262846
printf("%s: Success, deleted nsid:%d\n", cmd->name, cfg.namespace_id);
28272847
else if (err > 0)
2828-
nvme_show_status(err);
2848+
delete_ns_show_error(dev, err);
28292849
else
28302850
nvme_show_error("delete namespace: %s", nvme_strerror(errno));
28312851

0 commit comments

Comments
 (0)