From 2d34a25f81d6868387c2b21e8d6d25291c1069db Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 14 Jun 2011 14:30:22 -0400 Subject: [PATCH] mke2fs: add support for cluster size in mke2fs.conf Add support for specifying the cluster size in mke2fs.conf Signed-off-by: "Theodore Ts'o" --- misc/mke2fs.c | 19 ++++++++++--------- misc/mke2fs.conf.5.in | 7 +++++++ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/misc/mke2fs.c b/misc/mke2fs.c index 69f94f0..cdf2281 100644 --- a/misc/mke2fs.c +++ b/misc/mke2fs.c @@ -1177,7 +1177,7 @@ out: static void PRS(int argc, char *argv[]) { int b, c; - int size; + int cluster_size = 0; char *tmp, **cpp; int blocksize = 0; int inode_ratio = 0; @@ -1305,16 +1305,14 @@ profile_error: cflag++; break; case 'C': - size = strtoul(optarg, &tmp, 0); - if (size < EXT2_MIN_CLUSTER_SIZE || - size > EXT2_MAX_CLUSTER_SIZE || *tmp) { + cluster_size = strtoul(optarg, &tmp, 0); + if (cluster_size < EXT2_MIN_CLUSTER_SIZE || + cluster_size > EXT2_MAX_CLUSTER_SIZE || *tmp) { com_err(program_name, 0, _("invalid fragment size - %s"), optarg); exit(1); } - fs_param.s_log_cluster_size = - int_log2(size >> EXT2_MIN_CLUSTER_LOG_SIZE); break; case 'g': fs_param.s_blocks_per_group = strtoul(optarg, &tmp, 0); @@ -1801,9 +1799,12 @@ profile_error: fs_param.s_log_block_size = int_log2(blocksize >> EXT2_MIN_BLOCK_LOG_SIZE); if (fs_param.s_feature_ro_compat & EXT4_FEATURE_RO_COMPAT_BIGALLOC) { - if (fs_param.s_log_cluster_size == 0) - fs_param.s_log_cluster_size = - fs_param.s_log_block_size + 4; + if (!cluster_size) + cluster_size = get_int_from_profile(fs_types, + "cluster_size", + blocksize*4); + fs_param.s_log_cluster_size = + int_log2(cluster_size >> EXT2_MIN_CLUSTER_LOG_SIZE); } else fs_param.s_log_cluster_size = fs_param.s_log_block_size; diff --git a/misc/mke2fs.conf.5.in b/misc/mke2fs.conf.5.in index b0f1ccc..b2c7a57 100644 --- a/misc/mke2fs.conf.5.in +++ b/misc/mke2fs.conf.5.in @@ -395,6 +395,13 @@ on a per-filesystem type basis. This relation is a boolean which specifies whether the .BR mke2fs (8) should attempt to discard device prior to filesystem creation. +.TP +.I cluster_size +This relation specifies the default cluster size if the bigalloc file +system feature is enabled. It can be overridden via the +.B \-C +command line option to +.BR mke2fs (8) .SH THE [devices] STANZA Each tag in the .I [devices] -- 1.8.3.1