summaryrefslogtreecommitdiff
path: root/tests/generic/486
blob: 7dbfcb9835d962cf58fd08633fb88dd4ca474a33 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2018 Oracle.  All Rights Reserved.
#
# FS QA Test No. 486
#
# Ensure that we can XATTR_REPLACE a tiny attr into a large attr.
# Kanda Motohiro <kanda.motohiro@gmail.com> reports that XATTR_REPLACE'ing
# a single-byte attr with a 2048-byte attr causes a fs shutdown because we
# remove the shortform attr, convert the attr fork to long format, and then
# try to re-add the attr having not cleared ATTR_REPLACE.
#
# Commit 7b38460dc8e4 ("xfs: don't fail when converting shortform attr to long
# form during ATTR_REPLACE") fixed the xfs bug.
#
. ./common/preamble
_begin_fstest auto quick attr

# Override the default cleanup function.
_cleanup()
{
	cd /
	rm -f $testfile
}

# Import common functions.
. ./common/filter
. ./common/attr

# real QA test starts here
_supported_fs generic
_require_test_program "attr_replace_test"
_require_attrs
_require_scratch

_scratch_mkfs >>$seqres.full 2>&1
_scratch_mount >>$seqres.full 2>&1

filter_attr_output() {
	_filter_scratch | grep world | \
		sed -e 's/has a [0-9]* byte value/has a NNNN byte value/g'
}

max_attr_size=65536

# attr_replace_test can't easily auto-probe the attr size for ceph because:
# - ceph imposes a maximum value for the total xattr names+values, and
# - ceph reports the 'object size' in the block size, which is, by default, much
#   larger than XATTR_SIZE_MAX (4M > 64k)
# Hence, we need to provide it with a maximum size.
[ "$FSTYP" = "ceph" ] && max_attr_size=65000

$here/src/attr_replace_test -m $max_attr_size $SCRATCH_MNT/hello
$ATTR_PROG -l $SCRATCH_MNT/hello >>$seqres.full 2>&1
$ATTR_PROG -l $SCRATCH_MNT/hello | filter_attr_output

status=0
exit