2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
7 # This test stresses indirect block reservation for delayed allocation extents.
8 # XFS reserves extra blocks for deferred allocation of delalloc extents. These
9 # reserved blocks can be divided among more extents than anticipated if the
10 # original extent for which the blocks were reserved is split into multiple
11 # delalloc extents. If this scenario repeats, eventually some extents are left
12 # without any indirect block reservation whatsoever. This leads to assert
13 # failures and possibly other problems in XFS.
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
30 # get standard environment, filters and checks
33 # real QA test starts here
36 # Modify as appropriate.
40 _require_xfs_io_command "fzero"
42 _scratch_mkfs >/dev/null 2>&1
45 file=$SCRATCH_MNT/file.$seq
48 # create sequential delayed allocation
49 $XFS_IO_PROG -f -c "pwrite 0 $bytes" $file >> $seqres.full 2>&1
51 # Zero every other 4k range to split the larger delalloc extent into many more
52 # smaller extents. Use zero instead of hole punch because the former does not
53 # force writeback (and hence delalloc conversion). It can simply discard
54 # delalloc blocks and convert the ranges to unwritten.
55 endoff=$((bytes - 4096))
56 for i in $(seq 0 8192 $endoff); do
57 $XFS_IO_PROG -c "fzero -k $i 4k" $file >> $seqres.full 2>&1
60 # now zero the opposite set to remove remaining delalloc extents
61 for i in $(seq 4096 8192 $endoff); do
62 $XFS_IO_PROG -c "fzero -k $i 4k" $file >> $seqres.full 2>&1