Commit 1a587504 authored by Artur Paszkiewicz's avatar Artur Paszkiewicz Committed by Jim Harris
Browse files

raid: fix race between process starting and removing a base bdev



Abort starting the process if a base bdev was removed in the meantime.

Signed-off-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
Change-Id: I45345322c6e21837d257cbe0598c5eb19f3f41be
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/22773


Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: default avatarMateusz Kozlowski <mateusz.kozlowski@solidigm.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
parent b3750343
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -2828,6 +2828,13 @@ raid_bdev_channels_start_process_done(struct spdk_io_channel_iter *i, int status
	struct spdk_thread *thread;
	char thread_name[RAID_BDEV_SB_NAME_SIZE + 16];

	if (status == 0 &&
	    (process->target->remove_scheduled || !process->target->is_configured ||
	     raid_bdev->num_base_bdevs_operational <= raid_bdev->min_base_bdevs_operational)) {
		/* a base bdev was removed before we got here */
		status = -ENODEV;
	}

	if (status != 0) {
		SPDK_ERRLOG("Failed to start %s on %s: %s\n",
			    raid_bdev_process_to_str(process->type), raid_bdev->bdev.name,
@@ -2835,8 +2842,6 @@ raid_bdev_channels_start_process_done(struct spdk_io_channel_iter *i, int status
		goto err;
	}

	/* TODO: we may need to abort if a base bdev was removed before we got here */

	snprintf(thread_name, sizeof(thread_name), "%s_%s",
		 raid_bdev->bdev.name, raid_bdev_process_to_str(process->type));

+1 −0
Original line number Diff line number Diff line
@@ -2321,6 +2321,7 @@ test_raid_process(void)

	pbdev->module->submit_process_request = submit_process_request;
	pbdev->module_private = &num_blocks_processed;
	pbdev->min_base_bdevs_operational = 0;

	CU_ASSERT(raid_bdev_start_rebuild(&pbdev->base_bdev_info[0]) == 0);
	poll_app_thread();