diff --git a/lib/bdev/bdev.c b/lib/bdev/bdev.c index 20ba9a731..49153b130 100644 --- a/lib/bdev/bdev.c +++ b/lib/bdev/bdev.c @@ -76,6 +76,8 @@ enum spdk_bdev_qos_type { static const char *qos_type_str[SPDK_BDEV_QOS_NUM_TYPES] = {"Limit_IOPS", "Limit_BWPS"}; +TAILQ_HEAD(spdk_bdev_list, spdk_bdev); + struct spdk_bdev_mgr { struct spdk_mempool *bdev_io_pool; @@ -86,7 +88,7 @@ struct spdk_bdev_mgr { TAILQ_HEAD(, spdk_bdev_module) bdev_modules; - TAILQ_HEAD(, spdk_bdev) bdevs; + struct spdk_bdev_list bdevs; bool init_complete; bool module_init_complete; @@ -915,16 +917,10 @@ _spdk_bdev_finish_unregister_bdevs_iter(void *cb_arg, int bdeverrno) } /* - * Unregister the first bdev in the list. - * - * spdk_bdev_unregister() will handle the case where the bdev has open descriptors by - * calling the remove_cb of the descriptors first. - * - * Once this bdev and all of its open descriptors have been cleaned up, this function - * will be called again via the unregister completion callback to continue the cleanup - * process with the next bdev. + * Unregister the last bdev in the list. The last bdev in the list should be a bdev + * that has no bdevs that depend on it. */ - bdev = TAILQ_FIRST(&g_bdev_mgr.bdevs); + bdev = TAILQ_LAST(&g_bdev_mgr.bdevs, spdk_bdev_list); SPDK_DEBUGLOG(SPDK_LOG_BDEV, "Unregistering bdev '%s'\n", bdev->name); spdk_bdev_unregister(bdev, _spdk_bdev_finish_unregister_bdevs_iter, bdev); } diff --git a/lib/bdev/raid/bdev_raid.c b/lib/bdev/raid/bdev_raid.c index 28a95bbe4..628660404 100644 --- a/lib/bdev/raid/bdev_raid.c +++ b/lib/bdev/raid/bdev_raid.c @@ -243,6 +243,7 @@ raid_bdev_destruct(void *ctxt) TAILQ_REMOVE(&g_spdk_raid_bdev_configured_list, raid_bdev, link_specific_list); raid_bdev->state = RAID_BDEV_STATE_OFFLINE; TAILQ_INSERT_TAIL(&g_spdk_raid_bdev_offline_list, raid_bdev, link_specific_list); + spdk_io_device_unregister(raid_bdev, NULL); } if (raid_bdev->num_base_bdevs_discovered == 0) {