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
36 _require_xfs_io_command "fiemap" "-a"
38 echo "Format and mount"
39 _scratch_mkfs > $seqres.full 2>&1
40 _scratch_mount >> $seqres.full 2>&1
42 testdir=$SCRATCH_MNT/test-$seq
45 echo "Create the original files"
46 testfile=$testdir/attrfile
48 blk_sz=$(_get_file_block_size $SCRATCH_MNT)
50 # Assume each attr eats at least 20 bytes. Try to fill 2 fs blocks.
51 max_attrs=$((2 * blk_sz / 20))
54 while [ $i -lt $max_attrs ]; do
55 n="$(printf "%010d" $i)"
56 $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break
61 echo "Check attr extent counts"
62 f1=$(_count_attr_extents $testfile)
63 echo "$f1 xattr extents" >> $seqres.full
64 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
65 test $f1 -gt 0 || echo "Expected at least one xattr extent."
69 echo "Check attr extent counts after remount"
70 f1=$(_count_attr_extents $testfile)
71 echo "$f1 xattr extents" >> $seqres.full
72 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
73 test $f1 -gt 0 || echo "Expected at least one xattr extent."