Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions libnvme/src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ static int nvme_submit_passthru64(struct nvme_transport_handle *hdl,
int nvme_submit_io_passthru(struct nvme_transport_handle *hdl,
struct nvme_passthru_cmd *cmd)
{
cmd->admin = false;

if (hdl->ioctl64)
return nvme_submit_passthru64(hdl, NVME_IOCTL_IO64_CMD, cmd);
return nvme_submit_passthru32(hdl, NVME_IOCTL_IO_CMD, cmd);
Expand All @@ -186,6 +188,8 @@ int nvme_submit_io_passthru(struct nvme_transport_handle *hdl,
int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl,
struct nvme_passthru_cmd *cmd)
{
cmd->admin = true;

switch (hdl->type) {
case NVME_TRANSPORT_HANDLE_TYPE_DIRECT:
if (hdl->ioctl64)
Expand Down
4 changes: 3 additions & 1 deletion libnvme/src/nvme/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
* @timeout_ms: If non-zero, overrides system default timeout in milliseconds
* @rsvd2: Reserved for future use (and fills an implicit struct pad
* @result: Set on completion to the command's CQE DWORD 0-1 controller response
* @admin: If true admin command else io command
*/
struct nvme_passthru_cmd {
__u8 opcode;
Expand All @@ -91,6 +92,7 @@ struct nvme_passthru_cmd {
__u32 timeout_ms;
__u32 rsvd2;
__u64 result;
bool admin;
};

/**
Expand Down Expand Up @@ -462,7 +464,7 @@ int nvme_submit_admin_passthru(struct nvme_transport_handle *hdl,
struct nvme_passthru_cmd *cmd);

/**
* nvme_submit_io_passthru() - Submit an nvme passthrough command
* nvme_submit_io_passthru() - Submit an nvme passthrough io command
* @hdl: Transport handle
* @cmd: The nvme io command to send
*
Expand Down
13 changes: 11 additions & 2 deletions nvme-print.c
Original file line number Diff line number Diff line change
Expand Up @@ -522,9 +522,18 @@ void nvme_show_status(int status)

void nvme_show_err(const char *msg, int err)
{
if (err < 0)
nvme_show_cmd_err(msg, NULL, err);
}

void nvme_show_cmd_err(const char *msg, struct nvme_passthru_cmd *cmd, int err)
{
if (!err)
return;
else if (err < 0)
nvme_show_error("%s: %s", msg, nvme_strerror(-err));
else if (err > 0)
else if (cmd)
nvme_show_opcode_status(err, cmd->admin, cmd->opcode);
else
nvme_show_status(err);
}

Expand Down
1 change: 1 addition & 0 deletions nvme-print.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ struct print_ops *nvme_get_binary_print_ops(nvme_print_flags_t flags);

void nvme_show_status(int status);
void nvme_show_err(const char *msg, int err);
void nvme_show_cmd_err(const char *msg, struct nvme_passthru_cmd *cmd, int err);
void nvme_show_opcode_status(int status, bool admin, __u8 opcode);
void nvme_show_lba_status_info(__u64 result);
void nvme_show_relatives(struct nvme_global_ctx *ctx, const char *name, nvme_print_flags_t flags);
Expand Down
8 changes: 4 additions & 4 deletions nvme.c
Original file line number Diff line number Diff line change
Expand Up @@ -5604,10 +5604,10 @@ static int sanitize_ns_cmd(int argc, char **argv, struct command *acmd,

nvme_init_sanitize_ns(&cmd, cfg.sanact, cfg.ause, cfg.emvs);
err = nvme_submit_admin_passthru(hdl, &cmd);
if (err < 0)
nvme_show_error("sanitize ns: %s", nvme_strerror(err));
else if (err > 0)
nvme_show_status(err);
if (err) {
nvme_show_cmd_err("sanitize ns", &cmd, err);
return err;
}

return err;
}
Expand Down