diff options
Diffstat (limited to 'fs/jbd2')
-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 | ||