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: Shuhei 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: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com> Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
This commit is contained in:
parent
6bd83dd1c7
commit
80c4ee0a5e
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user