fstests: detect btrfs compression and disable certain tests
[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 . ./common/preamble
15 _begin_fstest auto quick qgroup limit
16
17 # Import common functions.
18 . ./common/filter
19
20 writer()
21 {
22         # Wait for running fsstress subcommand before exitting so that
23         # mountpoint is not busy when we try to unmount it.
24         trap "wait; exit" SIGTERM
25
26         while true; do
27                 args=`_scale_fsstress_args -p 20 -n 1000 $FSSTRESS_AVOID -d $SCRATCH_MNT/stressdir`
28                 $FSSTRESS_PROG $args >/dev/null 2>&1
29         done
30 }
31
32 # real QA test starts here
33
34 _supported_fs btrfs
35
36 # This test requires specific data space usage, skip if we have compression
37 # enabled.
38 _require_no_compress
39
40 _require_scratch_size $((2 * 1024 * 1024))
41 _scratch_mkfs > /dev/null 2>&1
42 _scratch_mount
43
44 _pwrite_byte 0xcd 0 900m $SCRATCH_MNT/file >> $seqres.full
45 # Make sure the data reach disk so later qgroup scan can see it
46 sync
47
48 $BTRFS_UTIL_PROG quota enable $SCRATCH_MNT
49 $BTRFS_UTIL_PROG quota rescan -w $SCRATCH_MNT >> $seqres.full
50 # set the limit to 1 g, leaving us just 100mb of slack space
51 $BTRFS_UTIL_PROG qgroup limit 1G 0/5 $SCRATCH_MNT
52
53 writer &
54 writer_pid=$!
55
56 # Give time for the background thread to generate some load
57 sleep 30
58
59 kill $writer_pid
60 wait
61
62 # success, all done
63 echo "Silence is golden"
64 status=0
65 exit