aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd2/journal.c')
-rw-r--r--fs/jbd2/journal.c79
1 files changed, 33 insertions, 46 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 78d63b818f0b..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>
@@ -528,7 +529,7 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
528{ 529{
529 int err = 0; 530 int err = 0;
530 531
531#ifdef CONFIG_JBD_DEBUG 532#ifdef CONFIG_JBD2_DEBUG
532 spin_lock(&journal->j_state_lock); 533 spin_lock(&journal->j_state_lock);
533 if (!tid_geq(journal->j_commit_request, tid)) { 534 if (!tid_geq(journal->j_commit_request, tid)) {
534 printk(KERN_EMERG 535 printk(KERN_EMERG
@@ -1709,7 +1710,7 @@ void jbd2_slab_free(void *ptr, size_t size)
1709 * Journal_head storage management 1710 * Journal_head storage management
1710 */ 1711 */
1711static struct kmem_cache *jbd2_journal_head_cache; 1712static struct kmem_cache *jbd2_journal_head_cache;
1712#ifdef CONFIG_JBD_DEBUG 1713#ifdef CONFIG_JBD2_DEBUG
1713static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1714static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1714#endif 1715#endif
1715 1716
@@ -1747,7 +1748,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1747 struct journal_head *ret; 1748 struct journal_head *ret;
1748 static unsigned long last_warning; 1749 static unsigned long last_warning;
1749 1750
1750#ifdef CONFIG_JBD_DEBUG 1751#ifdef CONFIG_JBD2_DEBUG
1751 atomic_inc(&nr_journal_heads); 1752 atomic_inc(&nr_journal_heads);
1752#endif 1753#endif
1753 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS); 1754 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
@@ -1768,7 +1769,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1768 1769
1769static void journal_free_journal_head(struct journal_head *jh) 1770static void journal_free_journal_head(struct journal_head *jh)
1770{ 1771{
1771#ifdef CONFIG_JBD_DEBUG 1772#ifdef CONFIG_JBD2_DEBUG
1772 atomic_dec(&nr_journal_heads); 1773 atomic_dec(&nr_journal_heads);
1773 memset(jh, JBD_POISON_FREE, sizeof(*jh)); 1774 memset(jh, JBD_POISON_FREE, sizeof(*jh));
1774#endif 1775#endif
@@ -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_JBD_DEBUG) 1957#if defined(CONFIG_JBD2_DEBUG)
1957int jbd2_journal_enable_debug; 1958u8 jbd2_journal_enable_debug;
1958EXPORT_SYMBOL(jbd2_journal_enable_debug); 1959EXPORT_SYMBOL(jbd2_journal_enable_debug);
1959#endif 1960#endif
1960 1961
1961#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS) 1962#if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_DEBUG_FS)
1962 1963
1963static struct proc_dir_entry *proc_jbd_debug; 1964#define JBD2_DEBUG_NAME "jbd2-debug"
1964 1965
1965static int read_jbd_debug(char *page, char **start, off_t off, 1966struct 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); 1968static 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
1975static int write_jbd_debug(struct file *file, const char __user *buffer, 1977static 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
1991static void __init create_jbd_proc_entry(void) 1987static 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
2001static void __exit jbd2_remove_jbd_proc_entry(void) 1993static 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
2014struct kmem_cache *jbd2_handle_cache; 2001struct kmem_cache *jbd2_handle_cache;
@@ -2067,18 +2054,18 @@ 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
2074static void __exit journal_exit(void) 2061static void __exit journal_exit(void)
2075{ 2062{
2076#ifdef CONFIG_JBD_DEBUG 2063#ifdef CONFIG_JBD2_DEBUG
2077 int n = atomic_read(&nr_journal_heads); 2064 int n = atomic_read(&nr_journal_heads);
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