generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / btrfs / 010
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Facebook.  All Rights Reserved.
4 #
5 # FS QA Test 10
6 #
7 # Test delayed allocation with a large number of extents that are merged.
8 # Regression test for patch "Btrfs: fix delalloc accounting leak caused
9 # by u32 overflow".
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 test_file="$TEST_DIR/$seq"
21
22 _cleanup()
23 {
24         cd /
25         rm -f $tmp.* "$test_file"
26 }
27
28 . ./common/rc
29 . ./common/filter
30
31 rm -f $seqres.full
32
33 _supported_fs btrfs
34 _require_test
35 _require_btrfs_fs_sysfs
36
37 # Create 32k extents. All of these extents will be accounted as outstanding and
38 # reserved.
39 for ((i = 0; i < 32 * 1024; i++)); do
40         $XFS_IO_PROG -f -c "pwrite $((2 * 4096 * i)) 4096" "$test_file" >>"$seqres.full"
41 done
42
43 # Fill in the gaps between the created extents. The outstanding extents will
44 # all be merged into 1, but there will still be 32k reserved.
45 for ((i = 0; i < 32 * 1024; i++)); do
46         $XFS_IO_PROG -f -c "pwrite $((2 * 4096 * i + 4096)) 4096" "$test_file" >>"$seqres.full"
47 done
48
49 # Flush the delayed allocations.
50 sync
51
52 # Make sure that we didn't leak any metadata space.
53 uuid="$(findmnt -n -o UUID "$TEST_DIR")"
54 cd "/sys/fs/btrfs/$uuid/allocation"
55 echo "$(($(cat metadata/bytes_may_use) - $(cat global_rsv_reserved))) bytes leaked" | grep -v '^0 '
56
57 echo "Silence is golden"
58
59 status=0
60 exit