2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # exercise xfs_repair - ensure repeated use doesn't corrupt
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
20 # get standard environment, filters and checks
27 echo "Repairing, round 0" >> $seqres.full
28 _scratch_xfs_repair 2>&1 | _filter_repair | tee -a $seqres.full >$tmp.0
31 echo "Repairing, iteration $i" | tee -a $seqres.full
32 _scratch_xfs_repair 2>&1 | _filter_repair >$tmp.$i
33 diff $tmp.0 $tmp.$i >> $seqres.full
35 echo "ERROR: repair round $i differs to round 0 (see $seqres.full)" | tee -a $seqres.full
38 # echo all interesting stuff...
40 s/(rebuilding directory inode) (\d+)/\1 INO/g;
41 s/internal log/<TYPEOF> log/g;
42 s/external log on \S+/<TYPEOF> log/g;
49 # prototype file to create various directory forms
55 # take inode size into account for non-shortform directories...
56 [ $total -gt 0 ] && total=`expr $total \* $isize / 512`
67 while [ $count -lt $total ]
70 cat >>$tmp.proto <<EOF
71 ${count}_of_${total}_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx ---755 3 1 /bin/true
77 # real QA test starts here
81 _require_no_large_scratch_dev
83 # mkfs cannot create a filesystem with protofiles if realtime is enabled, so
84 # don't run this test if the rtinherit is anywhere in the mkfs options.
85 echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
86 _notrun "Cannot mkfs with a protofile and -d rtinherit."
88 # sanity test - default + one root directory entry
89 # Note: must do this proto/mkfs now for later inode size calcs
91 echo "=== one entry (shortform)"
92 _scratch_mkfs_xfs -p $tmp.proto >$tmp.mkfs0 2>&1
93 _filter_mkfs <$tmp.mkfs0 >/dev/null 2>$tmp.mkfs
97 # block-form root directory & repeat
99 echo "=== twenty entries (block form)"
100 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1
103 # leaf-form root directory & repeat
105 echo "=== thousand entries (leaf form)"
106 _scratch_mkfs_xfs -p $tmp.proto | _filter_mkfs >/dev/null 2>&1