generic/223: make sure all files get created on the data device
[xfstests-dev.git] / tests / generic / 425
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Oracle, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 425
6 #
7 # Check that FIEMAP produces some output when we require an external
8 # block to hold extended attributes.
9 #
10 seq=`basename $0`
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
13
14 here=`pwd`
15 tmp=/tmp/$$
16 status=1        # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 7 15
18
19 _cleanup()
20 {
21         cd /
22         rm -rf $tmp.*
23         wait
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29 . ./common/attr
30
31 # real QA test starts here
32 _supported_fs generic
33 _require_scratch
34 _require_attrs
35 _require_xfs_io_command "fiemap" "-a"
36
37 echo "Format and mount"
38 _scratch_mkfs > $seqres.full 2>&1
39 _scratch_mount >> $seqres.full 2>&1
40
41 testdir=$SCRATCH_MNT/test-$seq
42 mkdir $testdir
43
44 echo "Create the original files"
45 testfile=$testdir/attrfile
46 touch $testfile
47 blk_sz=$(_get_file_block_size $SCRATCH_MNT)
48
49 # Assume each attr eats at least 20 bytes.  Try to fill 2 fs blocks.
50 max_attrs=$((2 * blk_sz / 20))
51
52 i=0
53 while [ $i -lt $max_attrs ]; do
54         n="$(printf "%010d" $i)"
55         $SETFATTR_PROG -n "user.$n" -v "$n" $testfile > $seqres.full 2>&1 || break
56         i=$((i + 1))
57 done
58 sync
59
60 echo "Check attr extent counts"
61 f1=$(_count_attr_extents $testfile)
62 echo "$f1 xattr extents" >> $seqres.full
63 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
64 test $f1 -gt 0 || echo "Expected at least one xattr extent."
65
66 _scratch_cycle_mount
67
68 echo "Check attr extent counts after remount"
69 f1=$(_count_attr_extents $testfile)
70 echo "$f1 xattr extents" >> $seqres.full
71 $XFS_IO_PROG -c 'fiemap -a -v' $testfile >> $seqres.full
72 test $f1 -gt 0 || echo "Expected at least one xattr extent."
73
74 # success, all done
75 status=0
76 exit