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) 2017 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
49 # real QA test starts here
52 # Modify as appropriate.
56 _require_xfs_sysfs $(_short_dev $TEST_DEV)/drop_writes
58 _scratch_mkfs >/dev/null 2>&1
61 sdev=$(_short_dev $SCRATCH_DEV)
62 file=$SCRATCH_MNT/file.$seq
65 # create sequential delayed allocation
66 $XFS_IO_PROG -f -c "pwrite 0 $bytes" $file >> $seqres.full 2>&1
68 # Enable write drops. All buffered writes are dropped from this point on.
69 echo 1 > /sys/fs/xfs/$sdev/drop_writes
71 # Write every other 4k range to split the larger delalloc extent into many more
72 # smaller extents. Use pwrite because with write failures enabled, all
73 # preexisting delalloc blocks in the range of the I/O are tossed without
74 # discretion. This allows manipulation of the delalloc extent without conversion
75 # to real blocks (and thus releasing the indirect reservation).
76 endoff=$((bytes - 4096))
77 for i in $(seq 0 8192 $endoff); do
78 $XFS_IO_PROG -c "pwrite $i 4k" $file >> $seqres.full 2>&1
81 # now pwrite the opposite set to remove remaining delalloc extents
82 for i in $(seq 4096 8192 $endoff); do
83 $XFS_IO_PROG -c "pwrite $i 4k" $file >> $seqres.full 2>&1
86 echo 0 > /sys/fs/xfs/$sdev/drop_writes
89 $XFS_IO_PROG -c 'bmap -vp' $file | _filter_bmap
91 # Now test a buffered write workload with larger extents. Write a 100m extent,
92 # split it at the 3/4 mark, then write another 100m extent that is contiguous
93 # with the 1/4 portion of the split extent. Repeat several times. This pattern
94 # is known to prematurely exhaust indirect reservations and cause warnings and
97 for offset in $(seq 0 100 500); do
98 $XFS_IO_PROG -fc "pwrite ${offset}m 100m" $file >> $seqres.full 2>&1
100 punchoffset=$((offset + 75))
101 echo 1 > /sys/fs/xfs/$sdev/drop_writes
102 $XFS_IO_PROG -c "pwrite ${punchoffset}m 4k" $file >> $seqres.full 2>&1
103 echo 0 > /sys/fs/xfs/$sdev/drop_writes
106 echo "Silence is golden."