"Fossies" - the Fresh Open Source Software Archive

Member "btrfs-progs-v5.4/tests/fsck-tests/024-clear-space-cache/test.sh" (3 Dec 2019, 1211 Bytes) of package /linux/misc/btrfs-progs-v5.4.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/bin/bash
    2 # confirm that clearing space cache works
    3 
    4 source "$TEST_TOP/common"
    5 
    6 check_prereq btrfs
    7 check_prereq mkfs.btrfs
    8 
    9 setup_root_helper
   10 prepare_test_dev
   11 
   12 run_check_mkfs_test_dev
   13 run_check_mount_test_dev
   14 
   15 # Create files that takes at least 3 data chunks, while
   16 # can still be removed to create free space inside one chunk.
   17 
   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
   21 done
   22 sync
   23 
   24 # Remove file 1 3 5 to create holes
   25 for i in 1 3 5; do
   26     run_check $SUDO_HELPER rm "$TEST_MNT/file_${i}"
   27 done
   28 
   29 sync
   30 
   31 run_check_umount_test_dev
   32 
   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"
   36 
   37 # Manually recheck space cache and super space cache generation
   38 run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t root "$TEST_DEV" | \
   39     grep -q FREE_SPACE
   40 if [ $? -eq 0 ]; then
   41     _fail "clear space cache doesn't clear all space cache"
   42 fi
   43 
   44 run_check_stdout $TOP/btrfs inspect-internal dump-super "$TEST_DEV" |
   45     grep -q 'cache_generation.*18446744073709551615'
   46 if [ $? -ne 0 ]; then
   47     _fail "clear space cache doesn't set cache_generation correctly"
   48 fi