generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / btrfs / 099
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2015 Fujitsu. All Rights Reserved.
4 #
5 # FS QA Test 099
6 #
7 # Check for qgroup reserved space leaks caused by re-writing dirty ranges
8 # This bug has been present in btrfs qgroup for a long time
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 # get standard environment, filters and checks
26 . ./common/rc
27 . ./common/filter
28
29 # real QA test starts here
30
31 _supported_fs btrfs
32 _require_scratch
33 _require_btrfs_qgroup_report
34
35 # Use big blocksize to ensure there is still enough space left for metadata
36 # space reserve.
37 BLOCKSIZE=$(( 2 * 1024 * 1024 )) # 2M block size
38 FILESIZE=$(( 128 * 1024 * 1024 )) # 128M file size
39
40 rm -f $seqres.full
41
42 _scratch_mkfs >> $seqres.full 2>&1
43 _scratch_mount
44 _require_fs_space $SCRATCH_MNT $(($FILESIZE * 2 / 1024))
45
46 _run_btrfs_util_prog quota enable $SCRATCH_MNT
47 _run_btrfs_util_prog qgroup limit $FILESIZE 5 $SCRATCH_MNT
48
49 # loop 5 times without sync to ensure reserved space leak will happen
50 for i in `seq 1 5`; do
51         # Use 1/4 of the file size, to ensure even commit is trigger by
52         # dirty page threshold or commit interval, we should still be
53         # able to continue write
54         $XFS_IO_PROG -f -c "pwrite -b $BLOCKSIZE 0 $(($FILESIZE / 4))" \
55                 $SCRATCH_MNT/foo | _filter_xfs_io
56 done
57
58 # Sync to make sure all the dirty pages are written to disk, which should
59 # free all the reserved space
60 sync
61
62 # remove the file and sync, to ensure all quota space freed
63 rm $SCRATCH_MNT/foo
64 sync
65
66 # We should be able to write $FILESIZE - $BLOCKSIZE data now
67 $XFS_IO_PROG -f -c "pwrite -b $BLOCKSIZE 0 $(($FILESIZE - $BLOCKSIZE))" \
68         $SCRATCH_MNT/foo | _filter_xfs_io
69
70 # success, all done
71 status=0
72 exit