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
34 getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
35 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
39 _scratch_mkfs_xfs -m crc=0 -i size=256 >> $seqres.full 2>&1 \
40 || _fail "mkfs failed"
42 # Manually mount to avoid fs-wide context set by default in xfstests
43 mount $SCRATCH_DEV $SCRATCH_MNT
45 touch $SCRATCH_MNT/$seq.test
47 # Create an extents-format attribute on a file
48 $XFS_IO_PROG -f -c "pwrite -S 0x63 0 4096" $SCRATCH_MNT/attrvals >> $seqres.full 2>&1
49 cat $SCRATCH_MNT/attrvals | attr -s name $SCRATCH_MNT/$seq.test >> $seqres.full 2>&1
51 # Fragment the file by writing backwards
52 bs=$(_get_file_block_size $SCRATCH_MNT)
53 for I in `seq 6 -1 0`; do
54 dd if=/dev/zero of=$SCRATCH_MNT/$seq.test seek=$I bs=${bs} \
55 oflag=direct count=1 conv=notrunc >> $seqres.full 2>&1
58 # See if xfs_fsr works.
60 # The target file now has a non-local attribute, but the
61 # fsr temp file gets assigned a local attribute on creation,
64 # In this case, the large-ish selinux attr will create a forkoff
65 # in the temp file smaller than the forkoff in the target file,
66 # because the FMT_EXTENTS attr takes up less space. If there is
67 # no mechanism to grow the temp forkoff to match, we can end up
68 # failing to swap these 2 inodes if the result is not enough
69 # data space in the temp inode as a result.
71 $XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch