In the interests of SMP scalability the ext2 free blocks and free inodes
counters are "approximate".  But there is a piece of code in the Orlov
allocator which fails due to boundary conditions on really small
filesystems.

Fix that up via a final allocation pass which simply uses first-fit for
allocatiopn of a directory inode.


 fs/ext3/ialloc.c |    9 +++++++++
 1 files changed, 9 insertions(+)

diff -puN fs/ext3/ialloc.c~ext3-orlov-approx-counter-fix fs/ext3/ialloc.c
--- 25/fs/ext3/ialloc.c~ext3-orlov-approx-counter-fix	2003-04-17 19:36:40.000000000 -0700
+++ 25-akpm/fs/ext3/ialloc.c	2003-04-17 19:48:24.000000000 -0700
@@ -330,6 +330,15 @@ fallback:
 			return group;
 	}
 
+	if (avefreei) {
+		/*
+		 * The free-inodes counter is approximate, and for really small
+		 * filesystems the above test can fail to find any blockgroups
+		 */
+		avefreei = 0;
+		goto fallback;
+	}
+
 	return -1;
 }
 

_