From 6e888a7a6cff94ed67b3485f1593e20fde06e442 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Mon, 11 Oct 2021 17:43:00 +0800 Subject: [PATCH] btrfs-progs: tests: make sure mkfs.btrfs cleans up temporary chunks Since current "btrfs filesystem df" command will warn if there are multiple profiles of the same type, it's a good way to detect left-over temporary chunks. Enhance the existing mkfs-tests/001-basic-profiles test case to also check for the warning messages, to make sure mkfs.btrfs has properly cleaned up all temporary chunks. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- tests/mkfs-tests/001-basic-profiles/test.sh | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/tests/mkfs-tests/001-basic-profiles/test.sh b/tests/mkfs-tests/001-basic-profiles/test.sh index b3ba50d7..5beaf428 100755 --- a/tests/mkfs-tests/001-basic-profiles/test.sh +++ b/tests/mkfs-tests/001-basic-profiles/test.sh @@ -11,10 +11,23 @@ setup_root_helper test_get_info() { + local tmp_out + + tmp_out=$(mktemp --tmpdir btrfs-progs-mkfs-tests-get-info.XXXXXX) run_check $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-super "$dev1" run_check $SUDO_HELPER "$TOP/btrfs" check "$dev1" - run_check $SUDO_HELPER mount "$dev1" "$TEST_MNT" - run_check "$TOP/btrfs" filesystem df "$TEST_MNT" + + # Work around for kernel bug that will treat SINGLE and single + # device RAID0 as the same. + # Thus kernel may create new SINGLE chunks, causing extra warning + # when testing single device RAID0. + run_check $SUDO_HELPER mount -o ro "$dev1" "$TEST_MNT" + run_check_stdout "$TOP/btrfs" filesystem df "$TEST_MNT" > "$tmp_out" + if grep -q "Multiple block group profiles detected" "$tmp_out"; then + rm -- "$tmp_out" + _fail "temporary chunks are not properly cleaned up" + fi + rm -- "$tmp_out" run_check $SUDO_HELPER "$TOP/btrfs" filesystem usage "$TEST_MNT" run_check $SUDO_HELPER "$TOP/btrfs" device usage "$TEST_MNT" run_check $SUDO_HELPER umount "$TEST_MNT"