aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index dbd47eac13ec..df75855ae6f7 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -2413,7 +2413,8 @@ static void ext4_mb_history_release(struct super_block *sb)
2413 2413
2414 if (sbi->s_proc != NULL) { 2414 if (sbi->s_proc != NULL) {
2415 remove_proc_entry("mb_groups", sbi->s_proc); 2415 remove_proc_entry("mb_groups", sbi->s_proc);
2416 remove_proc_entry("mb_history", sbi->s_proc); 2416 if (sbi->s_mb_history_max)
2417 remove_proc_entry("mb_history", sbi->s_proc);
2417 } 2418 }
2418 kfree(sbi->s_mb_history); 2419 kfree(sbi->s_mb_history);
2419} 2420}
@@ -2424,17 +2425,17 @@ static void ext4_mb_history_init(struct super_block *sb)
2424 int i; 2425 int i;
2425 2426
2426 if (sbi->s_proc != NULL) { 2427 if (sbi->s_proc != NULL) {
2427 proc_create_data("mb_history", S_IRUGO, sbi->s_proc, 2428 if (sbi->s_mb_history_max)
2428 &ext4_mb_seq_history_fops, sb); 2429 proc_create_data("mb_history", S_IRUGO, sbi->s_proc,
2430 &ext4_mb_seq_history_fops, sb);
2429 proc_create_data("mb_groups", S_IRUGO, sbi->s_proc, 2431 proc_create_data("mb_groups", S_IRUGO, sbi->s_proc,
2430 &ext4_mb_seq_groups_fops, sb); 2432 &ext4_mb_seq_groups_fops, sb);
2431 } 2433 }
2432 2434
2433 sbi->s_mb_history_max = 1000;
2434 sbi->s_mb_history_cur = 0; 2435 sbi->s_mb_history_cur = 0;
2435 spin_lock_init(&sbi->s_mb_history_lock); 2436 spin_lock_init(&sbi->s_mb_history_lock);
2436 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history); 2437 i = sbi->s_mb_history_max * sizeof(struct ext4_mb_history);
2437 sbi->s_mb_history = kzalloc(i, GFP_KERNEL); 2438 sbi->s_mb_history = i ? kzalloc(i, GFP_KERNEL) : NULL;
2438 /* if we can't allocate history, then we simple won't use it */ 2439 /* if we can't allocate history, then we simple won't use it */
2439} 2440}
2440 2441
@@ -2444,7 +2445,7 @@ ext4_mb_store_history(struct ext4_allocation_context *ac)
2444 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb); 2445 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
2445 struct ext4_mb_history h; 2446 struct ext4_mb_history h;
2446 2447
2447 if (unlikely(sbi->s_mb_history == NULL)) 2448 if (sbi->s_mb_history == NULL)
2448 return; 2449 return;
2449 2450
2450 if (!(ac->ac_op & sbi->s_mb_history_filter)) 2451 if (!(ac->ac_op & sbi->s_mb_history_filter))