nvme: return NSID from spdk_nvme_ctrlr_create_ns()
Previously, there was no way to determine what namespace ID was assigned when a namespace was created via the NVMe library interface. Also drop the incorrect comment about calling spdk_nvme_ctrlr_process_admin_completions(), since spdk_nvme_ctrlr_create_ns() checks the admin queue internally. Change-Id: If90a6e9fc773aefa220ebbf6effc2d033c9f20cc Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
8f876a612f
commit
4957d2642a
@ -439,7 +439,7 @@ static void
|
||||
ns_manage_add(struct dev *device, uint64_t ns_size, uint64_t ns_capacity, int ns_lbasize,
|
||||
uint8_t ns_dps_type, uint8_t ns_dps_location, uint8_t ns_nmic)
|
||||
{
|
||||
int ret = 0;
|
||||
uint32_t nsid;
|
||||
struct spdk_nvme_ns_data *ndata;
|
||||
|
||||
ndata = rte_zmalloc("nvme namespace data", sizeof(struct spdk_nvme_ns_data), 4096);
|
||||
@ -456,9 +456,11 @@ ns_manage_add(struct dev *device, uint64_t ns_size, uint64_t ns_capacity, int ns
|
||||
ndata->dps.md_start = ns_dps_location;
|
||||
}
|
||||
ndata->nmic.can_share = ns_nmic;
|
||||
ret = spdk_nvme_ctrlr_create_ns(device->ctrlr, ndata);
|
||||
if (ret) {
|
||||
nsid = spdk_nvme_ctrlr_create_ns(device->ctrlr, ndata);
|
||||
if (nsid == 0) {
|
||||
fprintf(stdout, "ns manage: Failed\n");
|
||||
} else {
|
||||
printf("Created namespace ID %u\n", nsid);
|
||||
}
|
||||
|
||||
rte_free(ndata);
|
||||
|
@ -442,14 +442,12 @@ int spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
* \param ctrlr NVMe controller to create namespace on.
|
||||
* \param payload The pointer to the NVMe namespace data.
|
||||
*
|
||||
* \return 0 if successfully submitted, ENOMEM if resources could not be allocated for this request
|
||||
* \return Namespace ID (>= 1) if successfully created, or 0 if the request failed.
|
||||
*
|
||||
* This function is thread safe and can be called at any point after spdk_nvme_attach().
|
||||
*
|
||||
* Call \ref spdk_nvme_ctrlr_process_admin_completions() to poll for completion
|
||||
* of commands submitted through this function.
|
||||
*/
|
||||
int spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns_data *payload);
|
||||
uint32_t spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr,
|
||||
struct spdk_nvme_ns_data *payload);
|
||||
|
||||
/**
|
||||
* \brief Delete a namespace.
|
||||
|
@ -1231,7 +1231,7 @@ spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
return spdk_nvme_ctrlr_reset(ctrlr);
|
||||
}
|
||||
|
||||
int
|
||||
uint32_t
|
||||
spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns_data *payload)
|
||||
{
|
||||
struct nvme_completion_poll_status status;
|
||||
@ -1240,7 +1240,7 @@ spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns_dat
|
||||
status.done = false;
|
||||
res = nvme_ctrlr_cmd_create_ns(ctrlr, payload, nvme_completion_poll_cb, &status);
|
||||
if (res)
|
||||
return res;
|
||||
return 0;
|
||||
while (status.done == false) {
|
||||
nvme_mutex_lock(&ctrlr->ctrlr_lock);
|
||||
spdk_nvme_qpair_process_completions(&ctrlr->adminq, 0);
|
||||
@ -1248,10 +1248,16 @@ spdk_nvme_ctrlr_create_ns(struct spdk_nvme_ctrlr *ctrlr, struct spdk_nvme_ns_dat
|
||||
}
|
||||
if (spdk_nvme_cpl_is_error(&status.cpl)) {
|
||||
nvme_printf(ctrlr, "spdk_nvme_ctrlr_create_ns failed!\n");
|
||||
return ENXIO;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return spdk_nvme_ctrlr_reset(ctrlr);
|
||||
res = spdk_nvme_ctrlr_reset(ctrlr);
|
||||
if (res) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Return the namespace ID that was created */
|
||||
return status.cpl.cdw0;
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
x
Reference in New Issue
Block a user