Commit b8fbb070 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I299c2e5ea3c16cc1239899c163bb9e0eb921ade5
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4413


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
parent 5be704cf
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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);