2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Google, Inc. All Rights Reserved.
7 # Test for ea_inode feature in ext4. Without ea_inode feature, an extended
8 # attribute in ext4 cannot be larger than the fs block size. ea_inode feature
9 # allows storing xattr values in external inodes and so raises xattr value
13 _begin_fstest auto quick attr
15 # Import common functions.
19 # real QA test starts here
23 _require_scratch_ext4_feature "ea_inode"
25 _scratch_mkfs_ext4 -O ea_inode >/dev/null 2>&1
28 # Sets an extended attribute on a file.
31 local file=$1 name=$2 value=$3 tmp
33 if [[ "$value" != "" ]]; then
34 $SETFATTR_PROG -n $name -v "$value" $file
36 $SETFATTR_PROG -n $name $file
39 tmp=$(_getfattr --absolute-names --only-values -n $name $file)
40 [[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp"
43 # List attributes on a file.
46 _getfattr --absolute-names $1 | grep -v '^#'
49 # Removes an extended attribute from a file.
54 $SETFATTR_PROG -x $name $file
62 # Attribute with short name that goes into inode body.
65 # Attribute with long name that goes into xattr block.
66 name_in_block=user.$(perl -e 'print "b" x 100;')
68 # Set large xattr values on multiple files.
70 for file in $x $y $z; do
71 for name in $name_in_ibody $name_in_block; do
72 for size in 4096 8000 $((64*1024)); do
73 attr_set $file $name-$size \
74 $(perl -e "print 'v' x $size;")
83 attr_set $x $name_in_ibody $(perl -e "print 'i' x 25000;")
84 attr_set $x $name_in_block $(perl -e "print 'b' x 25000;")
86 attr_remove $x $name_in_ibody
87 attr_remove $x $name_in_block
90 # Set with same value twice.
92 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
93 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
97 # Repeatedly set an extended attribute with various value sizes.
99 for size in 0 10 80 900 1900 3000 9000 60 10000 0 8000 3000 10 0 20 10000 5; do
100 attr_set $x user.1 $(perl -e "print 'v' x $size;")