aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4/super.c
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2006-10-11 04:21:01 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-11 14:14:16 -0400
commitdab291af8d6307a3075c3d67d0cc8f98e646cb94 (patch)
treea2207ab3e2e00472e5e3c969ad0dd211fb9e4151 /fs/ext4/super.c
parenta920e9416b3469994860ab552dfd7fd5a5aff162 (diff)
[PATCH] jbd2: enable building of jbd2 and have ext4 use it rather than jbd
Reworked from a patch by Mingming Cao and Randy Dunlap Signed-off-By: Randy Dunlap <rdunlap@xenotime.net> Signed-off-by: Mingming Cao <cmm@us.ibm.com> Signed-off-by: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/ext4/super.c')
-rw-r--r--fs/ext4/super.c84
1 files changed, 42 insertions, 42 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9e32a2a8d286..f131bb69b62e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -20,9 +20,9 @@
20#include <linux/string.h> 20#include <linux/string.h>
21#include <linux/fs.h> 21#include <linux/fs.h>
22#include <linux/time.h> 22#include <linux/time.h>
23#include <linux/jbd.h> 23#include <linux/jbd2.h>
24#include <linux/ext4_fs.h> 24#include <linux/ext4_fs.h>
25#include <linux/ext4_jbd.h> 25#include <linux/ext4_jbd2.h>
26#include <linux/slab.h> 26#include <linux/slab.h>
27#include <linux/init.h> 27#include <linux/init.h>
28#include <linux/blkdev.h> 28#include <linux/blkdev.h>
@@ -63,7 +63,7 @@ static void ext4_write_super (struct super_block * sb);
63static void ext4_write_super_lockfs(struct super_block *sb); 63static void ext4_write_super_lockfs(struct super_block *sb);
64 64
65/* 65/*
66 * Wrappers for journal_start/end. 66 * Wrappers for jbd2_journal_start/end.
67 * 67 *
68 * The only special thing we need to do here is to make sure that all 68 * The only special thing we need to do here is to make sure that all
69 * journal_end calls result in the superblock being marked dirty, so 69 * journal_end calls result in the superblock being marked dirty, so
@@ -87,12 +87,12 @@ handle_t *ext4_journal_start_sb(struct super_block *sb, int nblocks)
87 return ERR_PTR(-EROFS); 87 return ERR_PTR(-EROFS);
88 } 88 }
89 89
90 return journal_start(journal, nblocks); 90 return jbd2_journal_start(journal, nblocks);
91} 91}
92 92
93/* 93/*
94 * The only special thing we need to do here is to make sure that all 94 * The only special thing we need to do here is to make sure that all
95 * journal_stop calls result in the superblock being marked dirty, so 95 * jbd2_journal_stop calls result in the superblock being marked dirty, so
96 * that sync() will call the filesystem's write_super callback if 96 * that sync() will call the filesystem's write_super callback if
97 * appropriate. 97 * appropriate.
98 */ 98 */
@@ -104,7 +104,7 @@ int __ext4_journal_stop(const char *where, handle_t *handle)
104 104
105 sb = handle->h_transaction->t_journal->j_private; 105 sb = handle->h_transaction->t_journal->j_private;
106 err = handle->h_err; 106 err = handle->h_err;
107 rc = journal_stop(handle); 107 rc = jbd2_journal_stop(handle);
108 108
109 if (!err) 109 if (!err)
110 err = rc; 110 err = rc;
@@ -131,7 +131,7 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn,
131 printk(KERN_ERR "%s: aborting transaction: %s in %s\n", 131 printk(KERN_ERR "%s: aborting transaction: %s in %s\n",
132 caller, errstr, err_fn); 132 caller, errstr, err_fn);
133 133
134 journal_abort_handle(handle); 134 jbd2_journal_abort_handle(handle);
135} 135}
136 136
137/* Deal with the reporting of failure conditions on a filesystem such as 137/* Deal with the reporting of failure conditions on a filesystem such as
@@ -144,7 +144,7 @@ void ext4_journal_abort_handle(const char *caller, const char *err_fn,
144 * be aborted, we can't rely on the current, or future, transactions to 144 * be aborted, we can't rely on the current, or future, transactions to
145 * write out the superblock safely. 145 * write out the superblock safely.
146 * 146 *
147 * We'll just use the journal_abort() error code to record an error in 147 * We'll just use the jbd2_journal_abort() error code to record an error in
148 * the journal instead. On recovery, the journal will compain about 148 * the journal instead. On recovery, the journal will compain about
149 * that error until we've noted it down and cleared it. 149 * that error until we've noted it down and cleared it.
150 */ 150 */
@@ -164,7 +164,7 @@ static void ext4_handle_error(struct super_block *sb)
164 164
165 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; 165 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
166 if (journal) 166 if (journal)
167 journal_abort(journal, -EIO); 167 jbd2_journal_abort(journal, -EIO);
168 } 168 }
169 if (test_opt (sb, ERRORS_RO)) { 169 if (test_opt (sb, ERRORS_RO)) {
170 printk (KERN_CRIT "Remounting filesystem read-only\n"); 170 printk (KERN_CRIT "Remounting filesystem read-only\n");
@@ -203,7 +203,7 @@ static const char *ext4_decode_error(struct super_block * sb, int errno,
203 errstr = "Out of memory"; 203 errstr = "Out of memory";
204 break; 204 break;
205 case -EROFS: 205 case -EROFS:
206 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JFS_ABORT) 206 if (!sb || EXT4_SB(sb)->s_journal->j_flags & JBD2_ABORT)
207 errstr = "Journal has aborted"; 207 errstr = "Journal has aborted";
208 else 208 else
209 errstr = "Readonly filesystem"; 209 errstr = "Readonly filesystem";
@@ -279,7 +279,7 @@ void ext4_abort (struct super_block * sb, const char * function,
279 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS; 279 EXT4_SB(sb)->s_mount_state |= EXT4_ERROR_FS;
280 sb->s_flags |= MS_RDONLY; 280 sb->s_flags |= MS_RDONLY;
281 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT; 281 EXT4_SB(sb)->s_mount_opt |= EXT4_MOUNT_ABORT;
282 journal_abort(EXT4_SB(sb)->s_journal, -EIO); 282 jbd2_journal_abort(EXT4_SB(sb)->s_journal, -EIO);
283} 283}
284 284
285void ext4_warning (struct super_block * sb, const char * function, 285void ext4_warning (struct super_block * sb, const char * function,
@@ -391,7 +391,7 @@ static void ext4_put_super (struct super_block * sb)
391 int i; 391 int i;
392 392
393 ext4_xattr_put_super(sb); 393 ext4_xattr_put_super(sb);
394 journal_destroy(sbi->s_journal); 394 jbd2_journal_destroy(sbi->s_journal);
395 if (!(sb->s_flags & MS_RDONLY)) { 395 if (!(sb->s_flags & MS_RDONLY)) {
396 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 396 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
397 es->s_state = cpu_to_le16(sbi->s_mount_state); 397 es->s_state = cpu_to_le16(sbi->s_mount_state);
@@ -1722,8 +1722,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1722 /* No mode set, assume a default based on the journal 1722 /* No mode set, assume a default based on the journal
1723 capabilities: ORDERED_DATA if the journal can 1723 capabilities: ORDERED_DATA if the journal can
1724 cope, else JOURNAL_DATA */ 1724 cope, else JOURNAL_DATA */
1725 if (journal_check_available_features 1725 if (jbd2_journal_check_available_features
1726 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) 1726 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE))
1727 set_opt(sbi->s_mount_opt, ORDERED_DATA); 1727 set_opt(sbi->s_mount_opt, ORDERED_DATA);
1728 else 1728 else
1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA); 1729 set_opt(sbi->s_mount_opt, JOURNAL_DATA);
@@ -1731,8 +1731,8 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1731 1731
1732 case EXT4_MOUNT_ORDERED_DATA: 1732 case EXT4_MOUNT_ORDERED_DATA:
1733 case EXT4_MOUNT_WRITEBACK_DATA: 1733 case EXT4_MOUNT_WRITEBACK_DATA:
1734 if (!journal_check_available_features 1734 if (!jbd2_journal_check_available_features
1735 (sbi->s_journal, 0, 0, JFS_FEATURE_INCOMPAT_REVOKE)) { 1735 (sbi->s_journal, 0, 0, JBD2_FEATURE_INCOMPAT_REVOKE)) {
1736 printk(KERN_ERR "EXT4-fs: Journal does not support " 1736 printk(KERN_ERR "EXT4-fs: Journal does not support "
1737 "requested data journaling mode\n"); 1737 "requested data journaling mode\n");
1738 goto failed_mount4; 1738 goto failed_mount4;
@@ -1749,7 +1749,7 @@ static int ext4_fill_super (struct super_block *sb, void *data, int silent)
1749 } 1749 }
1750 } 1750 }
1751 /* 1751 /*
1752 * The journal_load will have done any necessary log recovery, 1752 * The jbd2_journal_load will have done any necessary log recovery,
1753 * so we can safely mount the rest of the filesystem now. 1753 * so we can safely mount the rest of the filesystem now.
1754 */ 1754 */
1755 1755
@@ -1797,7 +1797,7 @@ cantfind_ext4:
1797 goto failed_mount; 1797 goto failed_mount;
1798 1798
1799failed_mount4: 1799failed_mount4:
1800 journal_destroy(sbi->s_journal); 1800 jbd2_journal_destroy(sbi->s_journal);
1801failed_mount3: 1801failed_mount3:
1802 percpu_counter_destroy(&sbi->s_freeblocks_counter); 1802 percpu_counter_destroy(&sbi->s_freeblocks_counter);
1803 percpu_counter_destroy(&sbi->s_freeinodes_counter); 1803 percpu_counter_destroy(&sbi->s_freeinodes_counter);
@@ -1837,9 +1837,9 @@ static void ext4_init_journal_params(struct super_block *sb, journal_t *journal)
1837 1837
1838 spin_lock(&journal->j_state_lock); 1838 spin_lock(&journal->j_state_lock);
1839 if (test_opt(sb, BARRIER)) 1839 if (test_opt(sb, BARRIER))
1840 journal->j_flags |= JFS_BARRIER; 1840 journal->j_flags |= JBD2_BARRIER;
1841 else 1841 else
1842 journal->j_flags &= ~JFS_BARRIER; 1842 journal->j_flags &= ~JBD2_BARRIER;
1843 spin_unlock(&journal->j_state_lock); 1843 spin_unlock(&journal->j_state_lock);
1844} 1844}
1845 1845
@@ -1873,7 +1873,7 @@ static journal_t *ext4_get_journal(struct super_block *sb,
1873 return NULL; 1873 return NULL;
1874 } 1874 }
1875 1875
1876 journal = journal_init_inode(journal_inode); 1876 journal = jbd2_journal_init_inode(journal_inode);
1877 if (!journal) { 1877 if (!journal) {
1878 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n"); 1878 printk(KERN_ERR "EXT4-fs: Could not load journal inode\n");
1879 iput(journal_inode); 1879 iput(journal_inode);
@@ -1945,7 +1945,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
1945 start = sb_block + 1; 1945 start = sb_block + 1;
1946 brelse(bh); /* we're done with the superblock */ 1946 brelse(bh); /* we're done with the superblock */
1947 1947
1948 journal = journal_init_dev(bdev, sb->s_bdev, 1948 journal = jbd2_journal_init_dev(bdev, sb->s_bdev,
1949 start, len, blocksize); 1949 start, len, blocksize);
1950 if (!journal) { 1950 if (!journal) {
1951 printk(KERN_ERR "EXT4-fs: failed to create device journal\n"); 1951 printk(KERN_ERR "EXT4-fs: failed to create device journal\n");
@@ -1968,7 +1968,7 @@ static journal_t *ext4_get_dev_journal(struct super_block *sb,
1968 ext4_init_journal_params(sb, journal); 1968 ext4_init_journal_params(sb, journal);
1969 return journal; 1969 return journal;
1970out_journal: 1970out_journal:
1971 journal_destroy(journal); 1971 jbd2_journal_destroy(journal);
1972out_bdev: 1972out_bdev:
1973 ext4_blkdev_put(bdev); 1973 ext4_blkdev_put(bdev);
1974 return NULL; 1974 return NULL;
@@ -2029,22 +2029,22 @@ static int ext4_load_journal(struct super_block *sb,
2029 } 2029 }
2030 2030
2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) { 2031 if (!really_read_only && test_opt(sb, UPDATE_JOURNAL)) {
2032 err = journal_update_format(journal); 2032 err = jbd2_journal_update_format(journal);
2033 if (err) { 2033 if (err) {
2034 printk(KERN_ERR "EXT4-fs: error updating journal.\n"); 2034 printk(KERN_ERR "EXT4-fs: error updating journal.\n");
2035 journal_destroy(journal); 2035 jbd2_journal_destroy(journal);
2036 return err; 2036 return err;
2037 } 2037 }
2038 } 2038 }
2039 2039
2040 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER)) 2040 if (!EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER))
2041 err = journal_wipe(journal, !really_read_only); 2041 err = jbd2_journal_wipe(journal, !really_read_only);
2042 if (!err) 2042 if (!err)
2043 err = journal_load(journal); 2043 err = jbd2_journal_load(journal);
2044 2044
2045 if (err) { 2045 if (err) {
2046 printk(KERN_ERR "EXT4-fs: error loading journal.\n"); 2046 printk(KERN_ERR "EXT4-fs: error loading journal.\n");
2047 journal_destroy(journal); 2047 jbd2_journal_destroy(journal);
2048 return err; 2048 return err;
2049 } 2049 }
2050 2050
@@ -2081,9 +2081,9 @@ static int ext4_create_journal(struct super_block * sb,
2081 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n", 2081 printk(KERN_INFO "EXT4-fs: creating new journal on inode %u\n",
2082 journal_inum); 2082 journal_inum);
2083 2083
2084 if (journal_create(journal)) { 2084 if (jbd2_journal_create(journal)) {
2085 printk(KERN_ERR "EXT4-fs: error creating journal.\n"); 2085 printk(KERN_ERR "EXT4-fs: error creating journal.\n");
2086 journal_destroy(journal); 2086 jbd2_journal_destroy(journal);
2087 return -EIO; 2087 return -EIO;
2088 } 2088 }
2089 2089
@@ -2130,15 +2130,15 @@ static void ext4_mark_recovery_complete(struct super_block * sb,
2130{ 2130{
2131 journal_t *journal = EXT4_SB(sb)->s_journal; 2131 journal_t *journal = EXT4_SB(sb)->s_journal;
2132 2132
2133 journal_lock_updates(journal); 2133 jbd2_journal_lock_updates(journal);
2134 journal_flush(journal); 2134 jbd2_journal_flush(journal);
2135 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) && 2135 if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER) &&
2136 sb->s_flags & MS_RDONLY) { 2136 sb->s_flags & MS_RDONLY) {
2137 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2137 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2138 sb->s_dirt = 0; 2138 sb->s_dirt = 0;
2139 ext4_commit_super(sb, es, 1); 2139 ext4_commit_super(sb, es, 1);
2140 } 2140 }
2141 journal_unlock_updates(journal); 2141 jbd2_journal_unlock_updates(journal);
2142} 2142}
2143 2143
2144/* 2144/*
@@ -2160,7 +2160,7 @@ static void ext4_clear_journal_err(struct super_block * sb,
2160 * journal by a prior ext4_error() or ext4_abort() 2160 * journal by a prior ext4_error() or ext4_abort()
2161 */ 2161 */
2162 2162
2163 j_errno = journal_errno(journal); 2163 j_errno = jbd2_journal_errno(journal);
2164 if (j_errno) { 2164 if (j_errno) {
2165 char nbuf[16]; 2165 char nbuf[16];
2166 2166
@@ -2174,7 +2174,7 @@ static void ext4_clear_journal_err(struct super_block * sb,
2174 es->s_state |= cpu_to_le16(EXT4_ERROR_FS); 2174 es->s_state |= cpu_to_le16(EXT4_ERROR_FS);
2175 ext4_commit_super (sb, es, 1); 2175 ext4_commit_super (sb, es, 1);
2176 2176
2177 journal_clear_err(journal); 2177 jbd2_journal_clear_err(journal);
2178 } 2178 }
2179} 2179}
2180 2180
@@ -2217,9 +2217,9 @@ static int ext4_sync_fs(struct super_block *sb, int wait)
2217 tid_t target; 2217 tid_t target;
2218 2218
2219 sb->s_dirt = 0; 2219 sb->s_dirt = 0;
2220 if (journal_start_commit(EXT4_SB(sb)->s_journal, &target)) { 2220 if (jbd2_journal_start_commit(EXT4_SB(sb)->s_journal, &target)) {
2221 if (wait) 2221 if (wait)
2222 log_wait_commit(EXT4_SB(sb)->s_journal, target); 2222 jbd2_log_wait_commit(EXT4_SB(sb)->s_journal, target);
2223 } 2223 }
2224 return 0; 2224 return 0;
2225} 2225}
@@ -2236,8 +2236,8 @@ static void ext4_write_super_lockfs(struct super_block *sb)
2236 journal_t *journal = EXT4_SB(sb)->s_journal; 2236 journal_t *journal = EXT4_SB(sb)->s_journal;
2237 2237
2238 /* Now we set up the journal barrier. */ 2238 /* Now we set up the journal barrier. */
2239 journal_lock_updates(journal); 2239 jbd2_journal_lock_updates(journal);
2240 journal_flush(journal); 2240 jbd2_journal_flush(journal);
2241 2241
2242 /* Journal blocked and flushed, clear needs_recovery flag. */ 2242 /* Journal blocked and flushed, clear needs_recovery flag. */
2243 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2243 EXT4_CLEAR_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
@@ -2257,7 +2257,7 @@ static void ext4_unlockfs(struct super_block *sb)
2257 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER); 2257 EXT4_SET_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_RECOVER);
2258 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1); 2258 ext4_commit_super(sb, EXT4_SB(sb)->s_es, 1);
2259 unlock_super(sb); 2259 unlock_super(sb);
2260 journal_unlock_updates(EXT4_SB(sb)->s_journal); 2260 jbd2_journal_unlock_updates(EXT4_SB(sb)->s_journal);
2261 } 2261 }
2262} 2262}
2263 2263
@@ -2438,9 +2438,9 @@ static int ext4_statfs (struct dentry * dentry, struct kstatfs * buf)
2438 * is locked for write. Otherwise the are possible deadlocks: 2438 * is locked for write. Otherwise the are possible deadlocks:
2439 * Process 1 Process 2 2439 * Process 1 Process 2
2440 * ext4_create() quota_sync() 2440 * ext4_create() quota_sync()
2441 * journal_start() write_dquot() 2441 * jbd2_journal_start() write_dquot()
2442 * DQUOT_INIT() down(dqio_mutex) 2442 * DQUOT_INIT() down(dqio_mutex)
2443 * down(dqio_mutex) journal_start() 2443 * down(dqio_mutex) jbd2_journal_start()
2444 * 2444 *
2445 */ 2445 */
2446 2446