generic/233,270: unlimit the max locked memory size for io_uring
[xfstests-dev.git] / tests / xfs / 535
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 535
6 #
7 # Verify that XFS does not cause inode fork's extent count to overflow when
8 # writing to a shared extent.
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/reflink
28 . ./common/inject
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 _supported_fs xfs
36 _require_scratch
37 _require_scratch_reflink
38 _require_xfs_debug
39 _require_xfs_io_command "reflink"
40 _require_xfs_io_command "funshare"
41 _require_xfs_io_error_injection "reduce_max_iextents"
42
43 echo "Format and mount fs"
44 _scratch_mkfs_sized $((512 * 1024 * 1024)) >> $seqres.full
45 _scratch_mount >> $seqres.full
46
47 bsize=$(_get_block_size $SCRATCH_MNT)
48
49 nr_blks=15
50
51 srcfile=${SCRATCH_MNT}/srcfile
52 dstfile=${SCRATCH_MNT}/dstfile
53
54 echo "Inject reduce_max_iextents error tag"
55 _scratch_inject_error reduce_max_iextents 1
56
57 echo "Create a \$srcfile having an extent of length $nr_blks blocks"
58 $XFS_IO_PROG -f -c "pwrite -b $((nr_blks * bsize))  0 $((nr_blks * bsize))" \
59        -c fsync $srcfile  >> $seqres.full
60
61 echo "* Write to shared extent"
62
63 echo "Share the extent with \$dstfile"
64 _reflink $srcfile $dstfile >> $seqres.full
65
66 echo "Buffered write to every other block of \$dstfile's shared extent"
67 for i in $(seq 1 2 $((nr_blks - 1))); do
68         $XFS_IO_PROG -f -s -c "pwrite $((i * bsize)) $bsize" $dstfile \
69                >> $seqres.full 2>&1
70         [[ $? != 0 ]] && break
71 done
72
73 echo "Verify \$dstfile's extent count"
74 nextents=$(_xfs_get_fsxattr nextents $dstfile)
75 if (( $nextents > 10 )); then
76         echo "Extent count overflow check failed: nextents = $nextents"
77         exit 1
78 fi
79
80 rm $dstfile
81
82 echo "* Funshare shared extent"
83
84 echo "Share the extent with \$dstfile"
85 _reflink $srcfile $dstfile >> $seqres.full
86
87 echo "Funshare every other block of \$dstfile's shared extent"
88 for i in $(seq 1 2 $((nr_blks - 1))); do
89         $XFS_IO_PROG -f -s -c "funshare $((i * bsize)) $bsize" $dstfile \
90                >> $seqres.full 2>&1
91         [[ $? != 0 ]] && break
92 done
93
94 echo "Verify \$dstfile's extent count"
95 nextents=$(_xfs_get_fsxattr nextents $dstfile)
96 if (( $nextents > 10 )); then
97         echo "Extent count overflow check failed: nextents = $nextents"
98         exit 1
99 fi
100
101 # success, all done
102 status=0
103 exit
104