From 10a7c0eda57a0ab8be1337084bc926610a4d0224 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 20 May 2022 09:31:51 +0800 Subject: [PATCH] btrfs-progs: tests: make sure we don't create bitmaps for empty fs Add test case is to make sure on a relative large empty fs, we won't create bitmaps to unnecessarily increase the size of free space tree. Signed-off-by: Qu Wenruo Signed-off-by: David Sterba --- tests/mkfs-tests/024-fst-bitmaps/test.sh | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 tests/mkfs-tests/024-fst-bitmaps/test.sh diff --git a/tests/mkfs-tests/024-fst-bitmaps/test.sh b/tests/mkfs-tests/024-fst-bitmaps/test.sh new file mode 100755 index 00000000..7fccee66 --- /dev/null +++ b/tests/mkfs-tests/024-fst-bitmaps/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Basic check if mkfs supports the runtime feature free-space-tree + +source "$TEST_TOP/common" + +check_prereq mkfs.btrfs +check_prereq btrfs + +setup_root_helper + +setup_loopdevs 4 +prepare_loopdevs +dev1=${loopdevs[1]} +tmp=$(_mktemp fst-bitmap) + +test_do_mkfs() +{ + run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$@" + if run_check_stdout "$TOP/btrfs" check "$dev1" | grep -iq warning; then + _fail "warnings found in check output" + fi +} + +test_do_mkfs -m raid1 -d raid0 ${loopdevs[@]} + +run_check_stdout $SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree \ + -t free_space "$dev1" > "$tmp.dump-tree" +cleanup_loopdevs + +if grep -q FREE_SPACE_BITMAP "$tmp.dump-tree"; then + rm -f -- "$tmp*" + _fail "free space bitmap should not be created for empty fs" +fi +rm -f -- "$tmp*"