aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2011-09-09 19:02:51 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-09-09 19:02:51 -0400
commit27baebb849d46d901e756e6502b0a65a62e43771 (patch)
treeed72a295f62656beb29038358d99902b55b3438f
parentf975d6bcc7a698a10cc755115e27d3612dcfe322 (diff)
ext4: tune mballoc's default group prealloc size for bigalloc file systems
The default group preallocation size had been previously set to 512 blocks/clusters, regardless of the block/cluster size. This is probably too big for large cluster sizes. So adjust the default so that it is 2 megabytes or 32 clusters, whichever is larger. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
-rw-r--r--fs/ext4/mballoc.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index f8e37cf2c2dd..63dd56703342 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -126,7 +126,8 @@
126 * list. In case of inode preallocation we follow a list of heuristics 126 * list. In case of inode preallocation we follow a list of heuristics
127 * based on file size. This can be found in ext4_mb_normalize_request. If 127 * based on file size. This can be found in ext4_mb_normalize_request. If
128 * we are doing a group prealloc we try to normalize the request to 128 * we are doing a group prealloc we try to normalize the request to
129 * sbi->s_mb_group_prealloc. Default value of s_mb_group_prealloc is 129 * sbi->s_mb_group_prealloc. The default value of s_mb_group_prealloc is
130 * dependent on the cluster size; for non-bigalloc file systems, it is
130 * 512 blocks. This can be tuned via 131 * 512 blocks. This can be tuned via
131 * /sys/fs/ext4/<partition>/mb_group_prealloc. The value is represented in 132 * /sys/fs/ext4/<partition>/mb_group_prealloc. The value is represented in
132 * terms of number of blocks. If we have mounted the file system with -O 133 * terms of number of blocks. If we have mounted the file system with -O
@@ -2473,7 +2474,20 @@ int ext4_mb_init(struct super_block *sb, int needs_recovery)
2473 sbi->s_mb_stats = MB_DEFAULT_STATS; 2474 sbi->s_mb_stats = MB_DEFAULT_STATS;
2474 sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD; 2475 sbi->s_mb_stream_request = MB_DEFAULT_STREAM_THRESHOLD;
2475 sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS; 2476 sbi->s_mb_order2_reqs = MB_DEFAULT_ORDER2_REQS;
2476 sbi->s_mb_group_prealloc = MB_DEFAULT_GROUP_PREALLOC; 2477 /*
2478 * The default group preallocation is 512, which for 4k block
2479 * sizes translates to 2 megabytes. However for bigalloc file
2480 * systems, this is probably too big (i.e, if the cluster size
2481 * is 1 megabyte, then group preallocation size becomes half a
2482 * gigabyte!). As a default, we will keep a two megabyte
2483 * group pralloc size for cluster sizes up to 64k, and after
2484 * that, we will force a minimum group preallocation size of
2485 * 32 clusters. This translates to 8 megs when the cluster
2486 * size is 256k, and 32 megs when the cluster size is 1 meg,
2487 * which seems reasonable as a default.
2488 */
2489 sbi->s_mb_group_prealloc = max(MB_DEFAULT_GROUP_PREALLOC >>
2490 sbi->s_cluster_bits, 32);
2477 /* 2491 /*
2478 * If there is a s_stripe > 1, then we set the s_mb_group_prealloc 2492 * If there is a s_stripe > 1, then we set the s_mb_group_prealloc
2479 * to the lowest multiple of s_stripe which is bigger than 2493 * to the lowest multiple of s_stripe which is bigger than