Commit df80e8ff authored by yupeng's avatar yupeng Committed by Tomasz Zawadzki
Browse files

bdev/raid: stop the raid bdev in raid_bdev_destruct



The raid bdev may receive IO requests after the raid layer
invokes spdk_bdev_unregister function. This patch moves the
raid_bdev->module->stop to the raid_bdev_destruct function.
Then there will be no IO after the raid_bdev->module->stop
is invoked.
Below is a way to reproduce this issue:
(1) create a malloc bdev
sudo ./scripts/rpc.py bdev_malloc_create --name malloc0 128 4096
(2) create a concat bdev base on the malloc bdev
sudo ./scripts/rpc.py bdev_raid_create --name concat0 \
--raid-level concat --base-bdevs malloc0 --strip-size-kb 4
(3) create a lvstore base on the concat bdev
sudo ./scripts/rpc.py bdev_lvol_create_lvstore \
--cluster-sz 4194304 --clear-method unmap concat0 lvs0
(4) remove the concat bdev
sudo ./scripts/rpc.py bdev_raid_delete concat0
In the step(4), the spdk app will crash because an IO request
is sent to the concat bdev after the concat_stop is invoked.

Signed-off-by: default avatarPeng Yu <yupeng0921@gmail.com>
Change-Id: I76d6964ee9528d4590ed86e9c5c28d53e85da32f
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/12221


Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@mellanox.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 1bac8afd
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -290,13 +290,14 @@ raid_bdev_destruct(void *ctxt)

	if (g_shutdown_started) {
		TAILQ_REMOVE(&g_raid_bdev_configured_list, raid_bdev, state_link);
		if (raid_bdev->module->stop != NULL) {
			raid_bdev->module->stop(raid_bdev);
		}
		raid_bdev->state = RAID_BDEV_STATE_OFFLINE;
		TAILQ_INSERT_TAIL(&g_raid_bdev_offline_list, raid_bdev, state_link);
	}

	if (raid_bdev->module->stop != NULL) {
		raid_bdev->module->stop(raid_bdev);
	}

	spdk_io_device_unregister(raid_bdev, NULL);

	if (raid_bdev->num_base_bdevs_discovered == 0) {
@@ -1285,9 +1286,6 @@ raid_bdev_deconfigure(struct raid_bdev *raid_bdev, raid_bdev_destruct_cb cb_fn,

	assert(raid_bdev->num_base_bdevs == raid_bdev->num_base_bdevs_discovered);
	TAILQ_REMOVE(&g_raid_bdev_configured_list, raid_bdev, state_link);
	if (raid_bdev->module->stop != NULL) {
		raid_bdev->module->stop(raid_bdev);
	}
	raid_bdev->state = RAID_BDEV_STATE_OFFLINE;
	assert(raid_bdev->num_base_bdevs_discovered);
	TAILQ_INSERT_TAIL(&g_raid_bdev_offline_list, raid_bdev, state_link);