aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd/journal.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/jbd/journal.c')
-rw-r--r--fs/jbd/journal.c67
1 files changed, 22 insertions, 45 deletions
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c
index 5d9fec0b7ebd..5d14243499d4 100644
--- a/fs/jbd/journal.c
+++ b/fs/jbd/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>
@@ -654,10 +655,9 @@ static journal_t * journal_init_common (void)
654 journal_t *journal; 655 journal_t *journal;
655 int err; 656 int err;
656 657
657 journal = kmalloc(sizeof(*journal), GFP_KERNEL); 658 journal = kzalloc(sizeof(*journal), GFP_KERNEL);
658 if (!journal) 659 if (!journal)
659 goto fail; 660 goto fail;
660 memset(journal, 0, sizeof(*journal));
661 661
662 init_waitqueue_head(&journal->j_wait_transaction_locked); 662 init_waitqueue_head(&journal->j_wait_transaction_locked);
663 init_waitqueue_head(&journal->j_wait_logspace); 663 init_waitqueue_head(&journal->j_wait_logspace);
@@ -1852,64 +1852,41 @@ void journal_put_journal_head(struct journal_head *jh)
1852} 1852}
1853 1853
1854/* 1854/*
1855 * /proc tunables 1855 * debugfs tunables
1856 */ 1856 */
1857#if defined(CONFIG_JBD_DEBUG) 1857#ifdef CONFIG_JBD_DEBUG
1858int journal_enable_debug;
1859EXPORT_SYMBOL(journal_enable_debug);
1860#endif
1861 1858
1862#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS) 1859u8 journal_enable_debug __read_mostly;
1860EXPORT_SYMBOL(journal_enable_debug);
1863 1861
1864static struct proc_dir_entry *proc_jbd_debug; 1862static struct dentry *jbd_debugfs_dir;
1863static struct dentry *jbd_debug;
1865 1864
1866static int read_jbd_debug(char *page, char **start, off_t off, 1865static void __init jbd_create_debugfs_entry(void)
1867 int count, int *eof, void *data)
1868{ 1866{
1869 int ret; 1867 jbd_debugfs_dir = debugfs_create_dir("jbd", NULL);
1870 1868 if (jbd_debugfs_dir)
1871 ret = sprintf(page + off, "%d\n", journal_enable_debug); 1869 jbd_debug = debugfs_create_u8("jbd-debug", S_IRUGO,
1872 *eof = 1; 1870 jbd_debugfs_dir,
1873 return ret; 1871 &journal_enable_debug);
1874} 1872}
1875 1873
1876static int write_jbd_debug(struct file *file, const char __user *buffer, 1874static void __exit jbd_remove_debugfs_entry(void)
1877 unsigned long count, void *data)
1878{ 1875{
1879 char buf[32]; 1876 debugfs_remove(jbd_debug);
1880 1877 debugfs_remove(jbd_debugfs_dir);
1881 if (count > ARRAY_SIZE(buf) - 1)
1882 count = ARRAY_SIZE(buf) - 1;
1883 if (copy_from_user(buf, buffer, count))
1884 return -EFAULT;
1885 buf[ARRAY_SIZE(buf) - 1] = '\0';
1886 journal_enable_debug = simple_strtoul(buf, NULL, 10);
1887 return count;
1888} 1878}
1889 1879
1890#define JBD_PROC_NAME "sys/fs/jbd-debug" 1880#else
1891 1881
1892static void __init create_jbd_proc_entry(void) 1882static inline void jbd_create_debugfs_entry(void)
1893{ 1883{
1894 proc_jbd_debug = create_proc_entry(JBD_PROC_NAME, 0644, NULL);
1895 if (proc_jbd_debug) {
1896 /* Why is this so hard? */
1897 proc_jbd_debug->read_proc = read_jbd_debug;
1898 proc_jbd_debug->write_proc = write_jbd_debug;
1899 }
1900} 1884}
1901 1885
1902static void __exit remove_jbd_proc_entry(void) 1886static inline void jbd_remove_debugfs_entry(void)
1903{ 1887{
1904 if (proc_jbd_debug)
1905 remove_proc_entry(JBD_PROC_NAME, NULL);
1906} 1888}
1907 1889
1908#else
1909
1910#define create_jbd_proc_entry() do {} while (0)
1911#define remove_jbd_proc_entry() do {} while (0)
1912
1913#endif 1890#endif
1914 1891
1915struct kmem_cache *jbd_handle_cache; 1892struct kmem_cache *jbd_handle_cache;
@@ -1966,7 +1943,7 @@ static int __init journal_init(void)
1966 ret = journal_init_caches(); 1943 ret = journal_init_caches();
1967 if (ret != 0) 1944 if (ret != 0)
1968 journal_destroy_caches(); 1945 journal_destroy_caches();
1969 create_jbd_proc_entry(); 1946 jbd_create_debugfs_entry();
1970 return ret; 1947 return ret;
1971} 1948}
1972 1949
@@ -1977,7 +1954,7 @@ static void __exit journal_exit(void)
1977 if (n) 1954 if (n)
1978 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n); 1955 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
1979#endif 1956#endif
1980 remove_jbd_proc_entry(); 1957 jbd_remove_debugfs_entry();
1981 journal_destroy_caches(); 1958 journal_destroy_caches();
1982} 1959}
1983 1960