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 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=1 # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
24 # get standard environment, filters and checks
30 # real QA test starts here
35 getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
36 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
40 _scratch_mkfs_xfs -m crc=0 -i size=256 >> $seqres.full 2>&1 \
41 || _fail "mkfs failed"
43 # Manually mount to avoid fs-wide context set by default in xfstests
44 mount $SCRATCH_DEV $SCRATCH_MNT
46 touch $SCRATCH_MNT/$seq.test
48 # Create an extents-format attribute on a file
49 $XFS_IO_PROG -f -c "pwrite -S 0x63 0 4096" $SCRATCH_MNT/attrvals >> $seqres.full 2>&1
50 cat $SCRATCH_MNT/attrvals | attr -s name $SCRATCH_MNT/$seq.test >> $seqres.full 2>&1
52 # Fragment the file by writing backwards
53 bs=$(_get_file_block_size $SCRATCH_MNT)
54 for I in `seq 6 -1 0`; do
55 dd if=/dev/zero of=$SCRATCH_MNT/$seq.test seek=$I bs=${bs} \
56 oflag=direct count=1 conv=notrunc >> $seqres.full 2>&1
59 # See if xfs_fsr works.
61 # The target file now has a non-local attribute, but the
62 # fsr temp file gets assigned a local attribute on creation,
65 # In this case, the large-ish selinux attr will create a forkoff
66 # in the temp file smaller than the forkoff in the target file,
67 # because the FMT_EXTENTS attr takes up less space. If there is
68 # no mechanism to grow the temp forkoff to match, we can end up
69 # failing to swap these 2 inodes if the result is not enough
70 # data space in the temp inode as a result.
72 $XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch