summaryrefslogtreecommitdiff
path: root/misc/mke2fs.c
diff options
context:
space:
mode:
authorAndreas Dilger <adilger@clusterfs.com>2007-05-22 16:04:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2007-05-22 16:04:51 -0400
commitdcf7b091c3efb2e6218a1f139ef2823db9d7c4bb (patch)
tree177cea945547723de13b021c3fb9219eb54872e7 /misc/mke2fs.c
parent96c6a3acd377698cb99ffd9925bec9b20ca4f6f9 (diff)
downloade2fsprogs-dcf7b091c3efb2e6218a1f139ef2823db9d7c4bb.tar.gz
mke2fs: Add check to make sure inode_size * num_inodes isn't too big
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>
Diffstat (limited to 'misc/mke2fs.c')
-rw-r--r--misc/mke2fs.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 0a371379..737e3da5 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -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
*/