From 163aa3cc62b416a55971a9aad40c94bcc9a87422 Mon Sep 17 00:00:00 2001 From: David Sterba Date: Fri, 23 Sep 2022 00:54:51 +0200 Subject: [PATCH] btrfs-progs: tests: add mkfs/025 to test parallel zone reset Create a few emulated zoned devices and run mkfs, the zone reset is expected to be run in parallel. It's using memory-backed devices so it's too fast to measure the differences and we can't expect availability of slow zoned devices so this test is very simplistic. Signed-off-by: David Sterba --- tests/mkfs-tests/025-zoned-parallel/test.sh | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100755 tests/mkfs-tests/025-zoned-parallel/test.sh diff --git a/tests/mkfs-tests/025-zoned-parallel/test.sh b/tests/mkfs-tests/025-zoned-parallel/test.sh new file mode 100755 index 00000000..3bca214b --- /dev/null +++ b/tests/mkfs-tests/025-zoned-parallel/test.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Test parallel reset of zones. +# Needs kernel modules: null_blk, configfs and at least 2G of free memory for +# the devices + +source "$TEST_TOP/common" + +setup_root_helper +prepare_test_dev + +if ! check_min_kernel_version 5.12; then + _not_run "zoned tests need kernel 5.12 and newer" +fi + +nullb="$TEST_TOP/nullb" +# Create 128M devices with 4M zones, 32 of them +size=128 +zone=4 +# More than 10 may fail +count=10 + +declare -a devices +declare -a names + +run_check $SUDO_HELPER "$nullb" setup +if [ $? != 0 ]; then + _not_run "cannot setup nullb environment for zoned devices" +fi + +# Record any other pre-existing devices in case creation fails +run_check $SUDO_HELPER "$nullb" ls + +for i in `seq $count`; do + # Last line has the name of the device node path + out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$size" -z "$zone") + if [ $? != 0 ]; then + _fail "cannot create nullb zoned device $i" + fi + devices[$i]=$(echo "$out" | tail -n 1) + names[$i]=$(basename "${devices[$i]}") +done + +run_check $SUDO_HELPER "$nullb" ls + +TEST_DEV="${devices[1]}" +# Use single as it's supported on more kernels +run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -d single -m single "${devices[@]}" +run_check_mount_test_dev +run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file bs=1M count=1 +run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT" +run_check_umount_test_dev + +for i in `seq $count`; do + run_check $SUDO_HELPER "$nullb" rm "${names[$i]}" +done