nvme: Free inactive namespaces during spdk_nvme_ctrlr_reset

This is the only time where we're allowed to invalidate namespace
handles, so use this opportunity to release inactive ones.

Change-Id: I53626ddf30e48e04207078fe406ec6e02138ac9f
Signed-off-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10103
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Ben Walker 2021-11-03 12:24:50 -07:00 committed by Tomasz Zawadzki
parent 26d60dc433
commit e3eeb6bd9e

View File

@ -1714,6 +1714,7 @@ nvme_ctrlr_reset_pre(struct spdk_nvme_ctrlr *ctrlr)
int
spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr)
{
struct spdk_nvme_ns *ns, *tmp_ns;
struct spdk_nvme_qpair *qpair;
int rc = 0, rc_tmp = 0;
bool async;
@ -1754,6 +1755,17 @@ spdk_nvme_ctrlr_reconnect_poll_async(struct spdk_nvme_ctrlr *ctrlr)
}
}
/*
* Take this opportunity to remove inactive namespaces. During a reset namespace
* handles can be invalidated.
*/
RB_FOREACH_SAFE(ns, nvme_ns_tree, &ctrlr->ns, tmp_ns) {
if (!ns->active) {
RB_REMOVE(nvme_ns_tree, &ctrlr->ns, ns);
spdk_free(ns);
}
}
if (rc) {
nvme_ctrlr_fail(ctrlr, false);
}