2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Ernesto A. Fernandez. All Rights Reserved.
7 # Fill the device and set as many extended attributes to a file as
8 # possible. Then call setfacl on it and, if this fails for lack of
9 # space, test that the permissions remain the same.
12 _begin_fstest auto quick acl attr enospc
14 # Import common functions.
18 # real QA test starts here
20 # Modify as appropriate.
25 _require_attrs trusted
27 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
28 _scratch_mount || _fail "mount failed"
30 # This is a test of xattr behavior when we run out of disk space for xattrs,
31 # so make sure the pwrite goes to the data device and not the rt volume.
32 test "$FSTYP" = "xfs" && \
33 _xfs_force_bdev data $SCRATCH_MNT
35 TFILE=$SCRATCH_MNT/testfile.$seq
37 # Create the test file and choose its permissions
42 # Try to run out of space so setfacl will fail
43 $XFS_IO_PROG -c "pwrite 0 256m" $TFILE >>$seqres.full 2>&1
46 # Setting acls on an xfs filesystem will succeed even after running out of
47 # space for user attributes. Use trusted attributes
48 while $SETFATTR_PROG -n trusted.$i -v $(perl -e 'print "a"x1024') $TFILE &>/dev/null; do
53 while [ $ret -eq 0 ]; do
55 while [ $j -le 1000 ]; do
56 # On btrfs, setfattr will sometimes fail when free space is
57 # low, long before it's actually exhausted. Insist until it
59 $SETFATTR_PROG -n trusted.$i"x"$j $TFILE &>/dev/null
67 if setfacl -m m:r $TFILE &>/dev/null; then
68 # setfacl succeeded, so the test was meaningless
69 # The filesystem might still have an issue
70 _notrun "$FSTYP succeeds in setting acls despite running out of space for user attrs"
73 # Since setfacl failed, the permissions should not have changed