2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2021 Chandan Babu R. All Rights Reserved.
7 # Verify that XFS does not cause inode fork's extent count to overflow when
8 # punching out an extent.
10 _begin_fstest auto quick punch zero insert collapse
12 # Import common functions.
16 # real QA test starts here
21 _require_xfs_io_command "fpunch"
22 _require_xfs_io_command "finsert"
23 _require_xfs_io_command "fcollapse"
24 _require_xfs_io_command "fzero"
25 _require_xfs_io_error_injection "reduce_max_iextents"
27 echo "Format and mount fs"
28 _scratch_mkfs >> $seqres.full
29 _scratch_mount >> $seqres.full
31 bsize=$(_get_file_block_size $SCRATCH_MNT)
34 testfile=$SCRATCH_MNT/testfile
36 for op in fpunch finsert fcollapse fzero; do
37 echo "* $op regular file"
39 echo "Create \$testfile"
42 echo "Inject reduce_max_iextents error tag"
43 _scratch_inject_error reduce_max_iextents 1
46 -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \
47 $testfile >> $seqres.full
49 echo "$op alternating blocks"
50 for i in $(seq 1 2 $((nr_blks - 1))); do
51 $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \
53 [[ $? != 0 ]] && break
56 echo "Verify \$testfile's extent count"
58 nextents=$(_xfs_get_fsxattr nextents $testfile)
59 if (( $nextents > 10 )); then
60 echo "Extent count overflow check failed: nextents = $nextents"
64 echo "Disable reduce_max_iextents error tag"
65 _scratch_inject_error reduce_max_iextents 0