Skip to content

Commit 0f49d5d

Browse files
Jose R. Santostytso
authored andcommitted
jbd2: Move jbd2-debug file to debugfs
The jbd2-debug file used to be located in /proc/sys/fs/jbd2-debug, but it incorrectly used create_proc_entry() instead of the sysctl routines, and no proc entry was ever created. Instead of fixing this we might as well move the jbd2-debug file to debugfs which would be the preferred location for this kind of tunable. The new location is now /sys/kernel/debug/jbd2/jbd2-debug. Signed-off-by: Jose R. Santos <jrs@us.ibm.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent e23291b commit 0f49d5d

File tree

3 files changed

+33
-46
lines changed

3 files changed

+33
-46
lines changed

fs/Kconfig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ config JBD2
251251

252252
config JBD2_DEBUG
253253
bool "JBD2 (ext4dev/ext4) debugging support"
254-
depends on JBD2
254+
depends on JBD2 && DEBUG_FS
255255
help
256256
If you are using the ext4dev/ext4 journaled file system (or
257257
potentially any other filesystem/device using JBD2), this option
@@ -260,10 +260,10 @@ config JBD2_DEBUG
260260
By default, the debugging output will be turned off.
261261

262262
If you select Y here, then you will be able to turn on debugging
263-
with "echo N > /proc/sys/fs/jbd2-debug", where N is a number between
264-
1 and 5. The higher the number, the more debugging output is
265-
generated. To turn debugging off again, do
266-
"echo 0 > /proc/sys/fs/jbd2-debug".
263+
with "echo N > /sys/kernel/debug/jbd2/jbd2-debug", where N is a
264+
number between 1 and 5. The higher the number, the more debugging
265+
output is generated. To turn debugging off again, do
266+
"echo 0 > /sys/kernel/debug/jbd2/jbd2-debug".
267267

268268
config FS_MBCACHE
269269
# Meta block cache for Extended Attributes (ext2/ext3/ext4)

fs/jbd2/journal.c

Lines changed: 27 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include <linux/kthread.h>
3636
#include <linux/poison.h>
3737
#include <linux/proc_fs.h>
38+
#include <linux/debugfs.h>
3839

3940
#include <asm/uaccess.h>
4041
#include <asm/page.h>
@@ -1951,64 +1952,50 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
19511952
}
19521953

19531954
/*
1954-
* /proc tunables
1955+
* debugfs tunables
19551956
*/
19561957
#if defined(CONFIG_JBD2_DEBUG)
1957-
int jbd2_journal_enable_debug;
1958+
u8 jbd2_journal_enable_debug;
19581959
EXPORT_SYMBOL(jbd2_journal_enable_debug);
19591960
#endif
19601961

1961-
#if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_PROC_FS)
1962+
#if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_DEBUG_FS)
19621963

1963-
static struct proc_dir_entry *proc_jbd_debug;
1964+
#define JBD2_DEBUG_NAME "jbd2-debug"
19641965

1965-
static int read_jbd_debug(char *page, char **start, off_t off,
1966-
int count, int *eof, void *data)
1967-
{
1968-
int ret;
1966+
struct dentry *jbd2_debugfs_dir, *jbd2_debug;
19691967

1970-
ret = sprintf(page + off, "%d\n", jbd2_journal_enable_debug);
1971-
*eof = 1;
1972-
return ret;
1968+
static void __init jbd2_create_debugfs_entry(void)
1969+
{
1970+
jbd2_debugfs_dir = debugfs_create_dir("jbd2", NULL);
1971+
if (jbd2_debugfs_dir)
1972+
jbd2_debug = debugfs_create_u8(JBD2_DEBUG_NAME, S_IRUGO,
1973+
jbd2_debugfs_dir,
1974+
&jbd2_journal_enable_debug);
19731975
}
19741976

1975-
static int write_jbd_debug(struct file *file, const char __user *buffer,
1976-
unsigned long count, void *data)
1977+
static void __exit jbd2_remove_debugfs_entry(void)
19771978
{
1978-
char buf[32];
1979-
1980-
if (count > ARRAY_SIZE(buf) - 1)
1981-
count = ARRAY_SIZE(buf) - 1;
1982-
if (copy_from_user(buf, buffer, count))
1983-
return -EFAULT;
1984-
buf[ARRAY_SIZE(buf) - 1] = '\0';
1985-
jbd2_journal_enable_debug = simple_strtoul(buf, NULL, 10);
1986-
return count;
1979+
if (jbd2_debug)
1980+
debugfs_remove(jbd2_debug);
1981+
if (jbd2_debugfs_dir)
1982+
debugfs_remove(jbd2_debugfs_dir);
19871983
}
19881984

1989-
#define JBD_PROC_NAME "sys/fs/jbd2-debug"
1985+
#else
19901986

1991-
static void __init create_jbd_proc_entry(void)
1987+
static void __init jbd2_create_debugfs_entry(void)
19921988
{
1993-
proc_jbd_debug = create_proc_entry(JBD_PROC_NAME, 0644, NULL);
1994-
if (proc_jbd_debug) {
1995-
/* Why is this so hard? */
1996-
proc_jbd_debug->read_proc = read_jbd_debug;
1997-
proc_jbd_debug->write_proc = write_jbd_debug;
1998-
}
1989+
do {
1990+
} while (0);
19991991
}
20001992

2001-
static void __exit jbd2_remove_jbd_proc_entry(void)
1993+
static void __exit jbd2_remove_debugfs_entry(void)
20021994
{
2003-
if (proc_jbd_debug)
2004-
remove_proc_entry(JBD_PROC_NAME, NULL);
1995+
do {
1996+
} while (0);
20051997
}
20061998

2007-
#else
2008-
2009-
#define create_jbd_proc_entry() do {} while (0)
2010-
#define jbd2_remove_jbd_proc_entry() do {} while (0)
2011-
20121999
#endif
20132000

20142001
struct kmem_cache *jbd2_handle_cache;
@@ -2067,7 +2054,7 @@ static int __init journal_init(void)
20672054
ret = journal_init_caches();
20682055
if (ret != 0)
20692056
jbd2_journal_destroy_caches();
2070-
create_jbd_proc_entry();
2057+
jbd2_create_debugfs_entry();
20712058
return ret;
20722059
}
20732060

@@ -2078,7 +2065,7 @@ static void __exit journal_exit(void)
20782065
if (n)
20792066
printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
20802067
#endif
2081-
jbd2_remove_jbd_proc_entry();
2068+
jbd2_remove_debugfs_entry();
20822069
jbd2_journal_destroy_caches();
20832070
}
20842071

include/linux/jbd2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
* CONFIG_JBD2_DEBUG is on.
5858
*/
5959
#define JBD_EXPENSIVE_CHECKING
60-
extern int jbd2_journal_enable_debug;
60+
extern u8 jbd2_journal_enable_debug;
6161

6262
#define jbd_debug(n, f, a...) \
6363
do { \

0 commit comments

Comments
 (0)