diff options
author | Jose R. Santos <jrs@us.ibm.com> | 2007-07-18 08:50:18 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2007-07-18 08:50:18 -0400 |
commit | 0f49d5d019afa4e94253bfc92f0daca3badb990b (patch) | |
tree | 9a8266d3a7292a0632df0f970f6377a8b8b98658 /fs/jbd2/journal.c | |
parent | e23291b9120c11aafb2ee76fb71a062eb3c1056c (diff) |
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>
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r-- | fs/jbd2/journal.c | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 8f530cc66d34..f290cb7cb834 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include <linux/kthread.h> | 35 | #include <linux/kthread.h> |
36 | #include <linux/poison.h> | 36 | #include <linux/poison.h> |
37 | #include <linux/proc_fs.h> | 37 | #include <linux/proc_fs.h> |
38 | #include <linux/debugfs.h> | ||
38 | 39 | ||
39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
40 | #include <asm/page.h> | 41 | #include <asm/page.h> |
@@ -1951,64 +1952,50 @@ void jbd2_journal_put_journal_head(struct journal_head *jh) | |||
1951 | } | 1952 | } |
1952 | 1953 | ||
1953 | /* | 1954 | /* |
1954 | * /proc tunables | 1955 | * debugfs tunables |
1955 | */ | 1956 | */ |
1956 | #if defined(CONFIG_JBD2_DEBUG) | 1957 | #if defined(CONFIG_JBD2_DEBUG) |
1957 | int jbd2_journal_enable_debug; | 1958 | u8 jbd2_journal_enable_debug; |
1958 | EXPORT_SYMBOL(jbd2_journal_enable_debug); | 1959 | EXPORT_SYMBOL(jbd2_journal_enable_debug); |
1959 | #endif | 1960 | #endif |
1960 | 1961 | ||
1961 | #if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_PROC_FS) | 1962 | #if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_DEBUG_FS) |
1962 | 1963 | ||
1963 | static struct proc_dir_entry *proc_jbd_debug; | 1964 | #define JBD2_DEBUG_NAME "jbd2-debug" |
1964 | 1965 | ||
1965 | static int read_jbd_debug(char *page, char **start, off_t off, | 1966 | struct dentry *jbd2_debugfs_dir, *jbd2_debug; |
1966 | int count, int *eof, void *data) | ||
1967 | { | ||
1968 | int ret; | ||
1969 | 1967 | ||
1970 | ret = sprintf(page + off, "%d\n", jbd2_journal_enable_debug); | 1968 | static void __init jbd2_create_debugfs_entry(void) |
1971 | *eof = 1; | 1969 | { |
1972 | return ret; | 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); | ||
1973 | } | 1975 | } |
1974 | 1976 | ||
1975 | static int write_jbd_debug(struct file *file, const char __user *buffer, | 1977 | static void __exit jbd2_remove_debugfs_entry(void) |
1976 | unsigned long count, void *data) | ||
1977 | { | 1978 | { |
1978 | char buf[32]; | 1979 | if (jbd2_debug) |
1979 | 1980 | debugfs_remove(jbd2_debug); | |
1980 | if (count > ARRAY_SIZE(buf) - 1) | 1981 | if (jbd2_debugfs_dir) |
1981 | count = ARRAY_SIZE(buf) - 1; | 1982 | debugfs_remove(jbd2_debugfs_dir); |
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; | ||
1987 | } | 1983 | } |
1988 | 1984 | ||
1989 | #define JBD_PROC_NAME "sys/fs/jbd2-debug" | 1985 | #else |
1990 | 1986 | ||
1991 | static void __init create_jbd_proc_entry(void) | 1987 | static void __init jbd2_create_debugfs_entry(void) |
1992 | { | 1988 | { |
1993 | proc_jbd_debug = create_proc_entry(JBD_PROC_NAME, 0644, NULL); | 1989 | do { |
1994 | if (proc_jbd_debug) { | 1990 | } while (0); |
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 | } | ||
1999 | } | 1991 | } |
2000 | 1992 | ||
2001 | static void __exit jbd2_remove_jbd_proc_entry(void) | 1993 | static void __exit jbd2_remove_debugfs_entry(void) |
2002 | { | 1994 | { |
2003 | if (proc_jbd_debug) | 1995 | do { |
2004 | remove_proc_entry(JBD_PROC_NAME, NULL); | 1996 | } while (0); |
2005 | } | 1997 | } |
2006 | 1998 | ||
2007 | #else | ||
2008 | |||
2009 | #define create_jbd_proc_entry() do {} while (0) | ||
2010 | #define jbd2_remove_jbd_proc_entry() do {} while (0) | ||
2011 | |||
2012 | #endif | 1999 | #endif |
2013 | 2000 | ||
2014 | struct kmem_cache *jbd2_handle_cache; | 2001 | struct kmem_cache *jbd2_handle_cache; |
@@ -2067,7 +2054,7 @@ static int __init journal_init(void) | |||
2067 | ret = journal_init_caches(); | 2054 | ret = journal_init_caches(); |
2068 | if (ret != 0) | 2055 | if (ret != 0) |
2069 | jbd2_journal_destroy_caches(); | 2056 | jbd2_journal_destroy_caches(); |
2070 | create_jbd_proc_entry(); | 2057 | jbd2_create_debugfs_entry(); |
2071 | return ret; | 2058 | return ret; |
2072 | } | 2059 | } |
2073 | 2060 | ||
@@ -2078,7 +2065,7 @@ static void __exit journal_exit(void) | |||
2078 | if (n) | 2065 | if (n) |
2079 | printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n); | 2066 | printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n); |
2080 | #endif | 2067 | #endif |
2081 | jbd2_remove_jbd_proc_entry(); | 2068 | jbd2_remove_debugfs_entry(); |
2082 | jbd2_journal_destroy_caches(); | 2069 | jbd2_journal_destroy_caches(); |
2083 | } | 2070 | } |
2084 | 2071 | ||