2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc. All Rights Reserved.
7 # Check that FIEMAP produces some output when we require an external
8 # block to hold extended attributes.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
26 # get standard environment, filters and checks
31 # real QA test starts here
34 [ $FSTYP = bcachefs ] && _notrun "bcachefs does not store xattrs in blocks"
38 _require_xfs_io_command "fiemap" "-a"
40 echo "Format and mount"
41 _scratch_mkfs > $seqres.full 2>&1
42 _scratch_mount >> $seqres.full 2>&1
44 testdir=$SCRATCH_MNT/test-$seq
47 echo "Create the original files"
48 testfile=$testdir/attrfile
50 blk_sz=$(_get_file_block_size $SCRATCH_MNT)
52 # Assume each attr eats at least 20 bytes. Try to fill 2 fs blocks.
53 max_attrs=$((2 * blk_sz / 20))
56 while [ $i -lt $max_attrs ]; do
57 n="$(printf "%010d" $i)"
58 $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break
63 echo "Check attr extent counts"
64 f1=$(_count_attr_extents $testfile)
65 echo "$f1 xattr extents" >> $seqres.full
66 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
67 test $f1 -gt 0 || echo "Expected at least one xattr extent."
71 echo "Check attr extent counts after remount"
72 f1=$(_count_attr_extents $testfile)
73 echo "$f1 xattr extents" >> $seqres.full
74 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
75 test $f1 -gt 0 || echo "Expected at least one xattr extent."