diff --git a/lib/nvmf/ctrlr.c b/lib/nvmf/ctrlr.c index a6d1fd104..04c7ad672 100644 --- a/lib/nvmf/ctrlr.c +++ b/lib/nvmf/ctrlr.c @@ -813,7 +813,7 @@ spdk_nvmf_ctrlr_identify_ns(struct spdk_nvmf_subsystem *subsystem, struct spdk_nvmf_ns *ns; ns = _spdk_nvmf_subsystem_get_ns(subsystem, cmd->nsid); - if (ns == NULL || ns->bdev == NULL || ns->is_removed) { + if (ns == NULL || ns->bdev == NULL) { SPDK_ERRLOG("Identify Namespace for invalid NSID %u\n", cmd->nsid); rsp->status.sc = SPDK_NVME_SC_INVALID_NAMESPACE_OR_FORMAT; return SPDK_NVMF_REQUEST_EXEC_STATUS_COMPLETE; @@ -913,7 +913,7 @@ spdk_nvmf_ctrlr_identify_active_ns_list(struct spdk_nvmf_subsystem *subsystem, for (ns = spdk_nvmf_subsystem_get_first_ns(subsystem); ns != NULL; ns = spdk_nvmf_subsystem_get_next_ns(subsystem, ns)) { - if (ns->id <= cmd->nsid || ns->is_removed) { + if (ns->id <= cmd->nsid) { continue; } diff --git a/lib/nvmf/ctrlr_bdev.c b/lib/nvmf/ctrlr_bdev.c index 4ae1fee57..65bb2e50f 100644 --- a/lib/nvmf/ctrlr_bdev.c +++ b/lib/nvmf/ctrlr_bdev.c @@ -404,7 +404,7 @@ spdk_nvmf_ctrlr_process_io_cmd(struct spdk_nvmf_request *req) } ns = _spdk_nvmf_subsystem_get_ns(ctrlr->subsys, nsid); - if (ns == NULL || ns->bdev == NULL || ns->is_removed) { + if (ns == NULL || ns->bdev == NULL) { SPDK_ERRLOG("Unsuccessful query for nsid %u\n", cmd->nsid); response->status.sc = SPDK_NVME_SC_INVALID_NAMESPACE_OR_FORMAT; response->status.dnr = 1; diff --git a/lib/nvmf/nvmf_internal.h b/lib/nvmf/nvmf_internal.h index 4fb29ca78..274768480 100644 --- a/lib/nvmf/nvmf_internal.h +++ b/lib/nvmf/nvmf_internal.h @@ -141,7 +141,6 @@ struct spdk_nvmf_ns { struct spdk_bdev_desc *desc; uint32_t id; bool allocated; - bool is_removed; }; enum spdk_nvmf_qpair_type { diff --git a/lib/nvmf/subsystem.c b/lib/nvmf/subsystem.c index 7de06e5ef..6b7d3dd4d 100644 --- a/lib/nvmf/subsystem.c +++ b/lib/nvmf/subsystem.c @@ -710,6 +710,9 @@ spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t ns { struct spdk_nvmf_ns *ns; + assert(subsystem->state == SPDK_NVMF_SUBSYSTEM_PAUSED || + subsystem->state == SPDK_NVMF_SUBSYSTEM_INACTIVE); + if (nsid == 0 || nsid > subsystem->max_nsid) { return -1; } @@ -727,22 +730,26 @@ spdk_nvmf_subsystem_remove_ns(struct spdk_nvmf_subsystem *subsystem, uint32_t ns } static void -_spdk_nvmf_ns_hot_remove(void *ctx) +_spdk_nvmf_ns_hot_remove(struct spdk_nvmf_subsystem *subsystem, + void *cb_arg, int status) { - struct spdk_nvmf_ns *ns = ctx; + struct spdk_nvmf_ns *ns = cb_arg; spdk_nvmf_subsystem_remove_ns(ns->subsystem, ns->id); + + spdk_nvmf_subsystem_resume(subsystem, NULL, NULL); } static void spdk_nvmf_ns_hot_remove(void *remove_ctx) { struct spdk_nvmf_ns *ns = remove_ctx; + int rc; - ns->is_removed = true; - spdk_thread_send_msg(ns->subsystem->tgt->master_thread, - _spdk_nvmf_ns_hot_remove, - ns); + rc = spdk_nvmf_subsystem_pause(ns->subsystem, _spdk_nvmf_ns_hot_remove, ns); + if (rc) { + SPDK_ERRLOG("Unable to pause subsystem to process namespace removal!\n"); + } } uint32_t