lib/nvme: nvme_ctrlr_probe() fails if the controller is being destructed

When we support spdk_nvme_detach_async(), any controller may be
destructed asynchronously. We will be able to know the case by
ctrlr->is_destructed is true and ctrlr is queued in the attached list.

nvme_ctrlr_probe() should fail if the found ctrlr satisfies these
conditions.

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I299c2e5ea3c16cc1239899c163bb9e0eb921ade5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4413
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Shuhei Matsumoto 2020-09-24 23:57:04 +09:00 committed by Tomasz Zawadzki
parent 5be704cf97
commit b8fbb070f8

View File

@ -491,8 +491,16 @@ nvme_ctrlr_probe(const struct spdk_nvme_transport_id *trid,
if (!probe_ctx->probe_cb || probe_ctx->probe_cb(probe_ctx->cb_ctx, trid, &opts)) {
ctrlr = nvme_get_ctrlr_by_trid_unsafe(trid);
if (ctrlr) {
/* This ctrlr already exists.
* Increase the ref count before calling attach_cb() as the user may
/* This ctrlr already exists. */
if (ctrlr->is_destructed) {
/* This ctrlr is being destructed asynchronously. */
SPDK_ERRLOG("NVMe controller for SSD: %s is being destructed\n",
trid->traddr);
return -EBUSY;
}
/* Increase the ref count before calling attach_cb() as the user may
* call nvme_detach() immediately. */
nvme_ctrlr_proc_get_ref(ctrlr);