fsx/fsstress: round blocksize properly
[xfstests-dev.git] / tests / generic / 449
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Ernesto A. Fernandez.  All Rights Reserved.
4 #
5 # FS QA Test 449
6 #
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.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/attr
30
31 # remove previous $seqres.full before test
32 rm -f $seqres.full
33
34 # real QA test starts here
35
36 # Modify as appropriate.
37 _supported_fs generic
38 _require_scratch
39 _require_test
40 _require_acls
41 _require_attrs trusted
42
43 _scratch_mkfs_sized $((256 * 1024 * 1024)) >> $seqres.full 2>&1
44 _scratch_mount || _fail "mount failed"
45
46 # This is a test of xattr behavior when we run out of disk space for xattrs,
47 # so make sure the pwrite goes to the data device and not the rt volume.
48 test "$FSTYP" = "xfs" && \
49         _xfs_force_bdev data $SCRATCH_MNT
50
51 TFILE=$SCRATCH_MNT/testfile.$seq
52
53 # Create the test file and choose its permissions
54 touch $TFILE
55 chmod u+rwx $TFILE
56 chmod go-rwx $TFILE
57
58 # Try to run out of space so setfacl will fail
59 $XFS_IO_PROG -c "pwrite 0 256m" $TFILE >>$seqres.full 2>&1
60 i=1
61
62 # Setting acls on an xfs filesystem will succeed even after running out of
63 # space for user attributes. Use trusted attributes
64 while $SETFATTR_PROG -n trusted.$i -v $(perl -e 'print "a"x1024') $TFILE &>/dev/null; do
65         ((++i))
66 done
67 j=1
68 ret=0
69 while [ $ret -eq 0 ]; do
70         ret=1
71         while [ $j -le 1000 ]; do
72                 # On btrfs, setfattr will sometimes fail when free space is
73                 # low, long before it's actually exhausted. Insist until it
74                 # fails consistently.
75                 $SETFATTR_PROG -n trusted.$i"x"$j $TFILE &>/dev/null
76                 ret=$(( $ret && $? ))
77                 ((++j))
78         done
79         j=1
80         ((++i))
81 done
82
83 if setfacl -m m:r $TFILE &>/dev/null; then
84         # setfacl succeeded, so the test was meaningless
85         # The filesystem might still have an issue
86         _notrun "$FSTYP succeeds in setting acls despite running out of space for user attrs"
87 fi
88
89 # Since setfacl failed, the permissions should not have changed
90 stat -c %A $TFILE
91
92 status=0
93 exit