generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / xfs / 532
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Chandan Babu R.  All Rights Reserved.
4 #
5 # FS QA Test 532
6 #
7 # Verify that XFS does not cause inode fork's extent count to overflow when
8 # adding/removing xattrs.
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20         cd /
21         rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27 . ./common/attr
28 . ./common/inject
29 . ./common/populate
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35
36 _supported_fs xfs
37 _require_scratch
38 _require_attrs
39 _require_xfs_debug
40 _require_test_program "punch-alternating"
41 _require_xfs_io_error_injection "reduce_max_iextents"
42 _require_xfs_io_error_injection "bmap_alloc_minlen_extent"
43
44 echo "Format and mount fs"
45 _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
46 _scratch_mount >> $seqres.full
47
48 bsize=$(_get_block_size $SCRATCH_MNT)
49
50 attr_len=255
51
52 testfile=$SCRATCH_MNT/testfile
53
54 echo "Consume free space"
55 fillerdir=$SCRATCH_MNT/fillerdir
56 nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT)
57 nr_free_blks=$((nr_free_blks * 90 / 100))
58
59 _fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1
60
61 echo "Create fragmented filesystem"
62 for dentry in $(ls -1 $fillerdir/); do
63         $here/src/punch-alternating $fillerdir/$dentry >> $seqres.full
64 done
65
66 echo "Inject reduce_max_iextents error tag"
67 _scratch_inject_error reduce_max_iextents 1
68
69 echo "Inject bmap_alloc_minlen_extent error tag"
70 _scratch_inject_error bmap_alloc_minlen_extent 1
71
72 echo "* Set xattrs"
73
74 echo "Create \$testfile"
75 touch $testfile
76
77 echo "Create xattrs"
78 nr_attrs=$((bsize * 20 / attr_len))
79 for i in $(seq 1 $nr_attrs); do
80         attr="$(printf "trusted.%0247d" $i)"
81         $SETFATTR_PROG -n "$attr" $testfile >> $seqres.full 2>&1
82         [[ $? != 0 ]] && break
83 done
84
85 echo "Verify \$testfile's naextent count"
86
87 naextents=$(_xfs_get_fsxattr naextents $testfile)
88 if (( $naextents > 10 )); then
89         echo "Extent count overflow check failed: naextents = $naextents"
90         exit 1
91 fi
92
93 echo "Remove \$testfile"
94 rm $testfile
95
96 echo "* Remove xattrs"
97
98 echo "Create \$testfile"
99 touch $testfile
100
101 echo "Disable reduce_max_iextents error tag"
102 _scratch_inject_error reduce_max_iextents 0
103
104 echo "Create initial xattr extents"
105
106 naextents=0
107 last=""
108 start=1
109 nr_attrs=$((bsize / attr_len))
110
111 while (( $naextents < 4 )); do
112         end=$((start + nr_attrs - 1))
113
114         for i in $(seq $start $end); do
115                 attr="$(printf "trusted.%0247d" $i)"
116                 $SETFATTR_PROG -n $attr $testfile
117         done
118
119         start=$((end + 1))
120
121         naextents=$(_xfs_get_fsxattr naextents $testfile)
122 done
123
124 echo "Inject reduce_max_iextents error tag"
125 _scratch_inject_error reduce_max_iextents 1
126
127 echo "Remove xattr to trigger -EFBIG"
128 attr="$(printf "trusted.%0247d" 1)"
129 $SETFATTR_PROG -x "$attr" $testfile >> $seqres.full 2>&1
130 if [[ $? == 0 ]]; then
131         echo "Xattr removal succeeded; Should have failed "
132         exit 1
133 fi
134
135 rm $testfile && echo "Successfully removed \$testfile"
136
137 # success, all done
138 status=0
139 exit