4 # This test stresses indirect block reservation for delayed allocation extents.
5 # XFS reserves extra blocks for deferred allocation of delalloc extents. These
6 # reserved blocks can be divided among more extents than anticipated if the
7 # original extent for which the blocks were reserved is split into multiple
8 # delalloc extents. If this scenario repeats, eventually some extents are left
9 # without any indirect block reservation whatsoever. This leads to assert
10 # failures and possibly other problems in XFS.
12 #-----------------------------------------------------------------------
13 # Copyright (c) 2014 Red Hat, Inc. All Rights Reserved.
15 # This program is free software; you can redistribute it and/or
16 # modify it under the terms of the GNU General Public License as
17 # published by the Free Software Foundation.
19 # This program is distributed in the hope that it would be useful,
20 # but WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 # GNU General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write the Free Software Foundation,
26 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #-----------------------------------------------------------------------
31 seqres=$RESULT_DIR/$seq
32 echo "QA output created by $seq"
36 status=1 # failure is the default!
37 trap "_cleanup; exit \$status" 0 1 2 3 15
45 # get standard environment, filters and checks
48 # real QA test starts here
51 # Modify as appropriate.
55 _require_xfs_io_command "fzero"
57 _scratch_mkfs >/dev/null 2>&1
60 file=$SCRATCH_MNT/file.$seq
63 # create sequential delayed allocation
64 $XFS_IO_PROG -f -c "pwrite 0 $bytes" $file >> $seqres.full 2>&1
66 # Zero every other 4k range to split the larger delalloc extent into many more
67 # smaller extents. Use zero instead of hole punch because the former does not
68 # force writeback (and hence delalloc conversion). It can simply discard
69 # delalloc blocks and convert the ranges to unwritten.
70 endoff=$((bytes - 4096))
71 for i in $(seq 0 8192 $endoff); do
72 $XFS_IO_PROG -c "fzero -k $i 4k" $file >> $seqres.full 2>&1
75 # now zero the opposite set to remove remaining delalloc extents
76 for i in $(seq 4096 8192 $endoff); do
77 $XFS_IO_PROG -c "fzero -k $i 4k" $file >> $seqres.full 2>&1