jbd2: only create debugfs and stats entries if init is successful
authorDuane Griffin <duaneg@dghda.com>
Wed, 30 Apr 2008 02:02:47 +0000 (22:02 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 30 Apr 2008 02:02:47 +0000 (22:02 -0400)
jbd2 debugfs and stats entries should only be created if cache initialisation
is successful.  At the moment they are being created unconditionally which
will leave them dangling if cache (and hence module) initialisation fails.

Signed-off-by: Duane Griffin <duaneg@dghda.com>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
fs/jbd2/journal.c

index d707a219e21b555a3882dd1ae86a513b46a015b5..64356e85a10fd48bcd05153500fdaea972ab09fe 100644 (file)
@@ -2307,10 +2307,12 @@ static int __init journal_init(void)
        BUILD_BUG_ON(sizeof(struct journal_superblock_s) != 1024);
 
        ret = journal_init_caches();
-       if (ret != 0)
+       if (ret == 0) {
+               jbd2_create_debugfs_entry();
+               jbd2_create_jbd_stats_proc_entry();
+       } else {
                jbd2_journal_destroy_caches();
-       jbd2_create_debugfs_entry();
-       jbd2_create_jbd_stats_proc_entry();
+       }
        return ret;
 }