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 # writing to an unwritten extent.
10 _begin_fstest auto quick
12 # Import common functions.
16 # real QA test starts here
21 _require_xfs_io_command "falloc"
22 _require_xfs_io_error_injection "reduce_max_iextents"
24 echo "Format and mount fs"
25 _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
26 _scratch_mount >> $seqres.full
28 bsize=$(_get_file_block_size $SCRATCH_MNT)
30 testfile=${SCRATCH_MNT}/testfile
34 for io in Buffered Direct; do
35 echo "* $io write to unwritten extent"
37 echo "Fallocate $nr_blks blocks"
38 $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full
40 if [[ $io == "Buffered" ]]; then
46 echo "Inject reduce_max_iextents error tag"
47 _scratch_inject_error reduce_max_iextents 1
49 echo "$io write to every other block of fallocated space"
50 for i in $(seq 1 2 $((nr_blks - 1))); do
51 $XFS_IO_PROG -f -s $xfs_io_flag -c "pwrite $((i * bsize)) $bsize" \
52 $testfile >> $seqres.full 2>&1
53 [[ $? != 0 ]] && break
56 echo "Verify \$testfile's extent count"
57 nextents=$(_xfs_get_fsxattr nextents $testfile)
58 if (( $nextents > 10 )); then
59 echo "Extent count overflow check failed: nextents = $nextents"
63 echo "Disable reduce_max_iextents error tag"
64 _scratch_inject_error reduce_max_iextents 0