aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/mballoc.c
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-02-09 16:28:20 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-02-09 16:28:20 -0500
commita0b30c12297eb63e9b994164f9c0937d29b9352d (patch)
tree5d72a1352fba8bda1f61ae38ae2857545e982cc0 /fs/ext4/mballoc.c
parent1139575a927010390c6b38e4215a6d741b056074 (diff)
ext4: use module parameters instead of debugfs for mballoc_debug
There are multiple reasons to move away from debugfs. First of all, we are only using it for a single parameter, and it is much more complicated to set up (some 30 lines of code compared to 3), and one more thing that might fail while loading the ext4 module. Secondly, as a module paramter it can be specified as a boot option if ext4 is built into the kernel, or as a parameter when the module is loaded, and it can also be manipulated dynamically under /sys/module/ext4/parameters/mballoc_debug. So it is more flexible. Ultimately we want to move away from using mb_debug() towards tracepoints, but for now this is still a useful simplification of the code base. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/mballoc.c')
-rw-r--r--fs/ext4/mballoc.c47
1 files changed, 9 insertions, 38 deletions
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
index e350885aec30..6540ebe058e3 100644
--- a/fs/ext4/mballoc.c
+++ b/fs/ext4/mballoc.c
@@ -23,11 +23,18 @@
23 23
24#include "ext4_jbd2.h" 24#include "ext4_jbd2.h"
25#include "mballoc.h" 25#include "mballoc.h"
26#include <linux/debugfs.h>
27#include <linux/log2.h> 26#include <linux/log2.h>
27#include <linux/module.h>
28#include <linux/slab.h> 28#include <linux/slab.h>
29#include <trace/events/ext4.h> 29#include <trace/events/ext4.h>
30 30
31#ifdef CONFIG_EXT4_DEBUG
32ushort ext4_mballoc_debug __read_mostly;
33
34module_param_named(mballoc_debug, ext4_mballoc_debug, ushort, 0644);
35MODULE_PARM_DESC(mballoc_debug, "Debugging level for ext4's mballoc");
36#endif
37
31/* 38/*
32 * MUSTDO: 39 * MUSTDO:
33 * - test ext4_ext_search_left() and ext4_ext_search_right() 40 * - test ext4_ext_search_left() and ext4_ext_search_right()
@@ -2660,40 +2667,6 @@ static void ext4_free_data_callback(struct super_block *sb,
2660 mb_debug(1, "freed %u blocks in %u structures\n", count, count2); 2667 mb_debug(1, "freed %u blocks in %u structures\n", count, count2);
2661} 2668}
2662 2669
2663#ifdef CONFIG_EXT4_DEBUG
2664u8 mb_enable_debug __read_mostly;
2665
2666static struct dentry *debugfs_dir;
2667static struct dentry *debugfs_debug;
2668
2669static void __init ext4_create_debugfs_entry(void)
2670{
2671 debugfs_dir = debugfs_create_dir("ext4", NULL);
2672 if (debugfs_dir)
2673 debugfs_debug = debugfs_create_u8("mballoc-debug",
2674 S_IRUGO | S_IWUSR,
2675 debugfs_dir,
2676 &mb_enable_debug);
2677}
2678
2679static void ext4_remove_debugfs_entry(void)
2680{
2681 debugfs_remove(debugfs_debug);
2682 debugfs_remove(debugfs_dir);
2683}
2684
2685#else
2686
2687static void __init ext4_create_debugfs_entry(void)
2688{
2689}
2690
2691static void ext4_remove_debugfs_entry(void)
2692{
2693}
2694
2695#endif
2696
2697int __init ext4_init_mballoc(void) 2670int __init ext4_init_mballoc(void)
2698{ 2671{
2699 ext4_pspace_cachep = KMEM_CACHE(ext4_prealloc_space, 2672 ext4_pspace_cachep = KMEM_CACHE(ext4_prealloc_space,
@@ -2715,7 +2688,6 @@ int __init ext4_init_mballoc(void)
2715 kmem_cache_destroy(ext4_ac_cachep); 2688 kmem_cache_destroy(ext4_ac_cachep);
2716 return -ENOMEM; 2689 return -ENOMEM;
2717 } 2690 }
2718 ext4_create_debugfs_entry();
2719 return 0; 2691 return 0;
2720} 2692}
2721 2693
@@ -2730,7 +2702,6 @@ void ext4_exit_mballoc(void)
2730 kmem_cache_destroy(ext4_ac_cachep); 2702 kmem_cache_destroy(ext4_ac_cachep);
2731 kmem_cache_destroy(ext4_free_data_cachep); 2703 kmem_cache_destroy(ext4_free_data_cachep);
2732 ext4_groupinfo_destroy_slabs(); 2704 ext4_groupinfo_destroy_slabs();
2733 ext4_remove_debugfs_entry();
2734} 2705}
2735 2706
2736 2707
@@ -3876,7 +3847,7 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac)
3876 struct super_block *sb = ac->ac_sb; 3847 struct super_block *sb = ac->ac_sb;
3877 ext4_group_t ngroups, i; 3848 ext4_group_t ngroups, i;
3878 3849
3879 if (!mb_enable_debug || 3850 if (!ext4_mballoc_debug ||
3880 (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED)) 3851 (EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED))
3881 return; 3852 return;
3882 3853