nvme: Add nvme_ctrlr_destruct_namespace
This function destructs a single namespace and removes it from the controller. Change-Id: I4b7b3576beda85c9ddad4e0f2db6d1964fa72b82 Signed-off-by: Ben Walker <benjamin.walker@intel.com> Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10024 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Eugene Kochetov <ekochetov@yandex.ru> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
84688fdb1c
commit
f555a8af97
@ -2138,6 +2138,23 @@ nvme_active_ns_ctx_destroy(struct nvme_active_ns_ctx *ctx)
|
||||
free(ctx);
|
||||
}
|
||||
|
||||
static int
|
||||
nvme_ctrlr_destruct_namespace(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
|
||||
{
|
||||
struct spdk_nvme_ns *ns;
|
||||
|
||||
assert(ctrlr != NULL);
|
||||
|
||||
if (nsid < 1 || nsid > ctrlr->num_ns) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ns = &ctrlr->ns[nsid - 1];
|
||||
nvme_ns_destruct(ns);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nvme_ctrlr_identify_active_ns_swap(struct spdk_nvme_ctrlr *ctrlr, uint32_t **new_ns_list,
|
||||
size_t max_entries)
|
||||
@ -2848,8 +2865,8 @@ nvme_ctrlr_destruct_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
||||
if (ctrlr->ns) {
|
||||
uint32_t i, num_ns = ctrlr->num_ns;
|
||||
|
||||
for (i = 0; i < num_ns; i++) {
|
||||
nvme_ns_destruct(&ctrlr->ns[i]);
|
||||
for (i = 1; i <= num_ns; i++) {
|
||||
nvme_ctrlr_destruct_namespace(ctrlr, i);
|
||||
}
|
||||
|
||||
spdk_free(ctrlr->ns);
|
||||
@ -2890,7 +2907,7 @@ nvme_ctrlr_update_namespaces(struct spdk_nvme_ctrlr *ctrlr)
|
||||
|
||||
if (nsdata->ncap && !ns_is_active) {
|
||||
NVME_CTRLR_DEBUGLOG(ctrlr, "Namespace %u was removed\n", nsid);
|
||||
nvme_ns_destruct(ns);
|
||||
nvme_ctrlr_destruct_namespace(ctrlr, nsid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4495,7 +4512,6 @@ spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
{
|
||||
struct nvme_completion_poll_status *status;
|
||||
int res;
|
||||
struct spdk_nvme_ns *ns;
|
||||
|
||||
if (nsid == 0) {
|
||||
return -EINVAL;
|
||||
@ -4527,12 +4543,7 @@ spdk_nvme_ctrlr_detach_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid,
|
||||
return res;
|
||||
}
|
||||
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, nsid);
|
||||
assert(ns != NULL);
|
||||
/* Inactive NS */
|
||||
nvme_ns_destruct(ns);
|
||||
|
||||
return 0;
|
||||
return nvme_ctrlr_destruct_namespace(ctrlr, nsid);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
@ -4584,7 +4595,6 @@ spdk_nvme_ctrlr_delete_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
|
||||
{
|
||||
struct nvme_completion_poll_status *status;
|
||||
int res;
|
||||
struct spdk_nvme_ns *ns;
|
||||
|
||||
if (nsid == 0) {
|
||||
return -EINVAL;
|
||||
@ -4615,11 +4625,7 @@ spdk_nvme_ctrlr_delete_ns(struct spdk_nvme_ctrlr *ctrlr, uint32_t nsid)
|
||||
return res;
|
||||
}
|
||||
|
||||
ns = spdk_nvme_ctrlr_get_ns(ctrlr, nsid);
|
||||
assert(ns != NULL);
|
||||
nvme_ns_destruct(ns);
|
||||
|
||||
return 0;
|
||||
return nvme_ctrlr_destruct_namespace(ctrlr, nsid);
|
||||
}
|
||||
|
||||
int
|
||||
|
Loading…
Reference in New Issue
Block a user