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 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 "falloc"
38 _require_xfs_io_error_injection "reduce_max_iextents"
40 echo "Format and mount fs"
41 _scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
42 _scratch_mount >> $seqres.full
44 bsize=$(_get_file_block_size $SCRATCH_MNT)
46 testfile=${SCRATCH_MNT}/testfile
48 echo "Inject reduce_max_iextents error tag"
49 _scratch_inject_error reduce_max_iextents 1
53 for io in Buffered Direct; do
54 echo "* $io write to unwritten extent"
56 echo "Fallocate $nr_blks blocks"
57 $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * bsize))" $testfile >> $seqres.full
59 if [[ $io == "Buffered" ]]; then
65 echo "$io write to every other block of fallocated space"
66 for i in $(seq 1 2 $((nr_blks - 1))); do
67 $XFS_IO_PROG -f -s $xfs_io_flag -c "pwrite $((i * bsize)) $bsize" \
68 $testfile >> $seqres.full 2>&1
69 [[ $? != 0 ]] && break
72 echo "Verify \$testfile's extent count"
73 nextents=$(_xfs_get_fsxattr nextents $testfile)
74 if (( $nextents > 10 )); then
75 echo "Extent count overflow check failed: nextents = $nextents"