7 # This script depends on "mke2fs -d", which is only in master and not maint,
8 # to populate the file directory tree poorly (namely that there are no
9 # contiguous blocks in the directory leaf and the extent tree is large).
11 # Once the "mke2fs -d" option is available on the "maint" branch, the
12 # above few lines should be deleted, along with the "image.gz" file.
14 TMPDIR=${TMPDIR:-"/tmp"}
21 SRC=$TMPDIR/$test_name.tmp
23 BASE=$SRC/$SUB/$(yes | tr -d '\n' | dd bs=$NAMELEN count=1 2> /dev/null)
24 TMPFILE=${TMPFILE:-"$TMPDIR/image"}
29 # calculate the number of files needed to create the directory extent tree
30 # deep enough to exceed the in-inode index and spill into an index block.
32 # dirents per block * extents per block * (index blocks > i_blocks)
33 NUM=$(((BSIZE / (NAMELEN + 8)) * (BSIZE / 12) * 2))
34 # Create source files. Unfortunately hard links will be copied as links,
35 # and blocks with only NULs will be turned into holes.
36 if [ ! -f $BASE.1 ]; then
37 for N in $(seq $NUM); do
42 # make filesystem with enough inodes and blocks to hold all the test files
45 echo "mke2fs -b $BSIZE -O dir_index,extent -d$SRC -N$NUM $TMPFILE $NUM" >> $OUT
46 $MKE2FS -b $BSIZE -O dir_index,extent -d$SRC -N$NUM $TMPFILE $NUM >> $OUT 2>&1
49 # Run e2fsck to convert dir to htree before deleting the files, as mke2fs
50 # doesn't do this. Run second e2fsck to verify there is no corruption yet.
52 EXP1=$test_dir/expect.pre.1
53 EXP2=$test_dir/expect.pre.2
54 OUT1=$test_name.pre.1.log
55 OUT2=$test_name.pre.2.log
56 DESCRIPTION="$(cat $test_dir/name) setup"
60 # generate a list of filenames for debugfs to delete, one from each leaf block
61 DELETE_LIST=$TMPDIR/delete.$$
62 $DEBUGFS -c -R "htree subdir" $TMPFILE 2>> $OUT |
63 grep -A2 "Reading directory block" |
64 awk '/yyyyy/ { print "rm '$SUB'/"$4 }' > $DELETE_LIST
65 $DEBUGFS -w -f $DELETE_LIST $TMPFILE >> $OUT 2>&1
67 cp $TMPFILE $TMPFILE.sav