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

raid: write sb earlier when removing a base bdev



Update the superblock as soon as the raid bdev is quiesced, then
continue with removing the base bdev.

The condition in _raid_bdev_write_superblock() has to be changed because
base_info->desc is not NULL now, only remove_scheduled is set at this
stage of removing the base bdev.

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


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Reviewed-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
parent 1b9c5629
Loading
Loading
Loading
Loading
+43 −36
Original line number Diff line number Diff line
@@ -1873,19 +1873,6 @@ raid_bdev_remove_base_bdev_done(struct raid_base_bdev_info *base_info, int statu
	}
}

static void
raid_bdev_remove_base_bdev_write_sb_cb(int status, struct raid_bdev *raid_bdev, void *ctx)
{
	struct raid_base_bdev_info *base_info = ctx;

	if (status != 0) {
		SPDK_ERRLOG("Failed to write raid bdev '%s' superblock: %s\n",
			    raid_bdev->bdev.name, spdk_strerror(-status));
	}

	raid_bdev_remove_base_bdev_done(base_info, status);
}

static void
raid_bdev_remove_base_bdev_on_unquiesced(void *ctx, int status)
{
@@ -1895,28 +1882,8 @@ raid_bdev_remove_base_bdev_on_unquiesced(void *ctx, int status)
	if (status != 0) {
		SPDK_ERRLOG("Failed to unquiesce raid bdev %s: %s\n",
			    raid_bdev->bdev.name, spdk_strerror(-status));
		goto out;
	}

	if (raid_bdev->sb) {
		struct raid_bdev_superblock *sb = raid_bdev->sb;
		uint8_t slot = raid_bdev_base_bdev_slot(base_info);
		uint8_t i;

		for (i = 0; i < sb->base_bdevs_size; i++) {
			struct raid_bdev_sb_base_bdev *sb_base_bdev = &sb->base_bdevs[i];

			if (sb_base_bdev->state == RAID_SB_BASE_BDEV_CONFIGURED &&
			    sb_base_bdev->slot == slot) {
				/* TODO: distinguish between failure and intentional removal */
				sb_base_bdev->state = RAID_SB_BASE_BDEV_FAILED;

				raid_bdev_write_superblock(raid_bdev, raid_bdev_remove_base_bdev_write_sb_cb, base_info);
				return;
			}
		}
	}
out:
	raid_bdev_remove_base_bdev_done(base_info, status);
}

@@ -1954,6 +1921,30 @@ raid_bdev_channels_remove_base_bdev_done(struct spdk_io_channel_iter *i, int sta
			    base_info);
}

static void
raid_bdev_remove_base_bdev_cont(struct raid_base_bdev_info *base_info)
{
	raid_bdev_deconfigure_base_bdev(base_info);

	spdk_for_each_channel(base_info->raid_bdev, raid_bdev_channel_remove_base_bdev, base_info,
			      raid_bdev_channels_remove_base_bdev_done);
}

static void
raid_bdev_remove_base_bdev_write_sb_cb(int status, struct raid_bdev *raid_bdev, void *ctx)
{
	struct raid_base_bdev_info *base_info = ctx;

	if (status != 0) {
		SPDK_ERRLOG("Failed to write raid bdev '%s' superblock: %s\n",
			    raid_bdev->bdev.name, spdk_strerror(-status));
		raid_bdev_remove_base_bdev_done(base_info, status);
		return;
	}

	raid_bdev_remove_base_bdev_cont(base_info);
}

static void
raid_bdev_remove_base_bdev_on_quiesced(void *ctx, int status)
{
@@ -1967,10 +1958,26 @@ raid_bdev_remove_base_bdev_on_quiesced(void *ctx, int status)
		return;
	}

	raid_bdev_deconfigure_base_bdev(base_info);
	if (raid_bdev->sb) {
		struct raid_bdev_superblock *sb = raid_bdev->sb;
		uint8_t slot = raid_bdev_base_bdev_slot(base_info);
		uint8_t i;

	spdk_for_each_channel(raid_bdev, raid_bdev_channel_remove_base_bdev, base_info,
			      raid_bdev_channels_remove_base_bdev_done);
		for (i = 0; i < sb->base_bdevs_size; i++) {
			struct raid_bdev_sb_base_bdev *sb_base_bdev = &sb->base_bdevs[i];

			if (sb_base_bdev->state == RAID_SB_BASE_BDEV_CONFIGURED &&
			    sb_base_bdev->slot == slot) {
				/* TODO: distinguish between failure and intentional removal */
				sb_base_bdev->state = RAID_SB_BASE_BDEV_FAILED;

				raid_bdev_write_superblock(raid_bdev, raid_bdev_remove_base_bdev_write_sb_cb, base_info);
				return;
			}
		}
	}

	raid_bdev_remove_base_bdev_cont(base_info);
}

static int
+1 −1
Original line number Diff line number Diff line
@@ -348,7 +348,7 @@ _raid_bdev_write_superblock(void *_ctx)
	for (i = ctx->submitted; i < raid_bdev->num_base_bdevs; i++) {
		base_info = &raid_bdev->base_bdev_info[i];

		if (base_info->desc == NULL) {
		if (!base_info->is_configured || base_info->remove_scheduled) {
			assert(ctx->remaining > 1);
			raid_bdev_write_sb_base_bdev_done(0, ctx);
			ctx->submitted++;
+1 −1
Original line number Diff line number Diff line
@@ -206,7 +206,7 @@ test_raid_bdev_write_superblock(void)
	for (i = 0; i < SPDK_COUNTOF(base_info); i++) {
		base_info[i].raid_bdev = &raid_bdev;
		if (i > 0) {
			base_info[i].desc = (void *)0x1;
			base_info[i].is_configured = true;
		}
	}