summaryrefslogtreecommitdiff
path: root/tests/xfs/300
blob: bc1f0efc6a36874e324f56c568ad28b32a93e5e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2013 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. 300
#
# Test xfs_fsr / swapext management of di_forkoff w/ selinux
#
. ./common/preamble
_begin_fstest auto fsr

# Import common functions.
. ./common/filter

_require_scratch
_require_xfs_nocrc

# real QA test starts here

_supported_fs xfs

getenforce | grep -q "Enforcing\|Permissive" || _notrun "SELinux not enabled"
[ "$XFS_FSR_PROG" = "" ] && _notrun "xfs_fsr not found"

_scratch_mkfs_xfs -m crc=0 -i size=256 >> $seqres.full 2>&1 \
			|| _fail "mkfs failed"

# Manually mount to avoid fs-wide context set by default in xfstests
mount $SCRATCH_DEV $SCRATCH_MNT

touch $SCRATCH_MNT/$seq.test

# Create an extents-format attribute on a file
$XFS_IO_PROG -f -c "pwrite -S 0x63 0 4096" $SCRATCH_MNT/attrvals >> $seqres.full 2>&1
cat $SCRATCH_MNT/attrvals | attr -s name $SCRATCH_MNT/$seq.test >> $seqres.full 2>&1

# Fragment the file by writing backwards
bs=$(_get_file_block_size $SCRATCH_MNT)
for I in `seq 6 -1 0`; do
	dd if=/dev/zero of=$SCRATCH_MNT/$seq.test seek=$I bs=${bs} \
	   oflag=direct count=1 conv=notrunc >> $seqres.full 2>&1
done

# See if xfs_fsr works.

# The target file now has a non-local attribute, but the
# fsr temp file gets assigned a local attribute on creation,
# due to selinux.
    
# In this case, the large-ish selinux attr will create a forkoff
# in the temp file smaller than the forkoff in the target file,
# because the FMT_EXTENTS attr takes up less space.  If there is
# no mechanism to grow the temp forkoff to match, we can end up
# failing to swap these 2 inodes if the result is not enough
# data space in the temp inode as a result.

$XFS_FSR_PROG -v $SCRATCH_MNT/$seq.test | _filter_scratch

# success, all done
status=0
exit