Whamcloud - gitweb
initialize.c (ext2fs_initialize): If the user specifies a really
authorTheodore Ts'o <tytso@mit.edu>
Mon, 20 Jan 2003 02:01:22 +0000 (21:01 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 20 Jan 2003 02:01:22 +0000 (21:01 -0500)
large number of inodes, then reduce the number of blocks
per group until we find a workable set of filesystem
parameters.

ext2_err.et.in (EXT2_ET_TOO_MANY_INODES): Add new error code.

lib/ext2fs/ChangeLog
lib/ext2fs/ext2_err.et.in
lib/ext2fs/initialize.c

index 930badd..749bafb 100644 (file)
@@ -1,3 +1,12 @@
+2003-01-19  Theodore Ts'o  <tytso@mit.edu>
+
+       * initialize.c (ext2fs_initialize): If the user specifies a really
+               large number of inodes, then reduce the number of blocks
+               per group until we find a workable set of filesystem
+               parameters.
+
+       * ext2_err.et.in (EXT2_ET_TOO_MANY_INODES): Add new error code.
+
 2002-11-09  Theodore Ts'o  <tytso@mit.edu>
 
        * Release of E2fsprogs 1.32
index b08f863..b9ad5f0 100644 (file)
@@ -281,5 +281,8 @@ ec  EXT2_ET_DIRHASH_UNSUPP,
 ec     EXT2_ET_BAD_EA_BLOCK_NUM,
        "Illegal extended attribute block number"
 
+ec     EXT2_ET_TOO_MANY_INODES,
+       "Cannot create filesystem with requested number of inodes"
+
        end
 
index f5552e6..32b9c87 100644 (file)
@@ -189,8 +189,17 @@ retry:
         */
        ipg = (super->s_inodes_count + fs->group_desc_count - 1) /
                fs->group_desc_count;
-       if (ipg > fs->blocksize * 8)
-               ipg = fs->blocksize * 8;
+       if (ipg > fs->blocksize * 8) {
+               if (super->s_blocks_per_group >= 256) {
+                       /* Try again with slightly different parameters */
+                       super->s_blocks_per_group -= 8;
+                       super->s_blocks_count = param->s_blocks_count;
+                       super->s_frags_per_group = super->s_blocks_per_group *
+                               frags_per_block;
+                       goto retry;
+               } else
+                       return EXT2_ET_TOO_MANY_INODES;
+       }
 
        if (ipg > EXT2_MAX_INODES_PER_GROUP(super))
                ipg = EXT2_MAX_INODES_PER_GROUP(super);
@@ -239,7 +248,11 @@ retry:
         * being clever is tricky...
         */
        overhead = (int) (3 + fs->desc_blocks + fs->inode_blocks_per_group);
-       
+
+       /* This can only happen if the user requested too many inodes */
+       if (overhead > super->s_blocks_per_group)
+               return EXT2_ET_TOO_MANY_INODES;
+
        /*
         * See if the last group is big enough to support the
         * necessary data structures.  If not, we need to get rid of