2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc. All Rights Reserved.
7 # Test xfs_fsr / swapext management of di_forkoff w/ selinux
10 _begin_fstest auto fsr
12 # Import common functions.
17 # real QA test starts here
21 getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
22 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
24 _scratch_mkfs_xfs -m crc=0 -i size=256 >> $seqres.full 2>&1 \
25 || _fail "mkfs failed"
27 # Manually mount to avoid fs-wide context set by default in xfstests
28 mount $SCRATCH_DEV $SCRATCH_MNT
30 touch $SCRATCH_MNT/$seq.test
32 # Create an extents-format attribute on a file
33 $XFS_IO_PROG -f -c "pwrite -S 0x63 0 4096" $SCRATCH_MNT/attrvals >> $seqres.full 2>&1
34 cat $SCRATCH_MNT/attrvals | attr -s name $SCRATCH_MNT/$seq.test >> $seqres.full 2>&1
36 # Fragment the file by writing backwards
37 bs=$(_get_file_block_size $SCRATCH_MNT)
38 for I in `seq 6 -1 0`; do
39 dd if=/dev/zero of=$SCRATCH_MNT/$seq.test seek=$I bs=${bs} \
40 oflag=direct count=1 conv=notrunc >> $seqres.full 2>&1
43 # See if xfs_fsr works.
45 # The target file now has a non-local attribute, but the
46 # fsr temp file gets assigned a local attribute on creation,
49 # In this case, the large-ish selinux attr will create a forkoff
50 # in the temp file smaller than the forkoff in the target file,
51 # because the FMT_EXTENTS attr takes up less space. If there is
52 # no mechanism to grow the temp forkoff to match, we can end up
53 # failing to swap these 2 inodes if the result is not enough
54 # data space in the temp inode as a result.
56 $XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch