Files
apfstests/tests/generic/449
T
Darrick J. Wong eb8d229ff7 generic/449: always fill up the data device
This is yet another one of those tests that looks at what happens when
we run out of space for more metadata (in this case, xattrs).  Make sure
that the 256M we write to the file to try to stimulate ENOSPC gets
written to the same place that xfs puts xattr data -- the data device.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
2021-05-09 23:25:05 +08:00

94 lines
2.2 KiB
Bash
Executable File

#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2017 Ernesto A. Fernandez. All Rights Reserved.
#
# FS QA Test 449
#
# Fill the device and set as many extended attributes to a file as
# possible. Then call setfacl on it and, if this fails for lack of
# space, test that the permissions remain the same.
#
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
# remove previous $seqres.full before test
rm -f $seqres.full
# real QA test starts here
# Modify as appropriate.
_supported_fs generic
_require_scratch
_require_test
_require_acls
_require_attrs trusted
_scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
_scratch_mount || _fail "mount failed"
# This is a test of xattr behavior when we run out of disk space for xattrs,
# so make sure the pwrite goes to the data device and not the rt volume.
test "$FSTYP" = "xfs" && \
$XFS_IO_PROG -c 'chattr -t' $SCRATCH_MNT
TFILE=$SCRATCH_MNT/testfile.$seq
# Create the test file and choose its permissions
touch $TFILE
chmod u+rwx $TFILE
chmod go-rwx $TFILE
# Try to run out of space so setfacl will fail
$XFS_IO_PROG -c "pwrite 0 256m" $TFILE >>$seqres.full 2>&1
i=1
# Setting acls on an xfs filesystem will succeed even after running out of
# space for user attributes. Use trusted attributes
while $SETFATTR_PROG -n trusted.$i -v $(perl -e 'print "a"x1024') $TFILE &>/dev/null; do
((++i))
done
j=1
ret=0
while [ $ret -eq 0 ]; do
ret=1
while [ $j -le 1000 ]; do
# On btrfs, setfattr will sometimes fail when free space is
# low, long before it's actually exhausted. Insist until it
# fails consistently.
$SETFATTR_PROG -n trusted.$i"x"$j $TFILE &>/dev/null
ret=$(( $ret && $? ))
((++j))
done
j=1
((++i))
done
if setfacl -m m:r $TFILE &>/dev/null; then
# setfacl succeeded, so the test was meaningless
# The filesystem might still have an issue
_notrun "$FSTYP succeeds in setting acls despite running out of space for user attrs"
fi
# Since setfacl failed, the permissions should not have changed
stat -c %A $TFILE
status=0
exit