Files
apfstests/tests/xfs/532
T
Chandan Babu R febeb7ec8b xfs/53[238]: Disable realtime inherit flag
The minimum length space allocator (i.e.
xfs_bmap_exact_minlen_extent_alloc()) depends on the underlying
filesystem to be fragmented so that there are enough one block sized
extents available to satify space allocation requests.

xfs/{532,533,538} tests issue space allocation requests for metadata
(e.g. for blocks holding directory and xattr information). With
realtime filesystem instances, these tests would end up fragmenting
the space on realtime device. Hence minimum length space allocator
fails since the regular filesystem space is not fragmented and hence
there are no one block sized extents available.

Thus, this commit disables realtime inherit flag (if any) on root
directory so that space on data device gets fragmented rather than
realtime device.

Suggested-by: Darrick J. Wong <djwong@kernel.org>
Reported-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-04-11 16:49:26 +08:00

147 lines
3.2 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2021 Chandan Babu R. All Rights Reserved.
#
# FS QA Test 532
#
# Verify that XFS does not cause inode fork's extent count to overflow when
# adding/removing xattrs.
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15
_cleanup()
{
cd /
rm -f $tmp.*
}
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
. ./common/attr
. ./common/inject
. ./common/populate
# remove previous $seqres.full before test
rm -f $seqres.full
# real QA test starts here
_supported_fs xfs
_require_scratch
_require_attrs
_require_xfs_debug
_require_test_program "punch-alternating"
_require_xfs_io_error_injection "reduce_max_iextents"
_require_xfs_io_error_injection "bmap_alloc_minlen_extent"
echo "Format and mount fs"
_scratch_mkfs_sized $((1024 * 1024 * 1024)) >> $seqres.full
_scratch_mount >> $seqres.full
# Disable realtime inherit flag (if any) on root directory so that space on data
# device gets fragmented rather than realtime device.
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
bsize=$(_get_block_size $SCRATCH_MNT)
attr_len=255
testfile=$SCRATCH_MNT/testfile
echo "Consume free space"
fillerdir=$SCRATCH_MNT/fillerdir
nr_free_blks=$(stat -f -c '%f' $SCRATCH_MNT)
nr_free_blks=$((nr_free_blks * 90 / 100))
_fill_fs $((bsize * nr_free_blks)) $fillerdir $bsize 0 >> $seqres.full 2>&1
echo "Create fragmented filesystem"
for dentry in $(ls -1 $fillerdir/); do
$here/src/punch-alternating $fillerdir/$dentry >> $seqres.full
done
echo "Inject bmap_alloc_minlen_extent error tag"
_scratch_inject_error bmap_alloc_minlen_extent 1
echo "* Set xattrs"
echo "Create \$testfile"
touch $testfile
echo "Inject reduce_max_iextents error tag"
_scratch_inject_error reduce_max_iextents 1
echo "Create xattrs"
nr_attrs=$((bsize * 20 / attr_len))
for i in $(seq 1 $nr_attrs); do
attr="$(printf "trusted.%0247d" $i)"
$SETFATTR_PROG -n "$attr" $testfile >> $seqres.full 2>&1
[[ $? != 0 ]] && break
done
echo "Verify \$testfile's naextent count"
naextents=$(_xfs_get_fsxattr naextents $testfile)
if (( $naextents > 10 )); then
echo "Extent count overflow check failed: naextents = $naextents"
exit 1
fi
echo "Disable reduce_max_iextents error tag"
_scratch_inject_error reduce_max_iextents 0
echo "Remove \$testfile"
rm $testfile
echo "* Remove xattrs"
echo "Create \$testfile"
touch $testfile
echo "Create initial xattr extents"
naextents=0
last=""
start=1
nr_attrs=$((bsize / attr_len))
while (( $naextents < 4 )); do
end=$((start + nr_attrs - 1))
for i in $(seq $start $end); do
attr="$(printf "trusted.%0247d" $i)"
$SETFATTR_PROG -n $attr $testfile
done
start=$((end + 1))
naextents=$(_xfs_get_fsxattr naextents $testfile)
done
echo "Inject reduce_max_iextents error tag"
_scratch_inject_error reduce_max_iextents 1
echo "Remove xattr to trigger -EFBIG"
attr="$(printf "trusted.%0247d" 1)"
$SETFATTR_PROG -x "$attr" $testfile >> $seqres.full 2>&1
if [[ $? == 0 ]]; then
echo "Xattr removal succeeded; Should have failed "
exit 1
fi
echo "Disable reduce_max_iextents error tag"
_scratch_inject_error reduce_max_iextents 0
rm $testfile
# success, all done
status=0
exit