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.c87
1 files changed, 36 insertions, 51 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index 78d63b818f0b..f37324aee817 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
@@ -1679,7 +1680,7 @@ static int jbd2_journal_create_jbd_slab(size_t slab_size)
1679 * boundary. 1680 * boundary.
1680 */ 1681 */
1681 jbd_slab[i] = kmem_cache_create(jbd_slab_names[i], 1682 jbd_slab[i] = kmem_cache_create(jbd_slab_names[i],
1682 slab_size, slab_size, 0, NULL, NULL); 1683 slab_size, slab_size, 0, NULL);
1683 if (!jbd_slab[i]) { 1684 if (!jbd_slab[i]) {
1684 printk(KERN_EMERG "JBD: no memory for jbd_slab cache\n"); 1685 printk(KERN_EMERG "JBD: no memory for jbd_slab cache\n");
1685 return -ENOMEM; 1686 return -ENOMEM;
@@ -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
@@ -1722,8 +1723,7 @@ static int journal_init_jbd2_journal_head_cache(void)
1722 sizeof(struct journal_head), 1723 sizeof(struct journal_head),
1723 0, /* offset */ 1724 0, /* offset */
1724 0, /* flags */ 1725 0, /* flags */
1725 NULL, /* ctor */ 1726 NULL); /* ctor */
1726 NULL); /* dtor */
1727 retval = 0; 1727 retval = 0;
1728 if (jbd2_journal_head_cache == 0) { 1728 if (jbd2_journal_head_cache == 0) {
1729 retval = -ENOMEM; 1729 retval = -ENOMEM;
@@ -1747,7 +1747,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1747 struct journal_head *ret; 1747 struct journal_head *ret;
1748 static unsigned long last_warning; 1748 static unsigned long last_warning;
1749 1749
1750#ifdef CONFIG_JBD_DEBUG 1750#ifdef CONFIG_JBD2_DEBUG
1751 atomic_inc(&nr_journal_heads); 1751 atomic_inc(&nr_journal_heads);
1752#endif 1752#endif
1753 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS); 1753 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
@@ -1768,7 +1768,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1768 1768
1769static void journal_free_journal_head(struct journal_head *jh) 1769static void journal_free_journal_head(struct journal_head *jh)
1770{ 1770{
1771#ifdef CONFIG_JBD_DEBUG 1771#ifdef CONFIG_JBD2_DEBUG
1772 atomic_dec(&nr_journal_heads); 1772 atomic_dec(&nr_journal_heads);
1773 memset(jh, JBD_POISON_FREE, sizeof(*jh)); 1773 memset(jh, JBD_POISON_FREE, sizeof(*jh));
1774#endif 1774#endif
@@ -1951,64 +1951,50 @@ void jbd2_journal_put_journal_head(struct journal_head *jh)
1951} 1951}
1952 1952
1953/* 1953/*
1954 * /proc tunables 1954 * debugfs tunables
1955 */ 1955 */
1956#if defined(CONFIG_JBD_DEBUG) 1956#if defined(CONFIG_JBD2_DEBUG)
1957int jbd2_journal_enable_debug; 1957u8 jbd2_journal_enable_debug;
1958EXPORT_SYMBOL(jbd2_journal_enable_debug); 1958EXPORT_SYMBOL(jbd2_journal_enable_debug);
1959#endif 1959#endif
1960 1960
1961#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS) 1961#if defined(CONFIG_JBD2_DEBUG) && defined(CONFIG_DEBUG_FS)
1962 1962
1963static struct proc_dir_entry *proc_jbd_debug; 1963#define JBD2_DEBUG_NAME "jbd2-debug"
1964 1964
1965static int read_jbd_debug(char *page, char **start, off_t off, 1965struct dentry *jbd2_debugfs_dir, *jbd2_debug;
1966 int count, int *eof, void *data)
1967{
1968 int ret;
1969 1966
1970 ret = sprintf(page + off, "%d\n", jbd2_journal_enable_debug); 1967static void __init jbd2_create_debugfs_entry(void)
1971 *eof = 1; 1968{
1972 return ret; 1969 jbd2_debugfs_dir = debugfs_create_dir("jbd2", NULL);
1970 if (jbd2_debugfs_dir)
1971 jbd2_debug = debugfs_create_u8(JBD2_DEBUG_NAME, S_IRUGO,
1972 jbd2_debugfs_dir,
1973 &jbd2_journal_enable_debug);
1973} 1974}
1974 1975
1975static int write_jbd_debug(struct file *file, const char __user *buffer, 1976static void __exit jbd2_remove_debugfs_entry(void)
1976 unsigned long count, void *data)
1977{ 1977{
1978 char buf[32]; 1978 if (jbd2_debug)
1979 1979 debugfs_remove(jbd2_debug);
1980 if (count > ARRAY_SIZE(buf) - 1) 1980 if (jbd2_debugfs_dir)
1981 count = ARRAY_SIZE(buf) - 1; 1981 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} 1982}
1988 1983
1989#define JBD_PROC_NAME "sys/fs/jbd2-debug" 1984#else
1990 1985
1991static void __init create_jbd_proc_entry(void) 1986static void __init jbd2_create_debugfs_entry(void)
1992{ 1987{
1993 proc_jbd_debug = create_proc_entry(JBD_PROC_NAME, 0644, NULL); 1988 do {
1994 if (proc_jbd_debug) { 1989 } 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} 1990}
2000 1991
2001static void __exit jbd2_remove_jbd_proc_entry(void) 1992static void __exit jbd2_remove_debugfs_entry(void)
2002{ 1993{
2003 if (proc_jbd_debug) 1994 do {
2004 remove_proc_entry(JBD_PROC_NAME, NULL); 1995 } while (0);
2005} 1996}
2006 1997
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 1998#endif
2013 1999
2014struct kmem_cache *jbd2_handle_cache; 2000struct kmem_cache *jbd2_handle_cache;
@@ -2019,8 +2005,7 @@ static int __init journal_init_handle_cache(void)
2019 sizeof(handle_t), 2005 sizeof(handle_t),
2020 0, /* offset */ 2006 0, /* offset */
2021 0, /* flags */ 2007 0, /* flags */
2022 NULL, /* ctor */ 2008 NULL); /* ctor */
2023 NULL); /* dtor */
2024 if (jbd2_handle_cache == NULL) { 2009 if (jbd2_handle_cache == NULL) {
2025 printk(KERN_EMERG "JBD: failed to create handle cache\n"); 2010 printk(KERN_EMERG "JBD: failed to create handle cache\n");
2026 return -ENOMEM; 2011 return -ENOMEM;
@@ -2067,18 +2052,18 @@ static int __init journal_init(void)
2067 ret = journal_init_caches(); 2052 ret = journal_init_caches();
2068 if (ret != 0) 2053 if (ret != 0)
2069 jbd2_journal_destroy_caches(); 2054 jbd2_journal_destroy_caches();
2070 create_jbd_proc_entry(); 2055 jbd2_create_debugfs_entry();
2071 return ret; 2056 return ret;
2072} 2057}
2073 2058
2074static void __exit journal_exit(void) 2059static void __exit journal_exit(void)
2075{ 2060{
2076#ifdef CONFIG_JBD_DEBUG 2061#ifdef CONFIG_JBD2_DEBUG
2077 int n = atomic_read(&nr_journal_heads); 2062 int n = atomic_read(&nr_journal_heads);
2078 if (n) 2063 if (n)
2079 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n); 2064 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
2080#endif 2065#endif
2081 jbd2_remove_jbd_proc_entry(); 2066 jbd2_remove_debugfs_entry();
2082 jbd2_journal_destroy_caches(); 2067 jbd2_journal_destroy_caches();
2083} 2068}
2084 2069