test/dd: Simple tests utilizing uring RPCs
Signed-off-by: Michal Berger <michalx.berger@intel.com> Change-Id: If9c5d0071d30b3a5ac40ea5085dbf564b98cb667 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/9947 Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
eb77d6394e
commit
1fdfb7e332
@ -159,3 +159,30 @@ check_liburing() {
|
|||||||
fi
|
fi
|
||||||
done < <(LD_TRACE_LOADED_OBJECTS=1 "${DD_APP[@]}") >&2
|
done < <(LD_TRACE_LOADED_OBJECTS=1 "${DD_APP[@]}") >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
init_zram() {
|
||||||
|
[[ -e /sys/class/zram-control ]] || modprobe zram num_devices=0
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
create_zram_dev() {
|
||||||
|
cat /sys/class/zram-control/hot_add
|
||||||
|
}
|
||||||
|
|
||||||
|
remove_zram_dev() {
|
||||||
|
local id=$1
|
||||||
|
|
||||||
|
[[ -e /sys/block/zram$id ]]
|
||||||
|
|
||||||
|
echo 1 > "/sys/block/zram$id/reset"
|
||||||
|
echo "$id" > "/sys/class/zram-control/hot_remove"
|
||||||
|
}
|
||||||
|
|
||||||
|
set_zram_dev() {
|
||||||
|
local id=$1
|
||||||
|
local size=${2:-64M}
|
||||||
|
|
||||||
|
[[ -e /sys/block/zram$id ]]
|
||||||
|
|
||||||
|
echo "$size" > "/sys/block/zram$id/disksize"
|
||||||
|
}
|
||||||
|
@ -17,3 +17,6 @@ run_test "spdk_dd_basic_rw" "$testdir/basic_rw.sh" "${nvmes[@]}"
|
|||||||
run_test "spdk_dd_posix" "$testdir/posix.sh"
|
run_test "spdk_dd_posix" "$testdir/posix.sh"
|
||||||
run_test "spdk_dd_malloc" "$testdir/malloc.sh"
|
run_test "spdk_dd_malloc" "$testdir/malloc.sh"
|
||||||
run_test "spdk_dd_bdev_to_bdev" "$testdir/bdev_to_bdev.sh" "${nvmes[@]}"
|
run_test "spdk_dd_bdev_to_bdev" "$testdir/bdev_to_bdev.sh" "${nvmes[@]}"
|
||||||
|
if ((SPDK_TEST_URING == 1)); then
|
||||||
|
run_test "spdk_dd_uring" "$testdir/uring.sh"
|
||||||
|
fi
|
||||||
|
98
test/dd/uring.sh
Executable file
98
test/dd/uring.sh
Executable file
@ -0,0 +1,98 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
testdir=$(readlink -f "$(dirname "$0")")
|
||||||
|
rootdir=$(readlink -f "$testdir/../../")
|
||||||
|
source "$testdir/common.sh"
|
||||||
|
|
||||||
|
uring_zram_copy() {
|
||||||
|
# Use zram for backend device - this is done in order to make the IO as fast
|
||||||
|
# as possible.
|
||||||
|
|
||||||
|
local zram_dev_id
|
||||||
|
local magic
|
||||||
|
local magic_file0=$SPDK_TEST_STORAGE/magic.dump0
|
||||||
|
local magic_file1=$SPDK_TEST_STORAGE/magic.dump1
|
||||||
|
local verify_magic
|
||||||
|
|
||||||
|
init_zram
|
||||||
|
zram_dev_id=$(create_zram_dev)
|
||||||
|
set_zram_dev "$zram_dev_id" 512M
|
||||||
|
|
||||||
|
local ubdev=uring0 ufile=/dev/zram$zram_dev_id
|
||||||
|
|
||||||
|
local -A method_bdev_uring_create_0=(
|
||||||
|
["filename"]=$ufile
|
||||||
|
["name"]=$ubdev
|
||||||
|
)
|
||||||
|
|
||||||
|
# Add extra malloc bdev
|
||||||
|
local mbdev=malloc0 mbdev_b=1048576 mbdev_bs=512
|
||||||
|
|
||||||
|
local -A method_bdev_malloc_create_0=(
|
||||||
|
["name"]=$mbdev
|
||||||
|
["num_blocks"]=$mbdev_b
|
||||||
|
["block_size"]=$mbdev_bs
|
||||||
|
)
|
||||||
|
|
||||||
|
magic=$(gen_bytes $((mbdev_bs * 2)))
|
||||||
|
echo "$magic" > "$magic_file0"
|
||||||
|
|
||||||
|
# Inflate the magic file to fill up entire zram of 512MB.
|
||||||
|
"${DD_APP[@]}" \
|
||||||
|
--if=/dev/zero \
|
||||||
|
--of="$magic_file0" \
|
||||||
|
--oflag=append \
|
||||||
|
--bs=$((mbdev_b * mbdev_bs - ${#magic} - 1)) \
|
||||||
|
--count=1
|
||||||
|
|
||||||
|
# Copy magic file to uring bdev
|
||||||
|
"${DD_APP[@]}" \
|
||||||
|
--if="$magic_file0" \
|
||||||
|
--ob="$ubdev" \
|
||||||
|
--json <(gen_conf)
|
||||||
|
|
||||||
|
# Copy the whole uring bdev back to a file
|
||||||
|
"${DD_APP[@]}" \
|
||||||
|
--ib="$ubdev" \
|
||||||
|
--of="$magic_file1" \
|
||||||
|
--json <(gen_conf)
|
||||||
|
|
||||||
|
# Verify integrity of each copy
|
||||||
|
read -rn${#magic} verify_magic < "$magic_file1"
|
||||||
|
[[ $verify_magic == "$magic" ]]
|
||||||
|
|
||||||
|
read -rn${#magic} verify_magic < "/dev/zram$zram_dev_id"
|
||||||
|
[[ $verify_magic == "$magic" ]]
|
||||||
|
|
||||||
|
diff -q "$magic_file0" "$magic_file1"
|
||||||
|
|
||||||
|
# Copy cotents of uring bdev to malloc bdev
|
||||||
|
"${DD_APP[@]}" \
|
||||||
|
--ib="$ubdev" \
|
||||||
|
--ob="$mbdev" \
|
||||||
|
--json <(gen_conf)
|
||||||
|
|
||||||
|
# HACK: small trick to utilize bdev_uring_delete and keep spdk_dd happy -
|
||||||
|
# read/write from 0-length files.
|
||||||
|
|
||||||
|
local -A method_bdev_uring_delete_0=(
|
||||||
|
["name"]="$ubdev"
|
||||||
|
)
|
||||||
|
|
||||||
|
"${DD_APP[@]}" \
|
||||||
|
--if=<(:) \
|
||||||
|
--of=<(:) \
|
||||||
|
--json <(gen_conf)
|
||||||
|
|
||||||
|
# Now try to copy to uring bdev which is explicitly deleted. We expect it
|
||||||
|
# to fail.
|
||||||
|
|
||||||
|
NOT "${DD_APP[@]}" \
|
||||||
|
--ib="$ubdev" \
|
||||||
|
--of=<(:) \
|
||||||
|
--json <(gen_conf)
|
||||||
|
|
||||||
|
remove_zram_dev "$zram_dev_id"
|
||||||
|
rm -f "$magic_file0" "$magic_file1"
|
||||||
|
}
|
||||||
|
|
||||||
|
run_test "dd_uring_copy" uring_zram_copy
|
Loading…
Reference in New Issue
Block a user