2 # confirm that clearing space cache works
4 source "$TOP/tests/common"
7 check_prereq mkfs.btrfs
12 run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f "$TEST_DEV"
13 run_check_mount_test_dev
15 # Create files that takes at least 3 data chunks, while
16 # can still be removed to create free space inside one chunk.
18 for i in $(seq 0 6); do
19 run_check $SUDO_HELPER dd if=/dev/zero of="$TEST_MNT/file_${i}" bs=1M \
20 count=64 > /dev/null 2>&1
24 # Remove file 1 3 5 to create holes
26 run_check $SUDO_HELPER rm "$TEST_MNT/file_${i}"
31 run_check_umount_test_dev
33 # Clear space cache and re-check fs
34 run_check "$TOP/btrfs" check --clear-space-cache v1 "$TEST_DEV"
35 run_check "$TOP/btrfs" check "$TEST_DEV"
37 # Manually recheck space cache and super space cache generation
38 run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t root "$TEST_DEV" | \
41 _fail "clear space cache doesn't clear all space cache"
44 run_check_stdout $TOP/btrfs inspect-internal dump-super "$TEST_DEV" |
45 grep -q 'cache_generation.*18446744073709551615'
47 _fail "clear space cache doesn't set cache_generation correctly"