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

bdev/nvme: Use SPDK message at bdev_nvme_library_fini() not to unlock during TAILQ_FOREACH()



Even if we use TAILQ_FOREACH_SAFE(), it is not safe to lock and unlock
while linked list is parsed.

To fix such erroneous implementation, use SPDK message.

Signed-off-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I79a126560ccd847149d4d06bb3d2111e43060ff7
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/5321


Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 6bd83dd1
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1595,8 +1595,10 @@ attach_cb(void *cb_ctx, const struct spdk_nvme_transport_id *trid,
}

static void
_nvme_bdev_ctrlr_destruct(struct nvme_bdev_ctrlr *nvme_bdev_ctrlr)
_nvme_bdev_ctrlr_destruct(void *ctx)
{
	struct nvme_bdev_ctrlr *nvme_bdev_ctrlr = ctx;

	nvme_ctrlr_depopulate_namespaces(nvme_bdev_ctrlr);

	pthread_mutex_lock(&g_bdev_nvme_mutex);
@@ -2105,11 +2107,8 @@ bdev_nvme_library_fini(void)
		}
		nvme_bdev_ctrlr->destruct = true;

		pthread_mutex_unlock(&g_bdev_nvme_mutex);

		_nvme_bdev_ctrlr_destruct(nvme_bdev_ctrlr);

		pthread_mutex_lock(&g_bdev_nvme_mutex);
		spdk_thread_send_msg(nvme_bdev_ctrlr->thread, _nvme_bdev_ctrlr_destruct,
				     nvme_bdev_ctrlr);
	}

	g_bdev_nvme_module_finish = true;