1OUT=$test_name.log 2EXP=$test_dir/expect 3E2FSCK=../e2fsck/e2fsck 4 5NAMELEN=255 6DIRENT_SZ=8 7BLOCKSZ=1024 8INODESZ=128 9DIRENT_PER_LEAF=$((BLOCKSZ / (NAMELEN + DIRENT_SZ))) 10HEADER=32 11INDEX_SZ=8 12INDEX_L1=$(((BLOCKSZ - HEADER) / INDEX_SZ)) 13INDEX_L2=$(((BLOCKSZ - DIRENT_SZ) / INDEX_SZ)) 14DIRBLK=$((2 + INDEX_L1 * INDEX_L2)) 15ENTRIES=$((DIRBLK * DIRENT_PER_LEAF)) 16EXT4_LINK_MAX=65000 17if [ $ENTRIES -lt $((EXT4_LINK_MAX + 10)) ]; then 18 ENTRIES=$((EXT4_LINK_MAX + 10)) 19 DIRBLK=$((ENTRIES / DIRENT_PER_LEAF + 3)) 20fi 21# directory leaf blocks plus inode count and 25% for the rest of the fs 22FSIZE=$(((DIRBLK + EXT4_LINK_MAX * ((BLOCKSZ + INODESZ) / BLOCKSZ)) * 5 / 4)) 23 24$MKE2FS -b 1024 -O large_dir,uninit_bg -N $((ENTRIES + 50)) \ 25 -I $INODESZ -F $TMPFILE $FSIZE > $OUT.new 2>&1 26RC=$? 27if [ $RC -eq 0 ]; then 28{ 29 # First some initial fs setup to create indexed dir 30 echo "mkdir /foo" 31 echo "cd /foo" 32 touch $TMPFILE.tmp 33 echo "write $TMPFILE.tmp foofile" 34 i=0 35 while test $i -lt $DIRENT_PER_LEAF ; do 36 printf "mkdir d%0254u\n" $i 37 i=$((i + 1)); 38 done 39 echo "expand ./" 40 printf "mkdir d%0254u\n" $i 41} | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new 42 RC=$? 43 # e2fsck should optimize the dir to become indexed 44 $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1 45 status=$? 46 echo Exit status is $status >> $OUT.new 47fi 48 49if [ $RC -eq 0 ]; then 50{ 51 START=$SECONDS 52 i=$(($DIRENT_PER_LEAF+1)) 53 last=$i 54 echo "cd /foo" 55 while test $i -lt $ENTRIES ; do 56 ELAPSED=$((SECONDS - START)) 57 if test $((i % 5000)) -eq 0 -a $ELAPSED -gt 10; then 58 RATE=$(((i - last) / ELAPSED)) 59 echo "$test_name: $i/$ENTRIES links, ${ELAPSED}s @ $RATE/s" >&2 60 START=$SECONDS 61 last=$i 62 fi 63 if test $i -lt $((EXT4_LINK_MAX + 10)); then 64 printf "mkdir d%0254u\n" $i 65 else 66 printf "ln foofile f%0254u\n" $i 67 fi 68 i=$((i + 1)) 69 done 70} | $DEBUGFS -w $TMPFILE > /dev/null 2>> $OUT.new 71 RC=$? 72fi 73 74if [ $RC -eq 0 ]; then 75 $E2FSCK -yfD $TMPFILE >> $OUT.new 2>&1 76 status=$? 77 echo Exit status is $status >> $OUT.new 78 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new > $OUT 79 rm -f $OUT.new 80 81 cmp -s $OUT $EXP 82 RC=$? 83fi 84if [ $RC -eq 0 ]; then 85 echo "$test_name: $test_description: ok" 86 touch $test_name.ok 87else 88 echo "$test_name: $test_description: failed" 89 diff -u $EXP $OUT > $test_name.failed 90fi 91