test/ftl: use spdk_dd in dirty_shutdown test

Use spdk_dd instead of plain dd to reduce test
execution time.

Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Change-Id: I54979b68b3c328aa9618e704e2bc55e794aa232c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/15524
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Mateusz Kozlowski <mateusz.kozlowski@intel.com>
Reviewed-by: Krzysztof Karas <krzysztof.karas@intel.com>
Reviewed-by: Pawel Piatek <pawelx.piatek@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
This commit is contained in:
Karol Latecki 2022-11-18 12:13:02 +01:00 committed by Tomasz Zawadzki
parent e8f8453120
commit 25f4d23517

View File

@ -6,6 +6,7 @@ source $rootdir/test/common/autotest_common.sh
source $testdir/common.sh
rpc_py=$rootdir/scripts/rpc.py
spdk_dd="$SPDK_BIN_DIR/spdk_dd"
while getopts ':u:c:' opt; do
case $opt in
@ -19,6 +20,7 @@ shift $((OPTIND - 1))
device=$1
timeout=240
block_size=4096
chunk_size=262144
data_size=$((chunk_size * 2))
@ -36,7 +38,7 @@ restore_kill() {
trap "restore_kill; exit 1" SIGINT SIGTERM EXIT
"$SPDK_BIN_DIR/spdk_tgt" &
"$SPDK_BIN_DIR/spdk_tgt" -m 0x1 &
svcpid=$!
# Wait until spdk_tgt starts
waitforlisten $svcpid
@ -67,9 +69,9 @@ $rpc_py nbd_start_disk ftl0 /dev/nbd0
waitfornbd nbd0
# Write and calculate checksum of the data written
dd if=/dev/urandom of=$testdir/testfile bs=4K count=$data_size
$spdk_dd -m 0x2 -r /var/tmp/spdk_dd.sock --if=/dev/urandom --of=$testdir/testfile --bs=$block_size --count=$data_size
md5sum $testdir/testfile > $testdir/testfile.md5
dd if=$testdir/testfile of=/dev/nbd0 bs=4K count=$data_size oflag=dsync
$spdk_dd -m 0x2 -r /var/tmp/spdk_dd.sock --if=$testdir/testfile --of=/dev/nbd0 --bs=$block_size --count=$data_size --oflag=dsync
$rpc_py nbd_stop_disk /dev/nbd0
# Force kill bdev service (dirty shutdown) and start it again
@ -77,15 +79,15 @@ kill -9 $svcpid
rm -f /dev/shm/spdk_tgt_trace.pid$svcpid
# Write extra data after restore
dd if=/dev/urandom of=$testdir/testfile2 bs=4K count=$chunk_size
"$SPDK_BIN_DIR/spdk_dd" --if=$testdir/testfile2 --ob=ftl0 --count=$chunk_size --seek=$data_size --json=$testdir/config/ftl.json
$spdk_dd --if=/dev/urandom --of=$testdir/testfile2 --bs=$block_size --count=$chunk_size
$spdk_dd --if=$testdir/testfile2 --ob=ftl0 --count=$chunk_size --seek=$data_size --json=$testdir/config/ftl.json
# Save md5 data
md5sum $testdir/testfile2 > $testdir/testfile2.md5
# Verify that the checksum matches and the data is consistent
"$SPDK_BIN_DIR/spdk_dd" --ib=ftl0 --of=$testdir/testfile --count=$data_size --json=$testdir/config/ftl.json
$spdk_dd --ib=ftl0 --of=$testdir/testfile --count=$data_size --json=$testdir/config/ftl.json
md5sum -c $testdir/testfile.md5
"$SPDK_BIN_DIR/spdk_dd" --ib=ftl0 --of=$testdir/testfile2 --count=$chunk_size --skip=$data_size --json=$testdir/config/ftl.json
$spdk_dd --ib=ftl0 --of=$testdir/testfile2 --count=$chunk_size --skip=$data_size --json=$testdir/config/ftl.json
md5sum -c $testdir/testfile2.md5
trap - SIGINT SIGTERM EXIT