Skip to content

Commit 3fabe8e

Browse files
adam900710kdave
authored andcommitted
btrfs-progs: tests: add a test case to check zoned bgt conversion
Add a new test case to make sure: - btrfstune can convert a zoned btrfs with extent tree to bgt - btrfstune can convert a zoned btrfs with bgt back to extent tree Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Naohiro Aota <[email protected]> Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent dd250be commit 3fabe8e

File tree

1 file changed

+55
-0
lines changed
  • tests/misc-tests/063-btrfstune-zoned-bgt

1 file changed

+55
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Verify btrfstune for zoned devices with block-group-tree conversion
3+
4+
source "$TEST_TOP/common" || exit
5+
6+
setup_root_helper
7+
prepare_test_dev
8+
9+
nullb="$TEST_TOP/nullb"
10+
# Create one 128M device with 4M zones, 32 of them
11+
size=128
12+
zone=4
13+
14+
run_mayfail $SUDO_HELPER "$nullb" setup
15+
if [ $? != 0 ]; then
16+
_not_run "cannot setup nullb environment for zoned devices"
17+
fi
18+
19+
# Record any other pre-existing devices in case creation fails
20+
run_check $SUDO_HELPER "$nullb" ls
21+
22+
# Last line has the name of the device node path
23+
out=$(run_check_stdout $SUDO_HELPER "$nullb" create -s "$size" -z "$zone")
24+
if [ $? != 0 ]; then
25+
_fail "cannot create nullb zoned device $i"
26+
fi
27+
dev=$(echo "$out" | tail -n 1)
28+
name=$(basename "${dev}")
29+
30+
run_check $SUDO_HELPER "$nullb" ls
31+
32+
TEST_DEV="${dev}"
33+
34+
# Create the fs without bgt
35+
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f -m single -d single -O ^block-group-tree "${dev}"
36+
run_check_mount_test_dev
37+
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file1 bs=1M count=1
38+
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT"
39+
run_check_umount_test_dev
40+
41+
# Convert to bgt
42+
run_check $SUDO_HELPER "$TOP/btrfstune" --convert-to-block-group-tree "${dev}"
43+
run_check_mount_test_dev
44+
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file2 bs=1M count=1
45+
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT"
46+
run_check_umount_test_dev
47+
48+
# And convert back to old extent tree
49+
run_check $SUDO_HELPER "$TOP/btrfstune" --convert-from-block-group-tree "${dev}"
50+
run_check_mount_test_dev
51+
run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT"/file3 bs=1M count=1
52+
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage -T "$TEST_MNT"
53+
run_check_umount_test_dev
54+
55+
run_check $SUDO_HELPER "$nullb" rm "${name}"

0 commit comments

Comments
 (0)