From 7717cfcacc818f391e13efde8aa68e2e5ade517e Mon Sep 17 00:00:00 2001 From: Jim Harris Date: Thu, 14 Jun 2018 10:26:00 -0700 Subject: [PATCH] bdev/iscsi: fix double spdk_bdev_module_finish_done() call bdev_iscsi_lun_cleanup() was not accounting for LUNs getting cleaned up before the module_finish function was called. This resulted in the bdev/iscsi module calling spdk_bdev_module_finish_done twice which resulted in io_device_unregister not found errors and possible seg faults. Signed-off-by: Jim Harris Change-Id: I42c3e0af250e0abcea1cd88ffd3c041ebdaeea49 Reviewed-on: https://review.gerrithub.io/415372 Tested-by: SPDK Automated Test System Reviewed-by: Daniel Verkamp Reviewed-by: Ben Walker --- lib/bdev/iscsi/bdev_iscsi.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/bdev/iscsi/bdev_iscsi.c b/lib/bdev/iscsi/bdev_iscsi.c index 2cefb7f4b..3ed7faaa9 100644 --- a/lib/bdev/iscsi/bdev_iscsi.c +++ b/lib/bdev/iscsi/bdev_iscsi.c @@ -63,6 +63,7 @@ static TAILQ_HEAD(, bdev_iscsi_lun) g_iscsi_lun_head = TAILQ_HEAD_INITIALIZER(g_ static TAILQ_HEAD(, bdev_iscsi_conn_req) g_iscsi_conn_req = TAILQ_HEAD_INITIALIZER( g_iscsi_conn_req); static struct spdk_poller *g_conn_poller = NULL; +static bool g_finish_in_process = false; struct bdev_iscsi_io { struct spdk_thread *submit_td; @@ -140,7 +141,7 @@ bdev_iscsi_lun_cleanup(struct bdev_iscsi_lun *lun) TAILQ_REMOVE(&g_iscsi_lun_head, lun, link); iscsi_destroy_context(lun->context); iscsi_free_lun(lun); - if (TAILQ_EMPTY(&g_iscsi_lun_head)) { + if (TAILQ_EMPTY(&g_iscsi_lun_head) && g_finish_in_process) { bdev_iscsi_finish_done(); spdk_bdev_module_finish_done(); } @@ -164,6 +165,12 @@ bdev_iscsi_finish(void) { struct bdev_iscsi_lun *lun, *tmp; + /* + * Set this flag so that bdev_iscsi_lun_cleanup knows it needs to mark + * the module finish as done when the TAILQ is not empty. + */ + g_finish_in_process = true; + if (TAILQ_EMPTY(&g_iscsi_lun_head)) { bdev_iscsi_finish_done(); spdk_bdev_module_finish_done();