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 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
17 status=1 # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
25 # get standard environment, filters and checks
30 # remove previous $seqres.full before test
33 # real QA test starts here
38 _require_scratch_ext4_feature "ea_inode"
40 _scratch_mkfs_ext4 -O ea_inode >/dev/null 2>&1
43 # Sets an extended attribute on a file.
46 local file=$1 name=$2 value=$3 tmp
48 if [[ "$value" != "" ]]; then
49 $SETFATTR_PROG -n $name -v "$value" $file
51 $SETFATTR_PROG -n $name $file
54 tmp=$(_getfattr --absolute-names --only-values -n $name $file)
55 [[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp"
58 # List attributes on a file.
61 _getfattr --absolute-names $1 | grep -v '^#'
64 # Removes an extended attribute from a file.
69 $SETFATTR_PROG -x $name $file
77 # Attribute with short name that goes into inode body.
80 # Attribute with long name that goes into xattr block.
81 name_in_block=user.$(perl -e 'print "b" x 100;')
83 # Set large xattr values on multiple files.
85 for file in $x $y $z; do
86 for name in $name_in_ibody $name_in_block; do
87 for size in 4096 8000 $((64*1024)); do
88 attr_set $file $name-$size \
89 $(perl -e "print 'v' x $size;")
98 attr_set $x $name_in_ibody $(perl -e "print 'i' x 25000;")
99 attr_set $x $name_in_block $(perl -e "print 'b' x 25000;")
101 attr_remove $x $name_in_ibody
102 attr_remove $x $name_in_block
105 # Set with same value twice.
107 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
108 attr_set $x $name_in_ibody $(perl -e "print 'i' x 60000;")
112 # Repeatedly set an extended attribute with various value sizes.
114 for size in 0 10 80 900 1900 3000 9000 60 10000 0 8000 3000 10 0 20 10000 5; do
115 attr_set $x user.1 $(perl -e "print 'v' x $size;")