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
31 _require_scratch_swapfile
33 _scratch_mkfs >> $seqres.full 2>&1
36 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/swapvol" >> $seqres.full
37 swapfile="$SCRATCH_MNT/swapvol/swap"
38 _format_swapfile "$swapfile" $(($(get_page_size) * 10))
41 # Turning off nocow doesn't do anything because the file is not empty, not
42 # because the file is a swap file, but make sure this works anyways.
44 $CHATTR_PROG -C "$swapfile"
45 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
47 # Compression we reject outright.
48 echo "Enable compression"
49 $CHATTR_PROG +c "$swapfile" 2>&1 | grep -o "Invalid argument while setting flags"
50 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
53 $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/swapvol" \
54 "$SCRATCH_MNT/swapsnap" 2>&1 | grep -o "Text file busy"
57 # We pass the -c (compress) flag to force defrag even if the file isn't
59 $BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"