4 # Create a file with more than 2^21 blocks (the max length of a bmbt record).
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2016, Oracle and/or its affiliates. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #-----------------------------------------------------------------------
24 seqres=$RESULT_DIR/$seq
25 echo "QA output created by $seq"
29 status=1 # failure is the default!
30 trap "_cleanup; exit \$status" 0 1 2 3 15
35 umount $SCRATCH_MNT > /dev/null 2>&1
38 _scratch_mkfs >/dev/null 2>&1
41 # get standard environment, filters and checks
46 # real QA test starts here
50 _require_xfs_scratch_rmapbt
51 _require_xfs_io_command "falloc"
55 # Figure out block size
56 echo "Figure out block size"
57 _scratch_mkfs >/dev/null 2>&1
58 _scratch_mount >> $seqres.full
60 testdir=$SCRATCH_MNT/test-$seq
61 blksz="$(_get_block_size $SCRATCH_MNT)"
65 echo "Format huge device"
66 nr_blks=2100000 # 2^21 plus a little more
67 sectors=$(( (nr_blks * 3) * blksz / 512 )) # each AG must have > 2^21 blocks
68 _dmhugedisk_init $sectors
69 _mkfs_dev -d agcount=2 $DMHUGEDISK_DEV
70 _mount $DMHUGEDISK_DEV $SCRATCH_MNT
71 xfs_info $SCRATCH_MNT >> $seqres.full
73 echo "Create the original file blocks"
75 blksz="$(_get_block_size $testdir)"
76 $XFS_IO_PROG -f -c "falloc 0 $((nr_blks * blksz))" $testdir/file1 >> $seqres.full
78 # make sure the allocator didn't allocate more than the needed two extents
79 echo "Check extent count"
80 xfs_bmap -l -p -v $testdir/file1 | grep '^[[:space:]]*2:' -q && xfs_bmap -l -p -v $testdir/file1
81 inum=$(stat -c '%i' $testdir/file1)
84 echo "Check bmap count"
85 nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
86 test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
87 #xfs_db -c "agf 0" -c p -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
89 echo "Check rmap count"
90 nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
91 test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
93 echo "Check and fake-repair huge filesystem" | tee -a $seqres.full
94 $XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
95 $XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1
96 test $? -eq 0 || echo "xfs_repair -n failed, see $seqres.full"
98 echo "Real repair huge filesystem" | tee -a $seqres.full
99 $XFS_REPAIR_PROG $DMHUGEDISK_DEV >> $seqres.full 2>&1
100 test $? -eq 0 || echo "xfs_repair failed, see $seqres.full"
102 echo "Check bmap count again"
103 nr_bmaps=$(xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV | grep 'data offset' | wc -l)
104 test $nr_bmaps -gt 1 || xfs_db -c "inode $inum" -c "bmap" $DMHUGEDISK_DEV
106 echo "Check rmap count again"
107 nr_rmaps=$(xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0" | wc -l)
108 test $nr_rmaps -eq 1 || xfs_db -c 'agf 0' -c 'addr rmaproot' -c 'p' $DMHUGEDISK_DEV | grep ",$inum,[0-9]*,1,0,0"
110 echo "Check and fake-repair huge filesystem again" | tee -a $seqres.full
111 $XFS_DB_PROG -c 'check' $DMHUGEDISK_DEV
112 $XFS_REPAIR_PROG -n $DMHUGEDISK_DEV >> $seqres.full 2>&1