]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
mke2fs: Add check to make sure inode_size * num_inodes isn't too big
authorAndreas Dilger <adilger@clusterfs.com>
Tue, 22 May 2007 20:04:51 +0000 (16:04 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Tue, 22 May 2007 20:04:51 +0000 (16:04 -0400)
A quick patch to sanity check the inode ratio vs the inode size.  In
some cases Lustre users have tried specifying an inode size of 4096
bytes, while keeping an inode ratio of one inode per 4096 bytes.  I'm
sure more people will do this now that large inodes are available in
ext4 and documented in e2fsprogs.

Signed-off-by: Andreas Dilger <adilger@clusterfs.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
misc/ChangeLog
misc/mke2fs.c

index 4a96f75b06f5d85eb5bcb8c6ddd1528ca9e08a88..3b57d0cea574ef28e3d4748713a94250475834ce 100644 (file)
@@ -1,3 +1,8 @@
+2007-05-22  Theodore Tso  <tytso@mit.edu>
+
+       * mke2fs.c (PRS): Add sanity check if the inode size * inode count
+               is bigger than the filesystem size.     
+
 2007-05-18  Theodore Tso  <tytso@mit.edu>
 
        * mke2fs.c (main): Save the raid stride to the superblock
index 0a3713799654acc3f983ac2fc07130427bf38b50..737e3da579bd7c32f574d99fae189e37c19d1697 100644 (file)
@@ -1489,6 +1489,20 @@ static void PRS(int argc, char *argv[])
                ((__u64) fs_param.s_blocks_count * blocksize)
                        / inode_ratio;
 
+       if ((((long long)fs_param.s_inodes_count) *
+            (inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE)) >=
+           (((long long)fs_param.s_blocks_count) * 
+            EXT2_BLOCK_SIZE(&fs_param))) {
+               com_err(program_name, 0, _("inode_size (%u) * inodes_count "
+                                         "(%u) too big for a\n\t"
+                                         "filesystem with %lu blocks, "
+                                         "specify higher inode_ratio (-i)\n\t"
+                                         "or lower inode count (-N).\n"),
+                       inode_size ? inode_size : EXT2_GOOD_OLD_INODE_SIZE,
+                       fs_param.s_inodes_count, fs_param.s_blocks_count);
+               exit(1);
+       }
+
        /*
         * Calculate number of blocks to reserve
         */