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