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