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
3 changes: 2 additions & 1 deletion libnvme/src/nvme/fabrics.c
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,8 @@ static int nvmf_dim(libnvme_ctrl_t c, enum nvmf_dim_tas tas, __u8 trtype,
nvmf_fill_die(die, c->s->h, tel, trtype, adrfam, reg_addr, tsas);

nvme_init_dim_send(&cmd, tas, dim, tdl);
return libnvme_submit_admin_passthru(hdl, &cmd);
ret = libnvme_submit_admin_passthru(hdl, &cmd);
return ret ? ret : libnvme_wait_complete_passthru(hdl);
}

/**
Expand Down
9 changes: 9 additions & 0 deletions libnvme/src/nvme/ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ static int libnvme_submit_passthru64(struct libnvme_transport_handle *hdl,
__public int libnvme_submit_io_passthru(struct libnvme_transport_handle *hdl,
struct libnvme_passthru_cmd *cmd)
{
if (!hdl)
return -ENODEV;

if (!cmd->timeout_ms && hdl->timeout)
cmd->timeout_ms = hdl->timeout;

Expand All @@ -205,6 +208,12 @@ __public int libnvme_submit_io_passthru(struct libnvme_transport_handle *hdl,
__public int libnvme_submit_admin_passthru(struct libnvme_transport_handle *hdl,
struct libnvme_passthru_cmd *cmd)
{
if (!hdl)
return -ENODEV;

if (hdl->uring_enabled)
return libnvme_submit_admin_passthru_async(hdl, cmd);

if (!cmd->timeout_ms && hdl->timeout)
cmd->timeout_ms = hdl->timeout;

Expand Down
6 changes: 6 additions & 0 deletions libnvme/src/nvme/mi.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ void libnvme_mi_ep_probe(struct libnvme_mi_ep *ep)
"Identify Controller failed, no quirks applied\n");
goto out_close;
}
rc = libnvme_wait_complete_passthru(hdl);
if (rc) {
libnvme_msg(ep->ctx, LIBNVME_LOG_WARN,
"Identify Controller failed, no quirks applied\n");
goto out_close;
}

/* Samsung MZUL2512: cannot receive commands sent within ~1ms of
* the previous response. Set an inter-command delay of 1.2ms for
Expand Down
2 changes: 1 addition & 1 deletion libnvme/src/nvme/no-uring.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ int libnvme_submit_admin_passthru_async(struct libnvme_transport_handle *hdl,

int libnvme_wait_complete_passthru(struct libnvme_transport_handle *hdl)
{
return -ENOTSUP;
return 0;
}
38 changes: 25 additions & 13 deletions libnvme/src/nvme/nvme-cmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,15 @@ __public int libnvme_get_log(struct libnvme_transport_handle *hdl,
cmd->data_len = xfer;
cmd->addr = (__u64)(uintptr_t)ptr;

if (hdl->uring_enabled)
ret = libnvme_submit_admin_passthru_async(hdl, cmd);
else
ret = libnvme_submit_admin_passthru(hdl, cmd);
ret = libnvme_submit_admin_passthru(hdl, cmd);
if (ret)
return ret;

offset += xfer;
ptr += xfer;
} while (offset < data_len);

if (hdl->uring_enabled) {
ret = libnvme_wait_complete_passthru(hdl);
if (ret)
return ret;
}

return 0;
return libnvme_wait_complete_passthru(hdl);
Comment thread
martin-belanger marked this conversation as resolved.
}

static int read_ana_chunk(struct libnvme_transport_handle *hdl,
Expand Down Expand Up @@ -240,6 +231,9 @@ __public int libnvme_set_etdas(struct libnvme_transport_handle *hdl, bool *chang

nvme_init_get_features_host_behavior(&cmd, 0, &da4);
err = libnvme_submit_admin_passthru(hdl, &cmd);
if (err)
return err;
err = libnvme_wait_complete_passthru(hdl);
if (err)
return err;

Expand All @@ -256,7 +250,7 @@ __public int libnvme_set_etdas(struct libnvme_transport_handle *hdl, bool *chang
return err;

*changed = true;
return 0;
return libnvme_wait_complete_passthru(hdl);
}

__public int libnvme_clear_etdas(struct libnvme_transport_handle *hdl, bool *changed)
Expand All @@ -267,6 +261,9 @@ __public int libnvme_clear_etdas(struct libnvme_transport_handle *hdl, bool *cha

nvme_init_get_features_host_behavior(&cmd, 0, &da4);
err = libnvme_submit_admin_passthru(hdl, &cmd);
if (err)
return err;
err = libnvme_wait_complete_passthru(hdl);
if (err)
return err;

Expand All @@ -282,7 +279,7 @@ __public int libnvme_clear_etdas(struct libnvme_transport_handle *hdl, bool *cha
return err;

*changed = true;
return 0;
return libnvme_wait_complete_passthru(hdl);
}

__public int libnvme_get_uuid_list(struct libnvme_transport_handle *hdl,
Expand All @@ -300,11 +297,17 @@ __public int libnvme_get_uuid_list(struct libnvme_transport_handle *hdl,
"ERROR: nvme_identify_ctrl() failed 0x%x\n", err);
return err;
}
err = libnvme_wait_complete_passthru(hdl);
if (err)
return err;

if ((ctrl.ctratt & NVME_CTRL_CTRATT_UUID_LIST) ==
NVME_CTRL_CTRATT_UUID_LIST) {
nvme_init_identify_uuid_list(&cmd, uuid_list);
err = libnvme_submit_admin_passthru(hdl, &cmd);
if (err)
return err;
err = libnvme_wait_complete_passthru(hdl);
}

return err;
Expand All @@ -323,6 +326,9 @@ __public int libnvme_get_telemetry_max(struct libnvme_transport_handle *hdl,

nvme_init_identify_ctrl(&cmd, id_ctrl);
err = libnvme_submit_admin_passthru(hdl, &cmd);
if (err)
return err;
err = libnvme_wait_complete_passthru(hdl);
if (err)
return err;

Expand Down Expand Up @@ -542,6 +548,9 @@ __public int libnvme_get_ana_log_len(struct libnvme_transport_handle *hdl, size_

nvme_init_identify_ctrl(&cmd, ctrl);
ret = libnvme_submit_admin_passthru(hdl, &cmd);
if (ret)
return ret;
ret = libnvme_wait_complete_passthru(hdl);
if (ret)
return ret;

Expand All @@ -563,6 +572,9 @@ __public int libnvme_get_logical_block_size(struct libnvme_transport_handle *hdl

nvme_init_identify_ns(&cmd, nsid, ns);
ret = libnvme_submit_admin_passthru(hdl, &cmd);
if (ret)
return ret;
ret = libnvme_wait_complete_passthru(hdl);
if (ret)
return ret;

Expand Down
10 changes: 7 additions & 3 deletions libnvme/src/nvme/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -1496,9 +1496,11 @@ __public int libnvme_ctrl_identify(libnvme_ctrl_t c, struct nvme_id_ctrl *id)
struct libnvme_transport_handle *hdl =
libnvme_ctrl_get_transport_handle(c);
struct libnvme_passthru_cmd cmd;
int ret;

nvme_init_identify_ctrl(&cmd, id);
return libnvme_submit_admin_passthru(hdl, &cmd);
ret = libnvme_submit_admin_passthru(hdl, &cmd);
return ret ? ret : libnvme_wait_complete_passthru(hdl);
}

__public libnvme_ns_t libnvme_ctrl_first_ns(libnvme_ctrl_t c)
Expand Down Expand Up @@ -2679,7 +2681,8 @@ __public int libnvme_ns_identify(libnvme_ns_t n, struct nvme_id_ns *ns)
return err;

nvme_init_identify_ns(&cmd, libnvme_ns_get_nsid(n), ns);
return libnvme_submit_admin_passthru(hdl, &cmd);
err = libnvme_submit_admin_passthru(hdl, &cmd);
return err ? err : libnvme_wait_complete_passthru(hdl);
}

int libnvme_ns_identify_descs(libnvme_ns_t n, struct nvme_ns_id_desc *descs)
Expand All @@ -2693,7 +2696,8 @@ int libnvme_ns_identify_descs(libnvme_ns_t n, struct nvme_ns_id_desc *descs)
return err;

nvme_init_identify_ns_descs_list(&cmd, libnvme_ns_get_nsid(n), descs);
return libnvme_submit_admin_passthru(hdl, &cmd);
err = libnvme_submit_admin_passthru(hdl, &cmd);
return err ? err : libnvme_wait_complete_passthru(hdl);
}

__public int libnvme_ns_verify(libnvme_ns_t n, off_t offset, size_t count)
Expand Down
Loading