4 # Test xfs_repair on fragmented multi-block dir2 fs
6 #-----------------------------------------------------------------------
7 # Copyright (c) Red Hat, Inc. 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 #-----------------------------------------------------------------------
25 seqres=$RESULT_DIR/$seq
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
32 status=1 # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
41 # get standard environment, filters and checks
46 _supported_os IRIX Linux
48 # real QA test starts here
51 _scratch_mkfs_xfs -n size=16k -d size=128m >> $seqres.full 2>&1
54 # First we cause very badly fragmented freespace, then
55 # make some multiblock directories in the filesystem, which
56 # should come out very fragmented as a result
58 # Step 1: Cause badly fragmented free space
59 mkdir $SCRATCH_MNT/fragdir
60 for I in `seq 0 27200`; do
61 (echo data > $SCRATCH_MNT/fragdir/f$I) >> $seqres.full 2>&1
65 for I in `seq 0 2 27200`; do
66 rm -f $SCRATCH_MNT/fragdir/f$I >> $seqres.full 2>&1
70 # Soak up any remaining freespace
71 xfs_io -f -c "pwrite 0 16m" -c "fsync" $SCRATCH_MNT/space_file.large >> $seqres.full 2>&1
73 # Take a look at freespace for any post-mortem on the test
75 xfs_db -c freesp $SCRATCH_DEV >> $seqres.full 2>&1
78 # Step 2: Make a bunch of (hopefully fragmented) multiblock
82 mkdir $SCRATCH_MNT/S_IFDIR.FMT_LOCAL
83 touch $SCRATCH_MNT/S_IFDIR.FMT_LOCAL/localdirfile
86 mkdir $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS
87 for I in `seq 1 100`; do
88 touch $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS/extent_dir_file_$I
91 for I in `seq 10 2 20` 100; do
92 rm -f $SCRATCH_MNT/S_IFDIR.FMT_EXTENTS/extent_dir_file_$I
96 mkdir $SCRATCH_MNT/S_IFDIR.FMT_BTREE
97 for I in `seq 1 1000`; do
98 touch $SCRATCH_MNT/S_IFDIR.FMT_BTREE/btree_dir_file_$I
101 for I in `seq 10 2 20` 1000; do
102 rm -f $SCRATCH_MNT/S_IFDIR.FMT_BTREE/btree_dir_file_$I
105 # Dave's special hack - grow freespace tree
106 mkdir $SCRATCH_MNT/S_IFDIR.FMT_BTREE2
107 for I in `seq 1 5000`; do
108 touch $SCRATCH_MNT/S_IFDIR.FMT_BTREE2/btree2_dir_file_$I
110 # Remove every other (odds)
111 for I in `seq 1 2 5000`; do
112 rm -f $SCRATCH_MNT/S_IFDIR.FMT_BTREE2/btree2_dir_file_$I
116 # Can xfs_repair and xfs_check cope with this monster?
117 _scratch_xfs_repair >> $seqres.full 2>&1 || _fail "xfs_repair failed"
118 xfs_check $SCRATCH_DEV >> $seqres.full 2>&1 || _fail "xfs_check failed"
120 # Yes they can! Now...
121 # Can xfs_metadump cope with this monster?
122 xfs_metadump $SCRATCH_DEV $tmp.metadump || _fail "xfs_metadump failed"
123 xfs_mdrestore $tmp.metadump $tmp.img || _fail "xfs_mdrestore failed"
124 xfs_repair $tmp.img >> $seqres.full 2>&1 || _fail "xfs_repair of metadump failed"
126 # Yes it can; success, all done