diff options
author | Qu Wenruo <quwenruo@cn.fujitsu.com> | 2016-10-13 17:22:27 +0800 |
---|---|---|
committer | David Sterba <dsterba@suse.com> | 2016-11-09 13:12:49 +0100 |
commit | 40de2f62793ad54a91755edb301f2609121137e4 (patch) | |
tree | 1b704b384def25f1b0d3b9c79b4b194236004e64 /tests/fsck-tests/024-clear-space-cache | |
parent | eb8a61b235ad035cc474bef78e10453ec3d11d72 (diff) |
btrfs-progs: fsck-tests: Check if clear space cache works
Add test case to check the basic function of --clear-space-cache.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tests/fsck-tests/024-clear-space-cache')
-rwxr-xr-x | tests/fsck-tests/024-clear-space-cache/test.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/fsck-tests/024-clear-space-cache/test.sh b/tests/fsck-tests/024-clear-space-cache/test.sh new file mode 100755 index 00000000..2945ae87 --- /dev/null +++ b/tests/fsck-tests/024-clear-space-cache/test.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# confirm that clearing space cache works + +source $TOP/tests/common + +check_prereq btrfs +check_prereq mkfs.btrfs + +setup_root_helper +prepare_test_dev 1G + +run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $TEST_DEV +run_check_mount_test_dev + +# Create files that takes at least 3 data chunks, while +# can still be removed to create free space inside one chunk. + +for i in $(seq 0 6); do + run_check $SUDO_HELPER dd if=/dev/zero of=$TEST_MNT/file_${i} bs=1M \ + count=64 > /dev/null 2>&1 +done +sync + +# Remove file 1 3 5 to create holes +for i in 1 3 5; do + run_check $SUDO_HELPER rm $TEST_MNT/file_${i} +done + +sync + +run_check_umount_test_dev + +# Clear space cache and re-check fs +run_check $TOP/btrfs check --clear-space-cache v1 $TEST_DEV +run_check $TOP/btrfs check $TEST_DEV + +# Manually recheck space cache and super space cache generation +run_check_stdout $TOP/btrfs inspect-internal dump-tree -t root $TEST_DEV | \ + grep -q FREE_SPACE +if [ $? -eq 0 ]; then + _fail "clear space cache doesn't clear all space cache" +fi + +run_check_stdout $TOP/btrfs inspect-internal dump-super $TEST_DEV | + grep -q 'cache_generation.*18446744073709551615' +if [ $? -ne 0 ]; then + _fail "clear space cache doesn't set cache_generation correctly" +fi |