From f983acfc3a001de689689aacf0a9d19c653266a0 Mon Sep 17 00:00:00 2001 From: Konrad Sztyber Date: Thu, 8 Jul 2021 13:35:21 +0200 Subject: [PATCH] bdev/nvme: move module finish callback to nvme_ctrlr_delete This is done in preparation for using the non-blocking versions of the spdk_nvme_detach API, which will delay controller's delation until the detach is completed asynchronously. Signed-off-by: Konrad Sztyber Change-Id: Ia785408c9a94427e60bf239e6036a5e89d589f61 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/8727 Tested-by: SPDK CI Jenkins Community-CI: Broadcom CI Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- module/bdev/nvme/bdev_nvme.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index d5818fc770..744771b1d5 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -441,14 +441,6 @@ nvme_ctrlr_delete(struct nvme_ctrlr *nvme_ctrlr) free(nvme_ctrlr->namespaces); free(nvme_ctrlr); -} - -static void -nvme_ctrlr_unregister_cb(void *io_device) -{ - struct nvme_ctrlr *nvme_ctrlr = io_device; - - nvme_ctrlr_delete(nvme_ctrlr); pthread_mutex_lock(&g_bdev_nvme_mutex); if (g_bdev_nvme_module_finish && TAILQ_EMPTY(&g_nvme_bdev_ctrlrs)) { @@ -457,10 +449,17 @@ nvme_ctrlr_unregister_cb(void *io_device) spdk_bdev_module_fini_done(); return; } - pthread_mutex_unlock(&g_bdev_nvme_mutex); } +static void +nvme_ctrlr_unregister_cb(void *io_device) +{ + struct nvme_ctrlr *nvme_ctrlr = io_device; + + nvme_ctrlr_delete(nvme_ctrlr); +} + static void nvme_ctrlr_unregister(void *ctx) {