Skip to content

Commit fdd3e53

Browse files
naotakdave
authored andcommitted
btrfs-progs: tests: add new mkfs test for zoned device
This new test is based on mkfs-tests/001-basic-profiles, and it goes through the profiles to mkfs and do some basic checks for zoned devices. Reviewed-by: Qu Wenruo <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent b7bb579 commit fdd3e53

File tree

1 file changed

+100
-0
lines changed
  • tests/mkfs-tests/039-zoned-profiles

1 file changed

+100
-0
lines changed
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
# Test various block group profile combinations, use nullb devices as block
3+
# devices. This test is based on mkfs-tests/001-basic-profiles with focus on
4+
# zoned devices.
5+
6+
source "$TEST_TOP/common" || exit
7+
8+
check_prereq mkfs.btrfs
9+
check_prereq btrfs
10+
check_global_prereq blkzone
11+
12+
setup_root_helper
13+
# Create one 128M device with 4M zones, 32 of them
14+
setup_nullbdevs 4 128 4
15+
prepare_nullbdevs
16+
dev1=${nullb_devs[1]}
17+
18+
test_get_info()
19+
{
20+
local tmp_out
21+
22+
tmp_out=$(_mktemp mkfs-get-info)
23+
run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dev1"
24+
run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1"
25+
26+
# Work around for kernel bug that will treat SINGLE and single
27+
# device RAID0 as the same.
28+
# Thus kernel may create new SINGLE chunks, causing extra warning
29+
# when testing single device RAID0.
30+
wait_for_nullbdevs
31+
run_check $SUDO_HELPER mount -o ro "$dev1" "$TEST_MNT"
32+
run_check_stdout "$TOP/btrfs" filesystem df "$TEST_MNT" > "$tmp_out"
33+
if grep -q "Multiple block group profiles detected" "$tmp_out"; then
34+
rm -- "$tmp_out"
35+
_fail "temporary chunks are not properly cleaned up"
36+
fi
37+
rm -- "$tmp_out"
38+
run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT"
39+
run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT"
40+
run_check $SUDO_HELPER umount "$TEST_MNT"
41+
}
42+
43+
test_do_mkfs()
44+
{
45+
run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@"
46+
if run_check_stdout $SUDO_HELPER "$TOP/btrfs" check "$dev1" | grep -iq warning; then
47+
_fail "warnings found in check output"
48+
fi
49+
}
50+
51+
test_mkfs_single()
52+
{
53+
test_do_mkfs "$@" "$dev1"
54+
test_get_info
55+
}
56+
57+
test_mkfs_multi()
58+
{
59+
test_do_mkfs "$@" "${nullb_devs[@]}"
60+
test_get_info
61+
}
62+
63+
test_mkfs_single
64+
test_mkfs_single -d single -m single
65+
test_mkfs_single -d single -m dup
66+
67+
test_mkfs_multi
68+
test_mkfs_multi -d single -m single
69+
70+
if _test_config "EXPERIMENTAL" && [ -f "/sys/fs/btrfs/features/raid_stripe_tree" ]; then
71+
test_mkfs_single -d dup -m single
72+
test_mkfs_single -d dup -m dup
73+
74+
test_mkfs_multi -d raid0 -m raid0
75+
test_mkfs_multi -d raid1 -m raid1
76+
test_mkfs_multi -d raid10 -m raid10
77+
# RAID5/6 are not yet supported.
78+
# test_mkfs_multi -d raid5 -m raid5
79+
# test_mkfs_multi -d raid6 -m raid6
80+
test_mkfs_multi -d dup -m dup
81+
82+
if [ -f "/sys/fs/btrfs/features/raid1c34" ]; then
83+
test_mkfs_multi -d raid1c3 -m raid1c3
84+
test_mkfs_multi -d raid1c4 -m raid1c4
85+
else
86+
_log "skip mount test, missing support for raid1c34"
87+
test_do_mkfs -d raid1c3 -m raid1c3 "${nullb_devs[@]}"
88+
test_do_mkfs -d raid1c4 -m raid1c4 "${nullb_devs[@]}"
89+
fi
90+
91+
# Non-standard profile/device combinations
92+
93+
# Single device raid0, two device raid10 (simple mount works on older kernels too)
94+
test_do_mkfs -d raid0 -m raid0 "$dev1"
95+
test_get_info
96+
test_do_mkfs -d raid10 -m raid10 "${nullb_devs[1]}" "${nullb_devs[2]}"
97+
test_get_info
98+
fi
99+
100+
cleanup_nullbdevs

0 commit comments

Comments
 (0)