From 986f74aead2321b4e1432e7ca9b039756762ab81 Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Tue, 7 Dec 2021 21:10:54 +0000 Subject: [PATCH] bdev_nvme: split fini ctrlr destruction to separate function We will need to add another step in the fini path for stopping discovery pollers, so this patch prepares for that. Signed-off-by: Jim Harris Change-Id: Ifecbbac60262f3aae7f7a7ced09b7a600df7c2e8 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10590 Community-CI: Broadcom CI Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Changpeng Liu Reviewed-by: Aleksey Marchuk --- module/bdev/nvme/bdev_nvme.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/module/bdev/nvme/bdev_nvme.c b/module/bdev/nvme/bdev_nvme.c index 958434d070..67e0b074cd 100644 --- a/module/bdev/nvme/bdev_nvme.c +++ b/module/bdev/nvme/bdev_nvme.c @@ -3873,20 +3873,10 @@ bdev_nvme_library_init(void) } static void -bdev_nvme_library_fini(void) +bdev_nvme_fini_destruct_ctrlrs(void) { struct nvme_bdev_ctrlr *nbdev_ctrlr; struct nvme_ctrlr *nvme_ctrlr; - struct nvme_probe_skip_entry *entry, *entry_tmp; - - spdk_poller_unregister(&g_hotplug_poller); - free(g_hotplug_probe_ctx); - g_hotplug_probe_ctx = NULL; - - TAILQ_FOREACH_SAFE(entry, &g_skipped_nvme_ctrlrs, tailq, entry_tmp) { - TAILQ_REMOVE(&g_skipped_nvme_ctrlrs, entry, tailq); - free(entry); - } pthread_mutex_lock(&g_bdev_nvme_mutex); TAILQ_FOREACH(nbdev_ctrlr, &g_nvme_bdev_ctrlrs, tailq) { @@ -3918,6 +3908,23 @@ bdev_nvme_library_fini(void) pthread_mutex_unlock(&g_bdev_nvme_mutex); } +static void +bdev_nvme_library_fini(void) +{ + struct nvme_probe_skip_entry *entry, *entry_tmp; + + spdk_poller_unregister(&g_hotplug_poller); + free(g_hotplug_probe_ctx); + g_hotplug_probe_ctx = NULL; + + TAILQ_FOREACH_SAFE(entry, &g_skipped_nvme_ctrlrs, tailq, entry_tmp) { + TAILQ_REMOVE(&g_skipped_nvme_ctrlrs, entry, tailq); + free(entry); + } + + bdev_nvme_fini_destruct_ctrlrs(); +} + static void bdev_nvme_verify_pi_error(struct nvme_bdev_io *bio) {