xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 174
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2018 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 174
6 #
7 # Test restrictions on operations that can be done on an active swap file
8 # specific to Btrfs.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
18
19 _cleanup()
20 {
21         cd /
22         rm -f $tmp.*
23 }
24
25 . ./common/rc
26 . ./common/filter
27
28 rm -f $seqres.full
29
30 _supported_fs btrfs
31 _require_scratch_swapfile
32
33 _scratch_mkfs >> $seqres.full 2>&1
34 _scratch_mount
35
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))
39 swapon "$swapfile"
40
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.
43 echo "Disable nocow"
44 $CHATTR_PROG -C "$swapfile"
45 $LSATTR_PROG -l "$swapfile" | _filter_scratch | _filter_spaces
46
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
51
52 echo "Snapshot"
53 $BTRFS_UTIL_PROG subvolume snapshot "$SCRATCH_MNT/swapvol" \
54         "$SCRATCH_MNT/swapsnap" 2>&1 | grep -o "Text file busy"
55
56 echo "Defrag"
57 # We pass the -c (compress) flag to force defrag even if the file isn't
58 # fragmented.
59 $BTRFS_UTIL_PROG filesystem defrag -c "$swapfile" 2>&1 | grep -o "Text file busy"
60
61 swapoff "$swapfile"
62 _scratch_unmount
63
64 status=0
65 exit