ext4: Make the length of the mb_history file tunable
In memory-constrained systems with many partitions, the ~68K for each partition for the mb_history buffer can be excessive. This patch adds a new mount option, mb_history_length, as well as a way of setting the default via a module parameter (or via a sysfs parameter in /sys/module/ext4/parameter/default_mb_history_length). If the mb_history_length is set to zero, the mb_history facility is disabled entirely. Signed-off-by: Curt Wohlgemuth <curtw@google.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
This commit is contained in:

committed by
Theodore Ts'o

parent
bb23c20a85
commit
f40339031b
@@ -2413,7 +2413,8 @@ static void ext4_mb_history_release(struct super_block *sb)
|
||||
|
||||
if (sbi->s_proc != NULL) {
|
||||
remove_proc_entry("mb_groups", sbi->s_proc);
|
||||
remove_proc_entry("mb_history", sbi->s_proc);
|
||||
if (sbi->s_mb_history_max)
|
||||
remove_proc_entry("mb_history", sbi->s_proc);
|
||||
}
|
||||
kfree(sbi->s_mb_history);
|
||||
}
|
||||
@@ -2424,17 +2425,17 @@ static void ext4_mb_history_init(struct super_block *sb)
|
||||
int i;
|
||||
|
||||
if (sbi->s_proc != NULL) {
|
||||
proc_create_data("mb_history", S_IRUGO, sbi->s_proc,
|
||||
&ext4_mb_seq_history_fops, sb);
|
||||
if (sbi->s_mb_history_max)
|
||||
proc_create_data("mb_history", S_IRUGO, sbi->s_proc,
|
||||
&ext4_mb_seq_history_fops, sb);
|
||||
proc_create_data("mb_groups", S_IRUGO, sbi->s_proc,
|
||||
&ext4_mb_seq_groups_fops, sb);
|
||||
}
|
||||
|
||||
sbi->s_mb_history_max = 1000;
|
||||
sbi->s_mb_history_cur = 0;
|
||||
spin_lock_init(&sbi->s_mb_history_lock);
|
||||
i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history);
|
||||
sbi->s_mb_history = kzalloc(i, GFP_KERNEL);
|
||||
sbi->s_mb_history = i ? kzalloc(i, GFP_KERNEL) : NULL;
|
||||
/* if we can't allocate history, then we simple won't use it */
|
||||
}
|
||||
|
||||
@@ -2444,7 +2445,7 @@ ext4_mb_store_history(struct ext4_allocation_context *ac)
|
||||
struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
|
||||
struct ext4_mb_history h;
|
||||
|
||||
if (unlikely(sbi->s_mb_history == NULL))
|
||||
if (sbi->s_mb_history == NULL)
|
||||
return;
|
||||
|
||||
if (!(ac->ac_op & sbi->s_mb_history_filter))
|
||||
|
Reference in New Issue
Block a user