Commit 3cd7b237 authored by Sebastian Brzezinka's avatar Sebastian Brzezinka Committed by Konrad Sztyber
Browse files

bdev/raid: clear `data_offset` to allow it to be recalculated



If one of the slots of raid bdev is replaced, the optimal
`data_offset` for the new disk added will be recalculated.

Fixes #3419

Change-Id: I748ef2d3274f37d0a1e7cd4c443e316b8b0e45bc
Signed-off-by: default avatarSebastian Brzezinka <sebastian.brzezinka@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/24339


Reviewed-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarArtur Paszkiewicz <artur.paszkiewicz@intel.com>
parent 0cdba6b1
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -439,6 +439,9 @@ raid_bdev_free_base_bdev_resource(struct raid_base_bdev_info *base_info)
	}
	base_info->is_failed = false;

	/* clear `data_offset` to allow it to be recalculated during configuration */
	base_info->data_offset = 0;

	if (base_info->desc == NULL) {
		return;
	}
@@ -2457,6 +2460,7 @@ raid_bdev_process_finish_write_sb(void *ctx)
			base_info = &raid_bdev->base_bdev_info[sb_base_bdev->slot];
			if (base_info->is_configured) {
				sb_base_bdev->state = RAID_SB_BASE_BDEV_CONFIGURED;
				sb_base_bdev->data_offset = base_info->data_offset;
				spdk_uuid_copy(&sb_base_bdev->uuid, &base_info->uuid);
			}
		}
+34 −0
Original line number Diff line number Diff line
@@ -923,11 +923,45 @@ function raid_resize_superblock_test() {
	return 0
}

function raid_resize_data_offset_test() {

	$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -L bdev_raid &
	raid_pid=$!
	echo "Process raid pid: $raid_pid"
	waitforlisten $raid_pid $rpc_server

	# Create three base bdevs with one null bdev to be replaced later
	$rpc_py bdev_malloc_create -b malloc0 64 $base_blocklen -o 16
	$rpc_py bdev_malloc_create -b malloc1 64 $base_blocklen -o 16
	$rpc_py bdev_null_create null0 64 $base_blocklen

	$rpc_py bdev_raid_create -n Raid -r 1 -b "malloc0 malloc1 null0" -s

	# Check data_offset
	(($($rpc_py bdev_raid_get_bdevs all | jq -r '.[].base_bdevs_list[2].data_offset') == 2048))

	$rpc_py bdev_null_delete null0

	# Now null bdev is replaced with malloc, and optimal_io_boundary is changed to force
	# recalculation
	$rpc_py bdev_malloc_create -b malloc2 512 $base_blocklen -o 30
	$rpc_py bdev_raid_add_base_bdev Raid malloc2

	# Data offset is updated
	(($($rpc_py bdev_raid_get_bdevs all | jq -r '.[].base_bdevs_list[2].data_offset') == 2070))

	killprocess $raid_pid

	return 0
}

mkdir -p "$tmp_dir"
trap 'cleanup; exit 1' EXIT

base_blocklen=512

run_test "raid1_resize_data_offset_test" raid_resize_data_offset_test

run_test "raid0_resize_superblock_test" raid_resize_superblock_test 0
run_test "raid1_resize_superblock_test" raid_resize_superblock_test 1