Commit 4bd98e71 authored by Abhilash Shetty's avatar Abhilash Shetty Committed by Jim Harris
Browse files

test/blobstore: add test for max growable size



Adds shell test which starts bdev_svc. Creates lvstore with varying device size,
cluster size and num_md_pages_cluster_ratio.

Grows the lvs upto max_growable_size which should pass.
Then grows the lvs by a cluster_sz. This should fail.

Also updates negative blobstore grow test in blob_ut

Change-Id: I88bbd7108e3ff622c555ddb40f2b84cfb98068b1
Signed-off-by: default avatarAbhilash Shetty <abhilash.shetty@datacore.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26418


Reviewed-by: default avatarTomasz Zawadzki <tomasz@tzawadzki.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
parent 423e41f0
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ if [ $SPDK_RUN_FUNCTIONAL_TEST -eq 1 ]; then
	if [ $SPDK_TEST_LVOL -eq 1 ]; then
		run_test "blobstore" $rootdir/test/blobstore/blobstore.sh
		run_test "blobstore_grow" $rootdir/test/blobstore/blobstore_grow/blobstore_grow.sh
		run_test "max_growable" $rootdir/test/blobstore/blobstore_grow/max_growable.sh
		run_test "hello_blob" $SPDK_EXAMPLE_DIR/hello_blob \
			examples/blob/hello_world/hello_blob.json
		run_test "lvol" $rootdir/test/lvol/lvol.sh
+92 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash
#  SPDX-License-Identifier: BSD-3-Clause
#  All rights reserved.
#

testdir="$(readlink -f "$(dirname "$0")")"
rootdir=$(readlink -f "$testdir"/../../..)
source "$rootdir/test/common/autotest_common.sh"
rpc_py="$rootdir/scripts/rpc.py"

"$rootdir"/test/app/bdev_svc/bdev_svc &
bdev_svc_pid=$!

trap 'killprocess $bdev_svc_pid; exit 1' SIGINT SIGTERM EXIT

waitforlisten $bdev_svc_pid

# LVS, Bdev and aio disk all are cleaned up at the end of grow call.

# Ensures unique diskpath, bdev and lvs name at start.
disk_unique=$(uuidgen)
aio_disk="/tmp/$disk_unique.img"
bdev_name=$(uuidgen)
lvs_name=$(uuidgen)
block_size=512

function create_lvs() {
	size_bytes=$1
	truncate -s "$size_bytes" "$aio_disk"
	$rpc_py bdev_aio_create "$aio_disk" "$bdev_name" $block_size
	$rpc_py bdev_lvol_create_lvstore "$bdev_name" "$lvs_name" -c "$2" --md_pages_per_cluster_ratio="$3"
}

function grow_lvs() {
	# Get the max growable size of LVS.
	growable_upto=$($rpc_py bdev_lvol_get_lvstores -l "$lvs_name" | jq -r '.[0].max_growable_size')
	num_blocks=$($rpc_py bdev_get_bdevs -b "$bdev_name" | jq -r '.[0].num_blocks')
	current_size=$((num_blocks * block_size))
	cluster_size=$($rpc_py bdev_lvol_get_lvstores -l "$lvs_name" | jq -r '.[0].cluster_size')
	capacity_before=$(($($rpc_py bdev_lvol_get_lvstores -l "$lvs_name" \
		| jq -r '.[0].total_data_clusters') * cluster_size))
	# Grow the underlying device to the max growable size.
	truncate -s +$((growable_upto - current_size)) "$aio_disk"
	$rpc_py bdev_aio_rescan "$bdev_name"
	# Grow the LVS.
	$rpc_py bdev_lvol_grow_lvstore -l "$lvs_name"
	# Verify lvs capacity increase after successful grow.
	capacity_after=$(($($rpc_py bdev_lvol_get_lvstores -l "$lvs_name" \
		| jq -r '.[0].total_data_clusters') * cluster_size))
	[[ $capacity_after -gt $capacity_before ]] || {
		echo "Device size has not changed"
		exit 1
	}
	# max_growable_size is the absolute growable limit. Even 1 cluster worth of grow now should fail.
	truncate -s +"$cluster_size" "$aio_disk"
	$rpc_py bdev_aio_rescan "$bdev_name"
	NOT "$rpc_py" bdev_lvol_grow_lvstore -l "$lvs_name"
	# Verify lvs capacity remains same after grow fails.
	capacity_after_fail=$(($($rpc_py bdev_lvol_get_lvstores -l "$lvs_name" \
		| jq -r '.[0].total_data_clusters') * cluster_size))
	[[ $capacity_after_fail -eq $capacity_after ]] || {
		echo "Device size has changed"
		exit 1
	}
	# Cleanup lvs, bdev and disk.
	$rpc_py bdev_lvol_delete_lvstore -l "$lvs_name"
	$rpc_py bdev_aio_delete "$bdev_name"
	rm -f "$aio_disk"
}

# LVS backed by 100GiB device, 4MiB cluster size and 100 mum_md_pages_cluster_ratio.
create_lvs $((100 * 1024 * 1024 * 1024)) $((4 * 1024 * 1024)) 100
grow_lvs

# LVS backed by 200GiB device, 8MiB cluster size and 200 mum_md_pages_cluster_ratio.
create_lvs $((200 * 1024 * 1024 * 1024)) $((8 * 1024 * 1024)) 200
grow_lvs

# LVS backed by 300GiB device, 16MiB cluster size and 300 mum_md_pages_cluster_ratio.
create_lvs $((300 * 1024 * 1024 * 1024)) $((16 * 1024 * 1024)) 300
grow_lvs

# LVS backed by 500GiB device, 12MiB cluster size and 600 mum_md_pages_cluster_ratio.
create_lvs $((500 * 1024 * 1024 * 1024)) $((12 * 1024 * 1024)) 600
grow_lvs

# LVS backed by 1024GiB device, 254MiB cluster size and 800 mum_md_pages_cluster_ratio.
create_lvs $((1024 * 1024 * 1024 * 1024)) $((254 * 1024 * 1024)) 800
grow_lvs

killprocess $bdev_svc_pid
trap - SIGINT SIGTERM EXIT
+7 −6
Original line number Diff line number Diff line
@@ -3184,7 +3184,8 @@ bs_grow_live_no_space(void)
	struct spdk_bs_opts opts;
	struct spdk_bs_md_mask mask;
	uint64_t bdev_size_init;
	uint64_t total_data_clusters, max_clusters;
	uint64_t total_data_clusters;
	uint64_t beyond_max_growable_size;

	/*
	 * Further down the test the dev size will be larger than the g_dev_buffer size,
@@ -3219,12 +3220,12 @@ bs_grow_live_no_space(void)
	 * Blobstore in this test has only space for single md_page for used_clusters,
	 * which fits 1 bit per cluster minus the md header.
	 *
	 * Dev size is increased to exceed the reserved space for the used_cluster_mask
	 * in the metadata, expecting ENOSPC and no change in blobstore.
	 * Device size is set to one cluster beyond max_growable_size.
	 * The grow operation must fail with -ENOSPC, since the used_cluster_mask
	 * cannot track any additional clusters beyond the limit.
	 */
	max_clusters = (spdk_bs_get_page_size(bs) - sizeof(struct spdk_bs_md_mask)) * 8;
	max_clusters += 1;
	dev->blockcnt = (max_clusters * spdk_bs_get_cluster_size(bs)) / dev->blocklen;
	beyond_max_growable_size = spdk_bs_get_max_growable_size(bs) + spdk_bs_get_cluster_size(bs);
	dev->blockcnt = beyond_max_growable_size / dev->blocklen;
	spdk_bs_grow_live(bs, bs_op_complete, NULL);
	poll_threads();
	CU_ASSERT(g_bserrno == -ENOSPC);