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