Commit 01035cd4 authored by Jim Harris's avatar Jim Harris
Browse files

bdev: cleanup registered bdevs in reverse order



This ensures (for example) that a RAID volume is
unregistered before its member disks.

Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I7a7c16acc351f2d5d4218b64b370e2c77c6e2b5e
Reviewed-on: https://review.gerrithub.io/420812


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent fd75d357
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -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);
}
+1 −0
Original line number Diff line number Diff line
@@ -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) {