Skip to content

Commit a0b30c1

Browse files
committed
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>
1 parent 1139575 commit a0b30c1

File tree

2 files changed

+11
-40
lines changed

2 files changed

+11
-40
lines changed

fs/ext4/mballoc.c

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,18 @@
2323

2424
#include "ext4_jbd2.h"
2525
#include "mballoc.h"
26-
#include <linux/debugfs.h>
2726
#include <linux/log2.h>
27+
#include <linux/module.h>
2828
#include <linux/slab.h>
2929
#include <trace/events/ext4.h>
3030

31+
#ifdef CONFIG_EXT4_DEBUG
32+
ushort ext4_mballoc_debug __read_mostly;
33+
34+
module_param_named(mballoc_debug, ext4_mballoc_debug, ushort, 0644);
35+
MODULE_PARM_DESC(mballoc_debug, "Debugging level for ext4's mballoc");
36+
#endif
37+
3138
/*
3239
* MUSTDO:
3340
* - test ext4_ext_search_left() and ext4_ext_search_right()
@@ -2660,40 +2667,6 @@ static void ext4_free_data_callback(struct super_block *sb,
26602667
mb_debug(1, "freed %u blocks in %u structures\n", count, count2);
26612668
}
26622669

2663-
#ifdef CONFIG_EXT4_DEBUG
2664-
u8 mb_enable_debug __read_mostly;
2665-
2666-
static struct dentry *debugfs_dir;
2667-
static struct dentry *debugfs_debug;
2668-
2669-
static 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-
2679-
static void ext4_remove_debugfs_entry(void)
2680-
{
2681-
debugfs_remove(debugfs_debug);
2682-
debugfs_remove(debugfs_dir);
2683-
}
2684-
2685-
#else
2686-
2687-
static void __init ext4_create_debugfs_entry(void)
2688-
{
2689-
}
2690-
2691-
static void ext4_remove_debugfs_entry(void)
2692-
{
2693-
}
2694-
2695-
#endif
2696-
26972670
int __init ext4_init_mballoc(void)
26982671
{
26992672
ext4_pspace_cachep = KMEM_CACHE(ext4_prealloc_space,
@@ -2715,7 +2688,6 @@ int __init ext4_init_mballoc(void)
27152688
kmem_cache_destroy(ext4_ac_cachep);
27162689
return -ENOMEM;
27172690
}
2718-
ext4_create_debugfs_entry();
27192691
return 0;
27202692
}
27212693

@@ -2730,7 +2702,6 @@ void ext4_exit_mballoc(void)
27302702
kmem_cache_destroy(ext4_ac_cachep);
27312703
kmem_cache_destroy(ext4_free_data_cachep);
27322704
ext4_groupinfo_destroy_slabs();
2733-
ext4_remove_debugfs_entry();
27342705
}
27352706

27362707

@@ -3876,7 +3847,7 @@ static void ext4_mb_show_ac(struct ext4_allocation_context *ac)
38763847
struct super_block *sb = ac->ac_sb;
38773848
ext4_group_t ngroups, i;
38783849

3879-
if (!mb_enable_debug ||
3850+
if (!ext4_mballoc_debug ||
38803851
(EXT4_SB(sb)->s_mount_flags & EXT4_MF_FS_ABORTED))
38813852
return;
38823853

fs/ext4/mballoc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@
3737
/*
3838
*/
3939
#ifdef CONFIG_EXT4_DEBUG
40-
extern u8 mb_enable_debug;
40+
extern ushort ext4_mballoc_debug;
4141

4242
#define mb_debug(n, fmt, a...) \
4343
do { \
44-
if ((n) <= mb_enable_debug) { \
44+
if ((n) <= ext4_mballoc_debug) { \
4545
printk(KERN_DEBUG "(%s, %d): %s: ", \
4646
__FILE__, __LINE__, __func__); \
4747
printk(fmt, ## a); \

0 commit comments

Comments
 (0)