2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook. All Rights Reserved.
7 # Test restrictions on operations that can be done on an active swap file
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
32 _require_scratch_swapfile
34 _scratch_mkfs >> $seqres.full 2>&1
37 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/swapvol" >> $seqres.full
38 swapfile="$SCRATCH_MNT/swapvol/swap"
39 _format_swapfile "$swapfile" $(($(get_page_size) * 10))
42 # Turning off nocow doesn't do anything because the file is not empty, not
43 # because the file is a swap file, but make sure this works anyways.
45 $CHATTR_PROG -C "$swapfile"
46 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
48 # Compression we reject outright.
49 echo "Enable compression"
50 $CHATTR_PROG +c "$swapfile" 2>&1 | grep -o "Invalid argument while setting flags"
51 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
54 $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/swapvol" \
55 "$SCRATCH_MNT/swapsnap" 2>&1 | grep -o "Text file busy"
58 # We pass the -c (compress) flag to force defrag even if the file isn't
60 $BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"