From 42899f1a74f787afb2e560cd1046333803505fe3 Mon Sep 17 00:00:00 2001 From: Kozlowski Mateusz Date: Wed, 7 Sep 2022 18:22:15 +0200 Subject: [PATCH] FTL: rewrite restore tests to use spdk_dd Changing tests to using spdk_dd instead of using mounted nbd and dd on it. Should be faster. Signed-off-by: Kozlowski Mateusz Change-Id: I17ffeae8441ba37d8e3348c715889fb568e8cd88 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/14425 Reviewed-by: Jim Harris Reviewed-by: Ben Walker Tested-by: SPDK CI Jenkins --- test/common/skipped_tests.txt | 1 + test/ftl/ftl.sh | 2 +- test/ftl/restore.sh | 66 +++++++++++------------------------ 3 files changed, 23 insertions(+), 46 deletions(-) diff --git a/test/common/skipped_tests.txt b/test/common/skipped_tests.txt index 0d4836aa0..1c7eaab62 100644 --- a/test/common/skipped_tests.txt +++ b/test/common/skipped_tests.txt @@ -2,6 +2,7 @@ # cases ftl_dirty_shutdown +ftl_restore_fast ftl_fio_basic ftl_fio_extended ftl_fio_nightly diff --git a/test/ftl/ftl.sh b/test/ftl/ftl.sh index 1f58a13e3..6cc9e7dcc 100755 --- a/test/ftl/ftl.sh +++ b/test/ftl/ftl.sh @@ -71,10 +71,10 @@ if [[ -z $SPDK_TEST_FTL_NIGHTLY ]]; then run_test "ftl_fio_basic" $testdir/fio.sh $device $nv_cache basic run_test "ftl_bdevperf" $testdir/bdevperf.sh $device $nv_cache run_test "ftl_restore" $testdir/restore.sh -c $nv_cache $device - run_test "ftl_restore_fast" $testdir/restore.sh -f -c $nv_cache $device fi if [ $SPDK_TEST_FTL_EXTENDED -eq 1 ]; then + run_test "ftl_restore_fast" $testdir/restore.sh -f -c $nv_cache $device run_test "ftl_fio_extended" $testdir/fio.sh $device $nv_cache extended fi diff --git a/test/ftl/restore.sh b/test/ftl/restore.sh index 224bc4ad1..13302f7b4 100755 --- a/test/ftl/restore.sh +++ b/test/ftl/restore.sh @@ -22,16 +22,11 @@ device=$1 timeout=240 restore_kill() { - if mount | grep $mount_dir; then - umount $mount_dir - fi - rm -rf $mount_dir + rm -f $testdir/testfile rm -f $testdir/testfile.md5 - rm -f $testdir/testfile2.md5 rm -f $testdir/config/ftl.json killprocess $svcpid - rmmod nbd || true remove_shm } @@ -53,53 +48,34 @@ ftl_construct_args="bdev_ftl_create -b ftl0 -d $split_bdev --l2p_dram_limit $l2p [ -n "$uuid" ] && ftl_construct_args+=" -u $uuid" [ -n "$nv_cache" ] && ftl_construct_args+=" -c $nvc_bdev" -$rpc_py -t $timeout $ftl_construct_args - -# Load the nbd driver -modprobe nbd -$rpc_py nbd_start_disk ftl0 /dev/nbd0 -waitfornbd nbd0 - -$rpc_py save_config > $testdir/config/ftl.json - -# Prepare the disk by creating ext4 fs and putting a file on it -make_filesystem ext4 /dev/nbd0 -mount /dev/nbd0 $mount_dir -dd if=/dev/urandom of=$mount_dir/testfile bs=4K count=256K -sync -mount -o remount /dev/nbd0 $mount_dir -md5sum $mount_dir/testfile > $testdir/testfile.md5 -umount $mount_dir - -# Kill bdev service and start it again if [ "$fast_shutdown" -eq "1" ]; then - $rpc_py bdev_ftl_delete -b ftl0 --fast_shutdown -else - $rpc_py bdev_ftl_delete -b ftl0 + ftl_construct_args+=" --fast-shutdown" fi +$rpc_py -t $timeout $ftl_construct_args + +( + echo '{"subsystems": [' + $rpc_py save_subsystem_config -n bdev + echo ']}' +) > $testdir/config/ftl.json killprocess $svcpid -"$SPDK_BIN_DIR/spdk_tgt" -L ftl_init & -svcpid=$! -# Wait until spdk_tgt starts -waitforlisten $svcpid +# Generate random data and calculate checksum +dd if=/dev/urandom of=$testdir/testfile bs=4K count=256K +md5sum $testdir/testfile > $testdir/testfile.md5 -$rpc_py load_config < $testdir/config/ftl.json -waitfornbd nbd0 +# Write and read back the data, verifying checksum +"$SPDK_BIN_DIR/spdk_dd" --if=$testdir/testfile --ob=ftl0 --json=$testdir/config/ftl.json +"$SPDK_BIN_DIR/spdk_dd" --ib=ftl0 --of=$testdir/testfile --json=$testdir/config/ftl.json --count=262144 + +md5sum -c $testdir/testfile.md5 + +# Write second time at overlapped sectors, read back and verify checkum +"$SPDK_BIN_DIR/spdk_dd" --if=$testdir/testfile --ob=ftl0 --json=$testdir/config/ftl.json --seek=131072 +"$SPDK_BIN_DIR/spdk_dd" --ib=ftl0 --of=$testdir/testfile --json=$testdir/config/ftl.json --skip=131072 --count=262144 -mount /dev/nbd0 $mount_dir - -# Write second file, to make sure writer thread has restored properly -dd if=/dev/urandom of=$mount_dir/testfile2 bs=4K count=256K -md5sum $mount_dir/testfile2 > $testdir/testfile2.md5 - -# Make sure second file will be read from disk -echo 3 > /proc/sys/vm/drop_caches - -# Check both files have proper data md5sum -c $testdir/testfile.md5 -md5sum -c $testdir/testfile2.md5 trap - SIGINT SIGTERM EXIT restore_kill