xfs: fix old fuzz test invocations of xfs_repair
[xfstests-dev.git] / tests / xfs / 300
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 300
6 #
7 # Test xfs_fsr / swapext management of di_forkoff w/ selinux
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "_cleanup; exit \$status" 0 1 2 3 15
17
18 _cleanup()
19 {
20     cd /
21     rm -f $tmp.*
22 }
23
24 # get standard environment, filters and checks
25 . ./common/rc
26 . ./common/filter
27
28 _require_scratch
29
30 # real QA test starts here
31
32 _supported_fs xfs
33
34 getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
35 [ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"
36
37 rm -f $seqres.full
38
39 _scratch_mkfs_xfs -m crc=0 -i size=256 >> $seqres.full 2>&1 \
40                         || _fail "mkfs failed"
41
42 # Manually mount to avoid fs-wide context set by default in xfstests
43 mount $SCRATCH_DEV $SCRATCH_MNT
44
45 touch $SCRATCH_MNT/$seq.test
46
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
50
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
56 done
57
58 # See if xfs_fsr works.
59
60 # The target file now has a non-local attribute, but the
61 # fsr temp file gets assigned a local attribute on creation,
62 # due to selinux.
63     
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.
70
71 $XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch
72
73 # success, all done
74 status=0
75 exit