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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
29 # remove previous $seqres.full before test
32 # real QA test starts here
37 _require_xfs_io_command "fpunch"
38 _require_xfs_io_command "finsert"
39 _require_xfs_io_command "fcollapse"
40 _require_xfs_io_command "fzero"
41 _require_xfs_io_error_injection "reduce_max_iextents"
43 echo "Format and mount fs"
44 _scratch_mkfs >> $seqres.full
45 _scratch_mount >> $seqres.full
47 bsize=$(_get_file_block_size $SCRATCH_MNT)
50 testfile=$SCRATCH_MNT/testfile
52 for op in fpunch finsert fcollapse fzero; do
53 echo "* $op regular file"
55 echo "Create \$testfile"
58 echo "Inject reduce_max_iextents error tag"
59 _scratch_inject_error reduce_max_iextents 1
62 -c "pwrite -b $((nr_blks * bsize)) 0 $((nr_blks * bsize))" \
63 $testfile >> $seqres.full
65 echo "$op alternating blocks"
66 for i in $(seq 1 2 $((nr_blks - 1))); do
67 $XFS_IO_PROG -f -c "$op $((i * bsize)) $bsize" $testfile \
69 [[ $? != 0 ]] && break
72 echo "Verify \$testfile's extent count"
74 nextents=$(_xfs_get_fsxattr nextents $testfile)
75 if (( $nextents > 10 )); then
76 echo "Extent count overflow check failed: nextents = $nextents"
80 echo "Disable reduce_max_iextents error tag"
81 _scratch_inject_error reduce_max_iextents 0