4 # Test xfs_fsr / swapext management of di_forkoff w/ selinux
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
38 # get standard environment, filters and checks
44 # real QA test starts here
49 getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
50 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
54 _scratch_mkfs_xfs -i size=256 >> $seqres.full 2>&1 || _fail "mkfs failed"
56 # Manually mount to avoid fs-wide context set by default in xfstests
57 mount $SCRATCH_DEV $SCRATCH_MNT
59 touch $SCRATCH_MNT/$seq.test
61 # Create an extents-format attribute on a file
62 $XFS_IO_PROG -f -c "pwrite -S 0x63 0 4096" $SCRATCH_MNT/attrvals >> $seqres.full 2>&1
63 cat $SCRATCH_MNT/attrvals | attr -s name $SCRATCH_MNT/$seq.test >> $seqres.full 2>&1
65 # Fragment the file by writing backwards
66 for I in `seq 6 -1 0`; do
67 dd if=/dev/zero of=$SCRATCH_MNT/$seq.test seek=$I bs=4k \
68 oflag=direct count=1 conv=notrunc >> $seqres.full 2>&1
71 # See if xfs_fsr works.
73 # The target file now has a non-local attribute, but the
74 # fsr temp file gets assigned a local attribute on creation,
77 # In this case, the large-ish selinux attr will create a forkoff
78 # in the temp file smaller than the forkoff in the target file,
79 # because the FMT_EXTENTS attr takes up less space. If there is
80 # no mechanism to grow the temp forkoff to match, we can end up
81 # failing to swap these 2 inodes if the result is not enough
82 # data space in the temp inode as a result.
84 $XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch