xfs: Check for extent overflow when trivally adding a new extent
[xfstests-dev.git] / tests / btrfs / 232
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 SUSE Linux Products GmbH. All Rights Reserved.
4 #
5 # FS QA Test 232
6 #
7 # Test that performing io and exhausting qgroup limit won't deadlock. This
8 # exercises issues fixed by the following kernel commits:
9 #
10 # 4f6a49de64fd ("btrfs: unlock extents in btrfs_zero_range in case of quota
11 # reservation errors")
12 # 4d14c5cde5c2 ("btrfs: don't flush from btrfs_delayed_inode_reserve_metadata")
13 #
14 seq=`basename $0`
15 seqres=$RESULT_DIR/$seq
16 echo "QA output created by $seq"
17
18 here=`pwd`
19 tmp=/tmp/$$
20 status=1        # failure is the default!
21 trap "_cleanup; exit \$status" 0 1 2 3 15
22
23 _cleanup()
24 {
25         cd /
26         rm -f $tmp.*
27 }
28
29 # get standard environment, filters and checks
30 . ./common/rc
31 . ./common/filter
32
33 writer()
34 {
35         # Wait for running fsstress subcommand before exitting so that
36         # mountpoint is not busy when we try to unmount it.
37         trap "wait; exit" SIGTERM
38
39         while true; do
40                 args=`_scale_fsstress_args -p 20 -n 1000 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
41                 $FSSTRESS_PROG $args >/dev/null 2>&1
42         done
43 }
44
45 # remove previous $seqres.full before test
46 rm -f $seqres.full
47
48 # real QA test starts here
49
50 _supported_fs btrfs
51
52 _require_scratch_size $((2 * 1024 * 1024))
53 _scratch_mkfs > /dev/null 2>&1
54 _scratch_mount
55
56 _pwrite_byte 0xcd 0 900m $SCRATCH_MNT/file >> $seqres.full
57 # Make sure the data reach disk so later qgroup scan can see it
58 sync
59
60 $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
61 $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
62 # set the limit to 1 g, leaving us just 100mb of slack space
63 $BTRFS_UTIL_PROG qgroup limit 1G 0/5 $SCRATCH_MNT
64
65 writer &
66 writer_pid=$!
67
68 # Give time for the background thread to generate some load
69 sleep 30
70
71 kill $writer_pid
72 wait
73
74 # success, all done
75 echo "Silence is golden"
76 status=0
77 exit