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 _begin_fstest auto quick swap
16 _require_scratch_swapfile
18 _scratch_mkfs >> $seqres.full 2>&1
21 $BTRFS_UTIL_PROG subvolume create "$SCRATCH_MNT/swapvol" >> $seqres.full
22 swapfile="$SCRATCH_MNT/swapvol/swap"
23 _format_swapfile "$swapfile" $(($(get_page_size) * 10))
26 # Turning off nocow doesn't do anything because the file is not empty, not
27 # because the file is a swap file, but make sure this works anyways.
29 $CHATTR_PROG -C "$swapfile"
30 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
32 # Compression we reject outright.
33 echo "Enable compression"
34 $CHATTR_PROG +c "$swapfile" 2>&1 | grep -o "Invalid argument while setting flags"
35 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
38 $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/swapvol" \
39 "$SCRATCH_MNT/swapsnap" 2>&1 | grep -o "Text file busy"
42 # We pass the -c (compress) flag to force defrag even if the file isn't
44 $BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"