aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoel Becker <joel.becker@oracle.com>2008-09-03 23:03:41 -0400
committerMark Fasheh <mfasheh@suse.com>2008-10-13 20:02:43 -0400
commit2b4e30fbde425828b17f0e9c8f8e3fd3ecb2bc75 (patch)
tree5b340cde72e058b51642f0c7255818f62014bc91
parent12462f1d9f0b96389497438dc2730c6f7410be82 (diff)
ocfs2: Switch over to JBD2.
ocfs2 wants JBD2 for many reasons, not the least of which is that JBD is limiting our maximum filesystem size. It's a pretty trivial change. Most functions are just renamed. The only functional change is moving to Jan's inode-based ordered data mode. It's better, too. Because JBD2 reads and writes JBD journals, this is compatible with any existing filesystem. It can even interact with JBD-based ocfs2 as long as the journal is formated for JBD. We provide a compatibility option so that paranoid people can still use JBD for the time being. This will go away shortly. [ Moved call of ocfs2_begin_ordered_truncate() from ocfs2_delete_inode() to ocfs2_truncate_for_delete(). --Mark ] Signed-off-by: Joel Becker <joel.becker@oracle.com> Signed-off-by: Mark Fasheh <mfasheh@suse.com>
-rw-r--r--fs/Kconfig34
-rw-r--r--fs/ocfs2/alloc.c28
-rw-r--r--fs/ocfs2/aops.c21
-rw-r--r--fs/ocfs2/file.c14
-rw-r--r--fs/ocfs2/inode.c5
-rw-r--r--fs/ocfs2/inode.h1
-rw-r--r--fs/ocfs2/journal.c72
-rw-r--r--fs/ocfs2/journal.h25
-rw-r--r--fs/ocfs2/ocfs2.h7
-rw-r--r--fs/ocfs2/ocfs2_jbd_compat.h82
-rw-r--r--fs/ocfs2/super.c10
-rw-r--r--fs/ocfs2/uptodate.c6
12 files changed, 224 insertions, 81 deletions
diff --git a/fs/Kconfig b/fs/Kconfig
index f54a157a0296..4be00d812576 100644
--- a/fs/Kconfig
+++ b/fs/Kconfig
@@ -220,17 +220,16 @@ config JBD
220 tristate 220 tristate
221 help 221 help
222 This is a generic journalling layer for block devices. It is 222 This is a generic journalling layer for block devices. It is
223 currently used by the ext3 and OCFS2 file systems, but it could 223 currently used by the ext3 file system, but it could also be
224 also be used to add journal support to other file systems or block 224 used to add journal support to other file systems or block
225 devices such as RAID or LVM. 225 devices such as RAID or LVM.
226 226
227 If you are using the ext3 or OCFS2 file systems, you need to 227 If you are using the ext3 file system, you need to say Y here.
228 say Y here. If you are not using ext3 OCFS2 then you will probably 228 If you are not using ext3 then you will probably want to say N.
229 want to say N.
230 229
231 To compile this device as a module, choose M here: the module will be 230 To compile this device as a module, choose M here: the module will be
232 called jbd. If you are compiling ext3 or OCFS2 into the kernel, 231 called jbd. If you are compiling ext3 into the kernel, you
233 you cannot compile this code as a module. 232 cannot compile this code as a module.
234 233
235config JBD_DEBUG 234config JBD_DEBUG
236 bool "JBD (ext3) debugging support" 235 bool "JBD (ext3) debugging support"
@@ -254,15 +253,16 @@ config JBD2
254 help 253 help
255 This is a generic journaling layer for block devices that support 254 This is a generic journaling layer for block devices that support
256 both 32-bit and 64-bit block numbers. It is currently used by 255 both 32-bit and 64-bit block numbers. It is currently used by
257 the ext4 filesystem, but it could also be used to add 256 the ext4 and OCFS2 filesystems, but it could also be used to add
258 journal support to other file systems or block devices such 257 journal support to other file systems or block devices such
259 as RAID or LVM. 258 as RAID or LVM.
260 259
261 If you are using ext4, you need to say Y here. If you are not 260 If you are using ext4 or OCFS2, you need to say Y here.
262 using ext4 then you will probably want to say N. 261 If you are not using ext4 or OCFS2 then you will
262 probably want to say N.
263 263
264 To compile this device as a module, choose M here. The module will be 264 To compile this device as a module, choose M here. The module will be
265 called jbd2. If you are compiling ext4 into the kernel, 265 called jbd2. If you are compiling ext4 or OCFS2 into the kernel,
266 you cannot compile this code as a module. 266 you cannot compile this code as a module.
267 267
268config JBD2_DEBUG 268config JBD2_DEBUG
@@ -440,7 +440,7 @@ config OCFS2_FS
440 tristate "OCFS2 file system support" 440 tristate "OCFS2 file system support"
441 depends on NET && SYSFS 441 depends on NET && SYSFS
442 select CONFIGFS_FS 442 select CONFIGFS_FS
443 select JBD 443 select JBD2
444 select CRC32 444 select CRC32
445 help 445 help
446 OCFS2 is a general purpose extent based shared disk cluster file 446 OCFS2 is a general purpose extent based shared disk cluster file
@@ -511,6 +511,16 @@ config OCFS2_DEBUG_FS
511 this option for debugging only as it is likely to decrease 511 this option for debugging only as it is likely to decrease
512 performance of the filesystem. 512 performance of the filesystem.
513 513
514config OCFS2_COMPAT_JBD
515 bool "Use JBD for compatibility"
516 depends on OCFS2_FS
517 default n
518 select JBD
519 help
520 The ocfs2 filesystem now uses JBD2 for its journalling. JBD2
521 is backwards compatible with JBD. It is safe to say N here.
522 However, if you really want to use the original JBD, say Y here.
523
514endif # BLOCK 524endif # BLOCK
515 525
516config DNOTIFY 526config DNOTIFY
diff --git a/fs/ocfs2/alloc.c b/fs/ocfs2/alloc.c
index 47201b67dbf2..ebfe36ab2d5e 100644
--- a/fs/ocfs2/alloc.c
+++ b/fs/ocfs2/alloc.c
@@ -6421,20 +6421,13 @@ bail:
6421 return status; 6421 return status;
6422} 6422}
6423 6423
6424static int ocfs2_writeback_zero_func(handle_t *handle, struct buffer_head *bh) 6424static int ocfs2_zero_func(handle_t *handle, struct buffer_head *bh)
6425{ 6425{
6426 set_buffer_uptodate(bh); 6426 set_buffer_uptodate(bh);
6427 mark_buffer_dirty(bh); 6427 mark_buffer_dirty(bh);
6428 return 0; 6428 return 0;
6429} 6429}
6430 6430
6431static int ocfs2_ordered_zero_func(handle_t *handle, struct buffer_head *bh)
6432{
6433 set_buffer_uptodate(bh);
6434 mark_buffer_dirty(bh);
6435 return ocfs2_journal_dirty_data(handle, bh);
6436}
6437
6438static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle, 6431static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
6439 unsigned int from, unsigned int to, 6432 unsigned int from, unsigned int to,
6440 struct page *page, int zero, u64 *phys) 6433 struct page *page, int zero, u64 *phys)
@@ -6453,17 +6446,18 @@ static void ocfs2_map_and_dirty_page(struct inode *inode, handle_t *handle,
6453 * here if they aren't - ocfs2_map_page_blocks() 6446 * here if they aren't - ocfs2_map_page_blocks()
6454 * might've skipped some 6447 * might've skipped some
6455 */ 6448 */
6456 if (ocfs2_should_order_data(inode)) { 6449 ret = walk_page_buffers(handle, page_buffers(page),
6457 ret = walk_page_buffers(handle, 6450 from, to, &partial,
6458 page_buffers(page), 6451 ocfs2_zero_func);
6459 from, to, &partial, 6452 if (ret < 0)
6460 ocfs2_ordered_zero_func); 6453 mlog_errno(ret);
6461 if (ret < 0) 6454 else if (ocfs2_should_order_data(inode)) {
6462 mlog_errno(ret); 6455 ret = ocfs2_jbd2_file_inode(handle, inode);
6463 } else { 6456#ifdef CONFIG_OCFS2_COMPAT_JBD
6464 ret = walk_page_buffers(handle, page_buffers(page), 6457 ret = walk_page_buffers(handle, page_buffers(page),
6465 from, to, &partial, 6458 from, to, &partial,
6466 ocfs2_writeback_zero_func); 6459 ocfs2_journal_dirty_data);
6460#endif
6467 if (ret < 0) 6461 if (ret < 0)
6468 mlog_errno(ret); 6462 mlog_errno(ret);
6469 } 6463 }
diff --git a/fs/ocfs2/aops.c b/fs/ocfs2/aops.c
index 259775eedb85..de179054a74b 100644
--- a/fs/ocfs2/aops.c
+++ b/fs/ocfs2/aops.c
@@ -485,11 +485,14 @@ handle_t *ocfs2_start_walk_page_trans(struct inode *inode,
485 } 485 }
486 486
487 if (ocfs2_should_order_data(inode)) { 487 if (ocfs2_should_order_data(inode)) {
488 ret = ocfs2_jbd2_file_inode(handle, inode);
489#ifdef CONFIG_OCFS2_COMPAT_JBD
488 ret = walk_page_buffers(handle, 490 ret = walk_page_buffers(handle,
489 page_buffers(page), 491 page_buffers(page),
490 from, to, NULL, 492 from, to, NULL,
491 ocfs2_journal_dirty_data); 493 ocfs2_journal_dirty_data);
492 if (ret < 0) 494#endif
495 if (ret < 0)
493 mlog_errno(ret); 496 mlog_errno(ret);
494 } 497 }
495out: 498out:
@@ -669,7 +672,7 @@ static void ocfs2_invalidatepage(struct page *page, unsigned long offset)
669{ 672{
670 journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal; 673 journal_t *journal = OCFS2_SB(page->mapping->host->i_sb)->journal->j_journal;
671 674
672 journal_invalidatepage(journal, page, offset); 675 jbd2_journal_invalidatepage(journal, page, offset);
673} 676}
674 677
675static int ocfs2_releasepage(struct page *page, gfp_t wait) 678static int ocfs2_releasepage(struct page *page, gfp_t wait)
@@ -678,7 +681,7 @@ static int ocfs2_releasepage(struct page *page, gfp_t wait)
678 681
679 if (!page_has_buffers(page)) 682 if (!page_has_buffers(page))
680 return 0; 683 return 0;
681 return journal_try_to_free_buffers(journal, page, wait); 684 return jbd2_journal_try_to_free_buffers(journal, page, wait);
682} 685}
683 686
684static ssize_t ocfs2_direct_IO(int rw, 687static ssize_t ocfs2_direct_IO(int rw,
@@ -1074,11 +1077,15 @@ static void ocfs2_write_failure(struct inode *inode,
1074 tmppage = wc->w_pages[i]; 1077 tmppage = wc->w_pages[i];
1075 1078
1076 if (page_has_buffers(tmppage)) { 1079 if (page_has_buffers(tmppage)) {
1077 if (ocfs2_should_order_data(inode)) 1080 if (ocfs2_should_order_data(inode)) {
1081 ocfs2_jbd2_file_inode(wc->w_handle, inode);
1082#ifdef CONFIG_OCFS2_COMPAT_JBD
1078 walk_page_buffers(wc->w_handle, 1083 walk_page_buffers(wc->w_handle,
1079 page_buffers(tmppage), 1084 page_buffers(tmppage),
1080 from, to, NULL, 1085 from, to, NULL,
1081 ocfs2_journal_dirty_data); 1086 ocfs2_journal_dirty_data);
1087#endif
1088 }
1082 1089
1083 block_commit_write(tmppage, from, to); 1090 block_commit_write(tmppage, from, to);
1084 } 1091 }
@@ -1917,11 +1924,15 @@ int ocfs2_write_end_nolock(struct address_space *mapping,
1917 } 1924 }
1918 1925
1919 if (page_has_buffers(tmppage)) { 1926 if (page_has_buffers(tmppage)) {
1920 if (ocfs2_should_order_data(inode)) 1927 if (ocfs2_should_order_data(inode)) {
1928 ocfs2_jbd2_file_inode(wc->w_handle, inode);
1929#ifdef CONFIG_OCFS2_COMPAT_JBD
1921 walk_page_buffers(wc->w_handle, 1930 walk_page_buffers(wc->w_handle,
1922 page_buffers(tmppage), 1931 page_buffers(tmppage),
1923 from, to, NULL, 1932 from, to, NULL,
1924 ocfs2_journal_dirty_data); 1933 ocfs2_journal_dirty_data);
1934#endif
1935 }
1925 block_commit_write(tmppage, from, to); 1936 block_commit_write(tmppage, from, to);
1926 } 1937 }
1927 } 1938 }
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 441c6a94059d..c95318bc00cb 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -185,7 +185,7 @@ static int ocfs2_sync_file(struct file *file,
185 goto bail; 185 goto bail;
186 186
187 journal = osb->journal->j_journal; 187 journal = osb->journal->j_journal;
188 err = journal_force_commit(journal); 188 err = jbd2_journal_force_commit(journal);
189 189
190bail: 190bail:
191 mlog_exit(err); 191 mlog_exit(err);
@@ -941,9 +941,15 @@ int ocfs2_setattr(struct dentry *dentry, struct iattr *attr)
941 goto bail_unlock; 941 goto bail_unlock;
942 } 942 }
943 943
944 if (i_size_read(inode) > attr->ia_size) 944 if (i_size_read(inode) > attr->ia_size) {
945 if (ocfs2_should_order_data(inode)) {
946 status = ocfs2_begin_ordered_truncate(inode,
947 attr->ia_size);
948 if (status)
949 goto bail_unlock;
950 }
945 status = ocfs2_truncate_file(inode, bh, attr->ia_size); 951 status = ocfs2_truncate_file(inode, bh, attr->ia_size);
946 else 952 } else
947 status = ocfs2_extend_file(inode, bh, attr->ia_size); 953 status = ocfs2_extend_file(inode, bh, attr->ia_size);
948 if (status < 0) { 954 if (status < 0) {
949 if (status != -ENOSPC) 955 if (status != -ENOSPC)
@@ -1888,7 +1894,7 @@ out_dio:
1888 */ 1894 */
1889 if (old_size != i_size_read(inode) || 1895 if (old_size != i_size_read(inode) ||
1890 old_clusters != OCFS2_I(inode)->ip_clusters) { 1896 old_clusters != OCFS2_I(inode)->ip_clusters) {
1891 ret = journal_force_commit(osb->journal->j_journal); 1897 ret = jbd2_journal_force_commit(osb->journal->j_journal);
1892 if (ret < 0) 1898 if (ret < 0)
1893 written = ret; 1899 written = ret;
1894 } 1900 }
diff --git a/fs/ocfs2/inode.c b/fs/ocfs2/inode.c
index 4738dd25bb94..9d92c859ac94 100644
--- a/fs/ocfs2/inode.c
+++ b/fs/ocfs2/inode.c
@@ -534,6 +534,9 @@ static int ocfs2_truncate_for_delete(struct ocfs2_super *osb,
534 * data and fast symlinks. 534 * data and fast symlinks.
535 */ 535 */
536 if (fe->i_clusters) { 536 if (fe->i_clusters) {
537 if (ocfs2_should_order_data(inode))
538 ocfs2_begin_ordered_truncate(inode, 0);
539
537 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS); 540 handle = ocfs2_start_trans(osb, OCFS2_INODE_UPDATE_CREDITS);
538 if (IS_ERR(handle)) { 541 if (IS_ERR(handle)) {
539 status = PTR_ERR(handle); 542 status = PTR_ERR(handle);
@@ -1100,6 +1103,8 @@ void ocfs2_clear_inode(struct inode *inode)
1100 oi->ip_last_trans = 0; 1103 oi->ip_last_trans = 0;
1101 oi->ip_dir_start_lookup = 0; 1104 oi->ip_dir_start_lookup = 0;
1102 oi->ip_blkno = 0ULL; 1105 oi->ip_blkno = 0ULL;
1106 jbd2_journal_release_jbd_inode(OCFS2_SB(inode->i_sb)->journal->j_journal,
1107 &oi->ip_jinode);
1103 1108
1104bail: 1109bail:
1105 mlog_exit_void(); 1110 mlog_exit_void();
diff --git a/fs/ocfs2/inode.h b/fs/ocfs2/inode.h
index 499bc62e758b..f66e4340f178 100644
--- a/fs/ocfs2/inode.h
+++ b/fs/ocfs2/inode.h
@@ -71,6 +71,7 @@ struct ocfs2_inode_info
71 struct ocfs2_extent_map ip_extent_map; 71 struct ocfs2_extent_map ip_extent_map;
72 72
73 struct inode vfs_inode; 73 struct inode vfs_inode;
74 struct jbd2_inode ip_jinode;
74}; 75};
75 76
76/* 77/*
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c
index c47bc2a809c2..373d94366a4c 100644
--- a/fs/ocfs2/journal.c
+++ b/fs/ocfs2/journal.c
@@ -215,9 +215,9 @@ static int ocfs2_commit_cache(struct ocfs2_super *osb)
215 goto finally; 215 goto finally;
216 } 216 }
217 217
218 journal_lock_updates(journal->j_journal); 218 jbd2_journal_lock_updates(journal->j_journal);
219 status = journal_flush(journal->j_journal); 219 status = jbd2_journal_flush(journal->j_journal);
220 journal_unlock_updates(journal->j_journal); 220 jbd2_journal_unlock_updates(journal->j_journal);
221 if (status < 0) { 221 if (status < 0) {
222 up_write(&journal->j_trans_barrier); 222 up_write(&journal->j_trans_barrier);
223 mlog_errno(status); 223 mlog_errno(status);
@@ -264,7 +264,7 @@ handle_t *ocfs2_start_trans(struct ocfs2_super *osb, int max_buffs)
264 264
265 down_read(&osb->journal->j_trans_barrier); 265 down_read(&osb->journal->j_trans_barrier);
266 266
267 handle = journal_start(journal, max_buffs); 267 handle = jbd2_journal_start(journal, max_buffs);
268 if (IS_ERR(handle)) { 268 if (IS_ERR(handle)) {
269 up_read(&osb->journal->j_trans_barrier); 269 up_read(&osb->journal->j_trans_barrier);
270 270
@@ -290,7 +290,7 @@ int ocfs2_commit_trans(struct ocfs2_super *osb,
290 290
291 BUG_ON(!handle); 291 BUG_ON(!handle);
292 292
293 ret = journal_stop(handle); 293 ret = jbd2_journal_stop(handle);
294 if (ret < 0) 294 if (ret < 0)
295 mlog_errno(ret); 295 mlog_errno(ret);
296 296
@@ -304,7 +304,7 @@ int ocfs2_commit_trans(struct ocfs2_super *osb,
304 * transaction. extend_trans will either extend the current handle by 304 * transaction. extend_trans will either extend the current handle by
305 * nblocks, or commit it and start a new one with nblocks credits. 305 * nblocks, or commit it and start a new one with nblocks credits.
306 * 306 *
307 * This might call journal_restart() which will commit dirty buffers 307 * This might call jbd2_journal_restart() which will commit dirty buffers
308 * and then restart the transaction. Before calling 308 * and then restart the transaction. Before calling
309 * ocfs2_extend_trans(), any changed blocks should have been 309 * ocfs2_extend_trans(), any changed blocks should have been
310 * dirtied. After calling it, all blocks which need to be changed must 310 * dirtied. After calling it, all blocks which need to be changed must
@@ -332,7 +332,7 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)
332#ifdef CONFIG_OCFS2_DEBUG_FS 332#ifdef CONFIG_OCFS2_DEBUG_FS
333 status = 1; 333 status = 1;
334#else 334#else
335 status = journal_extend(handle, nblocks); 335 status = jbd2_journal_extend(handle, nblocks);
336 if (status < 0) { 336 if (status < 0) {
337 mlog_errno(status); 337 mlog_errno(status);
338 goto bail; 338 goto bail;
@@ -340,8 +340,10 @@ int ocfs2_extend_trans(handle_t *handle, int nblocks)
340#endif 340#endif
341 341
342 if (status > 0) { 342 if (status > 0) {
343 mlog(0, "journal_extend failed, trying journal_restart\n"); 343 mlog(0,
344 status = journal_restart(handle, nblocks); 344 "jbd2_journal_extend failed, trying "
345 "jbd2_journal_restart\n");
346 status = jbd2_journal_restart(handle, nblocks);
345 if (status < 0) { 347 if (status < 0) {
346 mlog_errno(status); 348 mlog_errno(status);
347 goto bail; 349 goto bail;
@@ -393,11 +395,11 @@ int ocfs2_journal_access(handle_t *handle,
393 switch (type) { 395 switch (type) {
394 case OCFS2_JOURNAL_ACCESS_CREATE: 396 case OCFS2_JOURNAL_ACCESS_CREATE:
395 case OCFS2_JOURNAL_ACCESS_WRITE: 397 case OCFS2_JOURNAL_ACCESS_WRITE:
396 status = journal_get_write_access(handle, bh); 398 status = jbd2_journal_get_write_access(handle, bh);
397 break; 399 break;
398 400
399 case OCFS2_JOURNAL_ACCESS_UNDO: 401 case OCFS2_JOURNAL_ACCESS_UNDO:
400 status = journal_get_undo_access(handle, bh); 402 status = jbd2_journal_get_undo_access(handle, bh);
401 break; 403 break;
402 404
403 default: 405 default:
@@ -422,7 +424,7 @@ int ocfs2_journal_dirty(handle_t *handle,
422 mlog_entry("(bh->b_blocknr=%llu)\n", 424 mlog_entry("(bh->b_blocknr=%llu)\n",
423 (unsigned long long)bh->b_blocknr); 425 (unsigned long long)bh->b_blocknr);
424 426
425 status = journal_dirty_metadata(handle, bh); 427 status = jbd2_journal_dirty_metadata(handle, bh);
426 if (status < 0) 428 if (status < 0)
427 mlog(ML_ERROR, "Could not dirty metadata buffer. " 429 mlog(ML_ERROR, "Could not dirty metadata buffer. "
428 "(bh->b_blocknr=%llu)\n", 430 "(bh->b_blocknr=%llu)\n",
@@ -432,6 +434,7 @@ int ocfs2_journal_dirty(handle_t *handle,
432 return status; 434 return status;
433} 435}
434 436
437#ifdef CONFIG_OCFS2_COMPAT_JBD
435int ocfs2_journal_dirty_data(handle_t *handle, 438int ocfs2_journal_dirty_data(handle_t *handle,
436 struct buffer_head *bh) 439 struct buffer_head *bh)
437{ 440{
@@ -443,8 +446,9 @@ int ocfs2_journal_dirty_data(handle_t *handle,
443 446
444 return err; 447 return err;
445} 448}
449#endif
446 450
447#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD_DEFAULT_MAX_COMMIT_AGE) 451#define OCFS2_DEFAULT_COMMIT_INTERVAL (HZ * JBD2_DEFAULT_MAX_COMMIT_AGE)
448 452
449void ocfs2_set_journal_params(struct ocfs2_super *osb) 453void ocfs2_set_journal_params(struct ocfs2_super *osb)
450{ 454{
@@ -457,9 +461,9 @@ void ocfs2_set_journal_params(struct ocfs2_super *osb)
457 spin_lock(&journal->j_state_lock); 461 spin_lock(&journal->j_state_lock);
458 journal->j_commit_interval = commit_interval; 462 journal->j_commit_interval = commit_interval;
459 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER) 463 if (osb->s_mount_opt & OCFS2_MOUNT_BARRIER)
460 journal->j_flags |= JFS_BARRIER; 464 journal->j_flags |= JBD2_BARRIER;
461 else 465 else
462 journal->j_flags &= ~JFS_BARRIER; 466 journal->j_flags &= ~JBD2_BARRIER;
463 spin_unlock(&journal->j_state_lock); 467 spin_unlock(&journal->j_state_lock);
464} 468}
465 469
@@ -524,14 +528,14 @@ int ocfs2_journal_init(struct ocfs2_journal *journal, int *dirty)
524 mlog(0, "inode->ip_clusters = %u\n", OCFS2_I(inode)->ip_clusters); 528 mlog(0, "inode->ip_clusters = %u\n", OCFS2_I(inode)->ip_clusters);
525 529
526 /* call the kernels journal init function now */ 530 /* call the kernels journal init function now */
527 j_journal = journal_init_inode(inode); 531 j_journal = jbd2_journal_init_inode(inode);
528 if (j_journal == NULL) { 532 if (j_journal == NULL) {
529 mlog(ML_ERROR, "Linux journal layer error\n"); 533 mlog(ML_ERROR, "Linux journal layer error\n");
530 status = -EINVAL; 534 status = -EINVAL;
531 goto done; 535 goto done;
532 } 536 }
533 537
534 mlog(0, "Returned from journal_init_inode\n"); 538 mlog(0, "Returned from jbd2_journal_init_inode\n");
535 mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen); 539 mlog(0, "j_journal->j_maxlen = %u\n", j_journal->j_maxlen);
536 540
537 *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) & 541 *dirty = (le32_to_cpu(di->id1.journal1.ij_flags) &
@@ -639,7 +643,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
639 if (journal->j_state != OCFS2_JOURNAL_LOADED) 643 if (journal->j_state != OCFS2_JOURNAL_LOADED)
640 goto done; 644 goto done;
641 645
642 /* need to inc inode use count as journal_destroy will iput. */ 646 /* need to inc inode use count - jbd2_journal_destroy will iput. */
643 if (!igrab(inode)) 647 if (!igrab(inode))
644 BUG(); 648 BUG();
645 649
@@ -668,9 +672,9 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
668 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0); 672 BUG_ON(atomic_read(&(osb->journal->j_num_trans)) != 0);
669 673
670 if (ocfs2_mount_local(osb)) { 674 if (ocfs2_mount_local(osb)) {
671 journal_lock_updates(journal->j_journal); 675 jbd2_journal_lock_updates(journal->j_journal);
672 status = journal_flush(journal->j_journal); 676 status = jbd2_journal_flush(journal->j_journal);
673 journal_unlock_updates(journal->j_journal); 677 jbd2_journal_unlock_updates(journal->j_journal);
674 if (status < 0) 678 if (status < 0)
675 mlog_errno(status); 679 mlog_errno(status);
676 } 680 }
@@ -686,7 +690,7 @@ void ocfs2_journal_shutdown(struct ocfs2_super *osb)
686 } 690 }
687 691
688 /* Shutdown the kernel journal system */ 692 /* Shutdown the kernel journal system */
689 journal_destroy(journal->j_journal); 693 jbd2_journal_destroy(journal->j_journal);
690 694
691 OCFS2_I(inode)->ip_open_count--; 695 OCFS2_I(inode)->ip_open_count--;
692 696
@@ -711,15 +715,15 @@ static void ocfs2_clear_journal_error(struct super_block *sb,
711{ 715{
712 int olderr; 716 int olderr;
713 717
714 olderr = journal_errno(journal); 718 olderr = jbd2_journal_errno(journal);
715 if (olderr) { 719 if (olderr) {
716 mlog(ML_ERROR, "File system error %d recorded in " 720 mlog(ML_ERROR, "File system error %d recorded in "
717 "journal %u.\n", olderr, slot); 721 "journal %u.\n", olderr, slot);
718 mlog(ML_ERROR, "File system on device %s needs checking.\n", 722 mlog(ML_ERROR, "File system on device %s needs checking.\n",
719 sb->s_id); 723 sb->s_id);
720 724
721 journal_ack_err(journal); 725 jbd2_journal_ack_err(journal);
722 journal_clear_err(journal); 726 jbd2_journal_clear_err(journal);
723 } 727 }
724} 728}
725 729
@@ -734,7 +738,7 @@ int ocfs2_journal_load(struct ocfs2_journal *journal, int local, int replayed)
734 738
735 osb = journal->j_osb; 739 osb = journal->j_osb;
736 740
737 status = journal_load(journal->j_journal); 741 status = jbd2_journal_load(journal->j_journal);
738 if (status < 0) { 742 if (status < 0) {
739 mlog(ML_ERROR, "Failed to load journal!\n"); 743 mlog(ML_ERROR, "Failed to load journal!\n");
740 goto done; 744 goto done;
@@ -778,7 +782,7 @@ int ocfs2_journal_wipe(struct ocfs2_journal *journal, int full)
778 782
779 BUG_ON(!journal); 783 BUG_ON(!journal);
780 784
781 status = journal_wipe(journal->j_journal, full); 785 status = jbd2_journal_wipe(journal->j_journal, full);
782 if (status < 0) { 786 if (status < 0) {
783 mlog_errno(status); 787 mlog_errno(status);
784 goto bail; 788 goto bail;
@@ -1229,19 +1233,19 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1229 } 1233 }
1230 1234
1231 mlog(0, "calling journal_init_inode\n"); 1235 mlog(0, "calling journal_init_inode\n");
1232 journal = journal_init_inode(inode); 1236 journal = jbd2_journal_init_inode(inode);
1233 if (journal == NULL) { 1237 if (journal == NULL) {
1234 mlog(ML_ERROR, "Linux journal layer error\n"); 1238 mlog(ML_ERROR, "Linux journal layer error\n");
1235 status = -EIO; 1239 status = -EIO;
1236 goto done; 1240 goto done;
1237 } 1241 }
1238 1242
1239 status = journal_load(journal); 1243 status = jbd2_journal_load(journal);
1240 if (status < 0) { 1244 if (status < 0) {
1241 mlog_errno(status); 1245 mlog_errno(status);
1242 if (!igrab(inode)) 1246 if (!igrab(inode))
1243 BUG(); 1247 BUG();
1244 journal_destroy(journal); 1248 jbd2_journal_destroy(journal);
1245 goto done; 1249 goto done;
1246 } 1250 }
1247 1251
@@ -1249,9 +1253,9 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1249 1253
1250 /* wipe the journal */ 1254 /* wipe the journal */
1251 mlog(0, "flushing the journal.\n"); 1255 mlog(0, "flushing the journal.\n");
1252 journal_lock_updates(journal); 1256 jbd2_journal_lock_updates(journal);
1253 status = journal_flush(journal); 1257 status = jbd2_journal_flush(journal);
1254 journal_unlock_updates(journal); 1258 jbd2_journal_unlock_updates(journal);
1255 if (status < 0) 1259 if (status < 0)
1256 mlog_errno(status); 1260 mlog_errno(status);
1257 1261
@@ -1272,7 +1276,7 @@ static int ocfs2_replay_journal(struct ocfs2_super *osb,
1272 if (!igrab(inode)) 1276 if (!igrab(inode))
1273 BUG(); 1277 BUG();
1274 1278
1275 journal_destroy(journal); 1279 jbd2_journal_destroy(journal);
1276 1280
1277done: 1281done:
1278 /* drop the lock on this nodes journal */ 1282 /* drop the lock on this nodes journal */
diff --git a/fs/ocfs2/journal.h b/fs/ocfs2/journal.h
index 08d1add14872..d4d14e9a3cea 100644
--- a/fs/ocfs2/journal.h
+++ b/fs/ocfs2/journal.h
@@ -27,7 +27,12 @@
27#define OCFS2_JOURNAL_H 27#define OCFS2_JOURNAL_H
28 28
29#include <linux/fs.h> 29#include <linux/fs.h>
30#include <linux/jbd.h> 30#ifndef CONFIG_OCFS2_COMPAT_JBD
31# include <linux/jbd2.h>
32#else
33# include <linux/jbd.h>
34# include "ocfs2_jbd_compat.h"
35#endif
31 36
32enum ocfs2_journal_state { 37enum ocfs2_journal_state {
33 OCFS2_JOURNAL_FREE = 0, 38 OCFS2_JOURNAL_FREE = 0,
@@ -215,8 +220,8 @@ static inline void ocfs2_checkpoint_inode(struct inode *inode)
215 * buffer. Will have to call ocfs2_journal_dirty once 220 * buffer. Will have to call ocfs2_journal_dirty once
216 * we've actually dirtied it. Type is one of . or . 221 * we've actually dirtied it. Type is one of . or .
217 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data. 222 * ocfs2_journal_dirty - Mark a journalled buffer as having dirty data.
218 * ocfs2_journal_dirty_data - Indicate that a data buffer should go out before 223 * ocfs2_jbd2_file_inode - Mark an inode so that its data goes out before
219 * the current handle commits. 224 * the current handle commits.
220 */ 225 */
221 226
222/* You must always start_trans with a number of buffs > 0, but it's 227/* You must always start_trans with a number of buffs > 0, but it's
@@ -268,8 +273,10 @@ int ocfs2_journal_access(handle_t *handle,
268 */ 273 */
269int ocfs2_journal_dirty(handle_t *handle, 274int ocfs2_journal_dirty(handle_t *handle,
270 struct buffer_head *bh); 275 struct buffer_head *bh);
276#ifdef CONFIG_OCFS2_COMPAT_JBD
271int ocfs2_journal_dirty_data(handle_t *handle, 277int ocfs2_journal_dirty_data(handle_t *handle,
272 struct buffer_head *bh); 278 struct buffer_head *bh);
279#endif
273 280
274/* 281/*
275 * Credit Macros: 282 * Credit Macros:
@@ -430,4 +437,16 @@ static inline int ocfs2_calc_tree_trunc_credits(struct super_block *sb,
430 return credits; 437 return credits;
431} 438}
432 439
440static inline int ocfs2_jbd2_file_inode(handle_t *handle, struct inode *inode)
441{
442 return jbd2_journal_file_inode(handle, &OCFS2_I(inode)->ip_jinode);
443}
444
445static inline int ocfs2_begin_ordered_truncate(struct inode *inode,
446 loff_t new_size)
447{
448 return jbd2_journal_begin_ordered_truncate(&OCFS2_I(inode)->ip_jinode,
449 new_size);
450}
451
433#endif /* OCFS2_JOURNAL_H */ 452#endif /* OCFS2_JOURNAL_H */
diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
index 78ae4f87e6b0..a21a465490c4 100644
--- a/fs/ocfs2/ocfs2.h
+++ b/fs/ocfs2/ocfs2.h
@@ -34,7 +34,12 @@
34#include <linux/workqueue.h> 34#include <linux/workqueue.h>
35#include <linux/kref.h> 35#include <linux/kref.h>
36#include <linux/mutex.h> 36#include <linux/mutex.h>
37#include <linux/jbd.h> 37#ifndef CONFIG_OCFS2_COMPAT_JBD
38# include <linux/jbd2.h>
39#else
40# include <linux/jbd.h>
41# include "ocfs2_jbd_compat.h"
42#endif
38 43
39/* For union ocfs2_dlm_lksb */ 44/* For union ocfs2_dlm_lksb */
40#include "stackglue.h" 45#include "stackglue.h"
diff --git a/fs/ocfs2/ocfs2_jbd_compat.h b/fs/ocfs2/ocfs2_jbd_compat.h
new file mode 100644
index 000000000000..b91c78f8f558
--- /dev/null
+++ b/fs/ocfs2/ocfs2_jbd_compat.h
@@ -0,0 +1,82 @@
1/* -*- mode: c; c-basic-offset: 8; -*-
2 * vim: noexpandtab sw=8 ts=8 sts=0:
3 *
4 * ocfs2_jbd_compat.h
5 *
6 * Compatibility defines for JBD.
7 *
8 * Copyright (C) 2008 Oracle. All rights reserved.
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public
12 * License version 2 as published by the Free Software Foundation.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 */
19
20#ifndef OCFS2_JBD_COMPAT_H
21#define OCFS2_JBD_COMPAT_H
22
23#ifndef CONFIG_OCFS2_COMPAT_JBD
24# error Should not have been included
25#endif
26
27struct jbd2_inode {
28 unsigned int dummy;
29};
30
31#define JBD2_BARRIER JFS_BARRIER
32#define JBD2_DEFAULT_MAX_COMMIT_AGE JBD_DEFAULT_MAX_COMMIT_AGE
33
34#define jbd2_journal_ack_err journal_ack_err
35#define jbd2_journal_clear_err journal_clear_err
36#define jbd2_journal_destroy journal_destroy
37#define jbd2_journal_dirty_metadata journal_dirty_metadata
38#define jbd2_journal_errno journal_errno
39#define jbd2_journal_extend journal_extend
40#define jbd2_journal_flush journal_flush
41#define jbd2_journal_force_commit journal_force_commit
42#define jbd2_journal_get_write_access journal_get_write_access
43#define jbd2_journal_get_undo_access journal_get_undo_access
44#define jbd2_journal_init_inode journal_init_inode
45#define jbd2_journal_invalidatepage journal_invalidatepage
46#define jbd2_journal_load journal_load
47#define jbd2_journal_lock_updates journal_lock_updates
48#define jbd2_journal_restart journal_restart
49#define jbd2_journal_start journal_start
50#define jbd2_journal_start_commit journal_start_commit
51#define jbd2_journal_stop journal_stop
52#define jbd2_journal_try_to_free_buffers journal_try_to_free_buffers
53#define jbd2_journal_unlock_updates journal_unlock_updates
54#define jbd2_journal_wipe journal_wipe
55#define jbd2_log_wait_commit log_wait_commit
56
57static inline int jbd2_journal_file_inode(handle_t *handle,
58 struct jbd2_inode *inode)
59{
60 return 0;
61}
62
63static inline int jbd2_journal_begin_ordered_truncate(struct jbd2_inode *inode,
64 loff_t new_size)
65{
66 return 0;
67}
68
69static inline void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode,
70 struct inode *inode)
71{
72 return;
73}
74
75static inline void jbd2_journal_release_jbd_inode(journal_t *journal,
76 struct jbd2_inode *jinode)
77{
78 return;
79}
80
81
82#endif /* OCFS2_JBD_COMPAT_H */
diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
index 1a51c8c53bef..8b4c5c67dcd4 100644
--- a/fs/ocfs2/super.c
+++ b/fs/ocfs2/super.c
@@ -212,10 +212,11 @@ static int ocfs2_sync_fs(struct super_block *sb, int wait)
212 ocfs2_schedule_truncate_log_flush(osb, 0); 212 ocfs2_schedule_truncate_log_flush(osb, 0);
213 } 213 }
214 214
215 if (journal_start_commit(OCFS2_SB(sb)->journal->j_journal, &target)) { 215 if (jbd2_journal_start_commit(OCFS2_SB(sb)->journal->j_journal,
216 &target)) {
216 if (wait) 217 if (wait)
217 log_wait_commit(OCFS2_SB(sb)->journal->j_journal, 218 jbd2_log_wait_commit(OCFS2_SB(sb)->journal->j_journal,
218 target); 219 target);
219 } 220 }
220 return 0; 221 return 0;
221} 222}
@@ -332,6 +333,7 @@ static struct inode *ocfs2_alloc_inode(struct super_block *sb)
332 if (!oi) 333 if (!oi)
333 return NULL; 334 return NULL;
334 335
336 jbd2_journal_init_jbd_inode(&oi->ip_jinode, &oi->vfs_inode);
335 return &oi->vfs_inode; 337 return &oi->vfs_inode;
336} 338}
337 339
@@ -896,7 +898,7 @@ static int ocfs2_parse_options(struct super_block *sb,
896 if (option < 0) 898 if (option < 0)
897 return 0; 899 return 0;
898 if (option == 0) 900 if (option == 0)
899 option = JBD_DEFAULT_MAX_COMMIT_AGE; 901 option = JBD2_DEFAULT_MAX_COMMIT_AGE;
900 mopt->commit_interval = HZ * option; 902 mopt->commit_interval = HZ * option;
901 break; 903 break;
902 case Opt_localalloc: 904 case Opt_localalloc:
diff --git a/fs/ocfs2/uptodate.c b/fs/ocfs2/uptodate.c
index e26459e7d554..523514020891 100644
--- a/fs/ocfs2/uptodate.c
+++ b/fs/ocfs2/uptodate.c
@@ -53,7 +53,11 @@
53#include <linux/highmem.h> 53#include <linux/highmem.h>
54#include <linux/buffer_head.h> 54#include <linux/buffer_head.h>
55#include <linux/rbtree.h> 55#include <linux/rbtree.h>
56#include <linux/jbd.h> 56#ifndef CONFIG_OCFS2_COMPAT_JBD
57# include <linux/jbd2.h>
58#else
59# include <linux/jbd.h>
60#endif
57 61
58#define MLOG_MASK_PREFIX ML_UPTODATE 62#define MLOG_MASK_PREFIX ML_UPTODATE
59 63