Skip to contentSkip to conversation

Many inodes in filesystem.

PATCH Applied Girish Shilamkar 2 participants 2 messages Jul 24, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 7/13 Many inodes in filesystem.

Handle filesystems with many hard links that have more than ~700M inodes. The float variable lacks precision at this scale.

lib/ext2fs/icount.c +4 -0
Index: e2fsprogs-1.40.1/lib/ext2fs/icount.c
===================================================================
@@ -376,6 +376,10 @@ static struct ext2_icount_el *get_icount
 					range = 0.1;
 			}
 			mid = low + ((int) (range * (high-low)));
+			if (mid > high)
+				mid = high;
+			if (mid < low)
+				mid = low;
 		}
 #endif
 		if (ino == icount->list[mid].ino) {
#1 lore raw
Quoted 2 lines · Girish Shilamkar

Handle filesystems with many hard links that have more than ~700M inodes. The float variable lacks precision at this scale.

This was fixed in e2fsprogs mainline a slightly different way. Just above it:

				range = ((float) (ino - lowval)) /
					(highval - lowval);
				if (range > 0.9)
					range = 0.9;
				if (range < 0.1)
					range = 0.1;

The problem with just correcting the midpoint calculation as you proposed in your patch is that you could end up doing a linear search through the whole array in some really abberrant cases. With this fix applied in e2fsprogs, the patch below isn't required.

Regards,

- Ted

Quoted 21 lines

Index: e2fsprogs-1.40.1/lib/ext2fs/icount.c
===================================================================

lib/ext2fs/icount.c +4 -0
@@ -376,6 +376,10 @@ static struct ext2_icount_el *get_icount
 					range = 0.1;
 			}
 			mid = low + ((int) (range * (high-low)));
+			if (mid > high)
+				mid = high;
+			if (mid < low)
+				mid = low;
 		}
 #endif
 		if (ino == icount->list[mid].ino) {