aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd2/journal.c
diff options
context:
space:
mode:
authorMingming Cao <cmm@us.ibm.com>2006-10-11 04:20:59 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-10-11 14:14:15 -0400
commitf7f4bccb729844a0fa873e224e3a6f7eeed095bb (patch)
treeb5b8ce65b5c17b4a7d45e43a3530f2cc977fb894 /fs/jbd2/journal.c
parent470decc613ab2048b619a01028072d932d9086ee (diff)
[PATCH] jbd2: rename jbd2 symbols to avoid duplication of jbd symbols
Mingming Cao originally did this work, and Shaggy reproduced it using some scripts from her. 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/jbd2/journal.c')
-rw-r--r--fs/jbd2/journal.c454
1 files changed, 227 insertions, 227 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c
index c518dd8fe60a..3fbbba20a516 100644
--- a/fs/jbd2/journal.c
+++ b/fs/jbd2/journal.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * linux/fs/jbd/journal.c 2 * linux/fs/jbd2/journal.c
3 * 3 *
4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998
5 * 5 *
@@ -25,7 +25,7 @@
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/time.h> 26#include <linux/time.h>
27#include <linux/fs.h> 27#include <linux/fs.h>
28#include <linux/jbd.h> 28#include <linux/jbd2.h>
29#include <linux/errno.h> 29#include <linux/errno.h>
30#include <linux/slab.h> 30#include <linux/slab.h>
31#include <linux/smp_lock.h> 31#include <linux/smp_lock.h>
@@ -40,51 +40,51 @@
40#include <asm/uaccess.h> 40#include <asm/uaccess.h>
41#include <asm/page.h> 41#include <asm/page.h>
42 42
43EXPORT_SYMBOL(journal_start); 43EXPORT_SYMBOL(jbd2_journal_start);
44EXPORT_SYMBOL(journal_restart); 44EXPORT_SYMBOL(jbd2_journal_restart);
45EXPORT_SYMBOL(journal_extend); 45EXPORT_SYMBOL(jbd2_journal_extend);
46EXPORT_SYMBOL(journal_stop); 46EXPORT_SYMBOL(jbd2_journal_stop);
47EXPORT_SYMBOL(journal_lock_updates); 47EXPORT_SYMBOL(jbd2_journal_lock_updates);
48EXPORT_SYMBOL(journal_unlock_updates); 48EXPORT_SYMBOL(jbd2_journal_unlock_updates);
49EXPORT_SYMBOL(journal_get_write_access); 49EXPORT_SYMBOL(jbd2_journal_get_write_access);
50EXPORT_SYMBOL(journal_get_create_access); 50EXPORT_SYMBOL(jbd2_journal_get_create_access);
51EXPORT_SYMBOL(journal_get_undo_access); 51EXPORT_SYMBOL(jbd2_journal_get_undo_access);
52EXPORT_SYMBOL(journal_dirty_data); 52EXPORT_SYMBOL(jbd2_journal_dirty_data);
53EXPORT_SYMBOL(journal_dirty_metadata); 53EXPORT_SYMBOL(jbd2_journal_dirty_metadata);
54EXPORT_SYMBOL(journal_release_buffer); 54EXPORT_SYMBOL(jbd2_journal_release_buffer);
55EXPORT_SYMBOL(journal_forget); 55EXPORT_SYMBOL(jbd2_journal_forget);
56#if 0 56#if 0
57EXPORT_SYMBOL(journal_sync_buffer); 57EXPORT_SYMBOL(journal_sync_buffer);
58#endif 58#endif
59EXPORT_SYMBOL(journal_flush); 59EXPORT_SYMBOL(jbd2_journal_flush);
60EXPORT_SYMBOL(journal_revoke); 60EXPORT_SYMBOL(jbd2_journal_revoke);
61 61
62EXPORT_SYMBOL(journal_init_dev); 62EXPORT_SYMBOL(jbd2_journal_init_dev);
63EXPORT_SYMBOL(journal_init_inode); 63EXPORT_SYMBOL(jbd2_journal_init_inode);
64EXPORT_SYMBOL(journal_update_format); 64EXPORT_SYMBOL(jbd2_journal_update_format);
65EXPORT_SYMBOL(journal_check_used_features); 65EXPORT_SYMBOL(jbd2_journal_check_used_features);
66EXPORT_SYMBOL(journal_check_available_features); 66EXPORT_SYMBOL(jbd2_journal_check_available_features);
67EXPORT_SYMBOL(journal_set_features); 67EXPORT_SYMBOL(jbd2_journal_set_features);
68EXPORT_SYMBOL(journal_create); 68EXPORT_SYMBOL(jbd2_journal_create);
69EXPORT_SYMBOL(journal_load); 69EXPORT_SYMBOL(jbd2_journal_load);
70EXPORT_SYMBOL(journal_destroy); 70EXPORT_SYMBOL(jbd2_journal_destroy);
71EXPORT_SYMBOL(journal_update_superblock); 71EXPORT_SYMBOL(jbd2_journal_update_superblock);
72EXPORT_SYMBOL(journal_abort); 72EXPORT_SYMBOL(jbd2_journal_abort);
73EXPORT_SYMBOL(journal_errno); 73EXPORT_SYMBOL(jbd2_journal_errno);
74EXPORT_SYMBOL(journal_ack_err); 74EXPORT_SYMBOL(jbd2_journal_ack_err);
75EXPORT_SYMBOL(journal_clear_err); 75EXPORT_SYMBOL(jbd2_journal_clear_err);
76EXPORT_SYMBOL(log_wait_commit); 76EXPORT_SYMBOL(jbd2_log_wait_commit);
77EXPORT_SYMBOL(journal_start_commit); 77EXPORT_SYMBOL(jbd2_journal_start_commit);
78EXPORT_SYMBOL(journal_force_commit_nested); 78EXPORT_SYMBOL(jbd2_journal_force_commit_nested);
79EXPORT_SYMBOL(journal_wipe); 79EXPORT_SYMBOL(jbd2_journal_wipe);
80EXPORT_SYMBOL(journal_blocks_per_page); 80EXPORT_SYMBOL(jbd2_journal_blocks_per_page);
81EXPORT_SYMBOL(journal_invalidatepage); 81EXPORT_SYMBOL(jbd2_journal_invalidatepage);
82EXPORT_SYMBOL(journal_try_to_free_buffers); 82EXPORT_SYMBOL(jbd2_journal_try_to_free_buffers);
83EXPORT_SYMBOL(journal_force_commit); 83EXPORT_SYMBOL(jbd2_journal_force_commit);
84 84
85static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *); 85static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *);
86static void __journal_abort_soft (journal_t *journal, int errno); 86static void __journal_abort_soft (journal_t *journal, int errno);
87static int journal_create_jbd_slab(size_t slab_size); 87static int jbd2_journal_create_jbd_slab(size_t slab_size);
88 88
89/* 89/*
90 * Helper function used to manage commit timeouts 90 * Helper function used to manage commit timeouts
@@ -98,7 +98,7 @@ static void commit_timeout(unsigned long __data)
98} 98}
99 99
100/* 100/*
101 * kjournald: The main thread function used to manage a logging device 101 * kjournald2: The main thread function used to manage a logging device
102 * journal. 102 * journal.
103 * 103 *
104 * This kernel thread is responsible for two things: 104 * This kernel thread is responsible for two things:
@@ -113,7 +113,7 @@ static void commit_timeout(unsigned long __data)
113 * known as checkpointing, and this thread is responsible for that job. 113 * known as checkpointing, and this thread is responsible for that job.
114 */ 114 */
115 115
116static int kjournald(void *arg) 116static int kjournald2(void *arg)
117{ 117{
118 journal_t *journal = arg; 118 journal_t *journal = arg;
119 transaction_t *transaction; 119 transaction_t *transaction;
@@ -129,7 +129,7 @@ static int kjournald(void *arg)
129 journal->j_task = current; 129 journal->j_task = current;
130 wake_up(&journal->j_wait_done_commit); 130 wake_up(&journal->j_wait_done_commit);
131 131
132 printk(KERN_INFO "kjournald starting. Commit interval %ld seconds\n", 132 printk(KERN_INFO "kjournald2 starting. Commit interval %ld seconds\n",
133 journal->j_commit_interval / HZ); 133 journal->j_commit_interval / HZ);
134 134
135 /* 135 /*
@@ -138,7 +138,7 @@ static int kjournald(void *arg)
138 spin_lock(&journal->j_state_lock); 138 spin_lock(&journal->j_state_lock);
139 139
140loop: 140loop:
141 if (journal->j_flags & JFS_UNMOUNT) 141 if (journal->j_flags & JBD2_UNMOUNT)
142 goto end_loop; 142 goto end_loop;
143 143
144 jbd_debug(1, "commit_sequence=%d, commit_request=%d\n", 144 jbd_debug(1, "commit_sequence=%d, commit_request=%d\n",
@@ -148,7 +148,7 @@ loop:
148 jbd_debug(1, "OK, requests differ\n"); 148 jbd_debug(1, "OK, requests differ\n");
149 spin_unlock(&journal->j_state_lock); 149 spin_unlock(&journal->j_state_lock);
150 del_timer_sync(&journal->j_commit_timer); 150 del_timer_sync(&journal->j_commit_timer);
151 journal_commit_transaction(journal); 151 jbd2_journal_commit_transaction(journal);
152 spin_lock(&journal->j_state_lock); 152 spin_lock(&journal->j_state_lock);
153 goto loop; 153 goto loop;
154 } 154 }
@@ -160,7 +160,7 @@ loop:
160 * good idea, because that depends on threads that may 160 * good idea, because that depends on threads that may
161 * be already stopped. 161 * be already stopped.
162 */ 162 */
163 jbd_debug(1, "Now suspending kjournald\n"); 163 jbd_debug(1, "Now suspending kjournald2\n");
164 spin_unlock(&journal->j_state_lock); 164 spin_unlock(&journal->j_state_lock);
165 refrigerator(); 165 refrigerator();
166 spin_lock(&journal->j_state_lock); 166 spin_lock(&journal->j_state_lock);
@@ -180,7 +180,7 @@ loop:
180 if (transaction && time_after_eq(jiffies, 180 if (transaction && time_after_eq(jiffies,
181 transaction->t_expires)) 181 transaction->t_expires))
182 should_sleep = 0; 182 should_sleep = 0;
183 if (journal->j_flags & JFS_UNMOUNT) 183 if (journal->j_flags & JBD2_UNMOUNT)
184 should_sleep = 0; 184 should_sleep = 0;
185 if (should_sleep) { 185 if (should_sleep) {
186 spin_unlock(&journal->j_state_lock); 186 spin_unlock(&journal->j_state_lock);
@@ -190,7 +190,7 @@ loop:
190 finish_wait(&journal->j_wait_commit, &wait); 190 finish_wait(&journal->j_wait_commit, &wait);
191 } 191 }
192 192
193 jbd_debug(1, "kjournald wakes\n"); 193 jbd_debug(1, "kjournald2 wakes\n");
194 194
195 /* 195 /*
196 * Were we woken up by a commit wakeup event? 196 * Were we woken up by a commit wakeup event?
@@ -211,16 +211,16 @@ end_loop:
211 return 0; 211 return 0;
212} 212}
213 213
214static void journal_start_thread(journal_t *journal) 214static void jbd2_journal_start_thread(journal_t *journal)
215{ 215{
216 kthread_run(kjournald, journal, "kjournald"); 216 kthread_run(kjournald2, journal, "kjournald2");
217 wait_event(journal->j_wait_done_commit, journal->j_task != 0); 217 wait_event(journal->j_wait_done_commit, journal->j_task != 0);
218} 218}
219 219
220static void journal_kill_thread(journal_t *journal) 220static void journal_kill_thread(journal_t *journal)
221{ 221{
222 spin_lock(&journal->j_state_lock); 222 spin_lock(&journal->j_state_lock);
223 journal->j_flags |= JFS_UNMOUNT; 223 journal->j_flags |= JBD2_UNMOUNT;
224 224
225 while (journal->j_task) { 225 while (journal->j_task) {
226 wake_up(&journal->j_wait_commit); 226 wake_up(&journal->j_wait_commit);
@@ -232,7 +232,7 @@ static void journal_kill_thread(journal_t *journal)
232} 232}
233 233
234/* 234/*
235 * journal_write_metadata_buffer: write a metadata buffer to the journal. 235 * jbd2_journal_write_metadata_buffer: write a metadata buffer to the journal.
236 * 236 *
237 * Writes a metadata buffer to a given disk block. The actual IO is not 237 * Writes a metadata buffer to a given disk block. The actual IO is not
238 * performed but a new buffer_head is constructed which labels the data 238 * performed but a new buffer_head is constructed which labels the data
@@ -240,7 +240,7 @@ static void journal_kill_thread(journal_t *journal)
240 * 240 *
241 * Any magic-number escaping which needs to be done will cause a 241 * Any magic-number escaping which needs to be done will cause a
242 * copy-out here. If the buffer happens to start with the 242 * copy-out here. If the buffer happens to start with the
243 * JFS_MAGIC_NUMBER, then we can't write it to the log directly: the 243 * JBD2_MAGIC_NUMBER, then we can't write it to the log directly: the
244 * magic number is only written to the log for descripter blocks. In 244 * magic number is only written to the log for descripter blocks. In
245 * this case, we copy the data and replace the first word with 0, and we 245 * this case, we copy the data and replace the first word with 0, and we
246 * return a result code which indicates that this buffer needs to be 246 * return a result code which indicates that this buffer needs to be
@@ -268,7 +268,7 @@ static void journal_kill_thread(journal_t *journal)
268 * Bit 1 set == buffer copy-out performed (kfree the data after IO) 268 * Bit 1 set == buffer copy-out performed (kfree the data after IO)
269 */ 269 */
270 270
271int journal_write_metadata_buffer(transaction_t *transaction, 271int jbd2_journal_write_metadata_buffer(transaction_t *transaction,
272 struct journal_head *jh_in, 272 struct journal_head *jh_in,
273 struct journal_head **jh_out, 273 struct journal_head **jh_out,
274 unsigned long blocknr) 274 unsigned long blocknr)
@@ -316,7 +316,7 @@ repeat:
316 * Check for escaping 316 * Check for escaping
317 */ 317 */
318 if (*((__be32 *)(mapped_data + new_offset)) == 318 if (*((__be32 *)(mapped_data + new_offset)) ==
319 cpu_to_be32(JFS_MAGIC_NUMBER)) { 319 cpu_to_be32(JBD2_MAGIC_NUMBER)) {
320 need_copy_out = 1; 320 need_copy_out = 1;
321 do_escape = 1; 321 do_escape = 1;
322 } 322 }
@@ -329,10 +329,10 @@ repeat:
329 char *tmp; 329 char *tmp;
330 330
331 jbd_unlock_bh_state(bh_in); 331 jbd_unlock_bh_state(bh_in);
332 tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS); 332 tmp = jbd2_slab_alloc(bh_in->b_size, GFP_NOFS);
333 jbd_lock_bh_state(bh_in); 333 jbd_lock_bh_state(bh_in);
334 if (jh_in->b_frozen_data) { 334 if (jh_in->b_frozen_data) {
335 jbd_slab_free(tmp, bh_in->b_size); 335 jbd2_slab_free(tmp, bh_in->b_size);
336 goto repeat; 336 goto repeat;
337 } 337 }
338 338
@@ -362,7 +362,7 @@ repeat:
362 atomic_set(&new_bh->b_count, 1); 362 atomic_set(&new_bh->b_count, 1);
363 jbd_unlock_bh_state(bh_in); 363 jbd_unlock_bh_state(bh_in);
364 364
365 new_jh = journal_add_journal_head(new_bh); /* This sleeps */ 365 new_jh = jbd2_journal_add_journal_head(new_bh); /* This sleeps */
366 366
367 set_bh_page(new_bh, new_page, new_offset); 367 set_bh_page(new_bh, new_page, new_offset);
368 new_jh->b_transaction = NULL; 368 new_jh->b_transaction = NULL;
@@ -380,9 +380,9 @@ repeat:
380 * copying is moved to the transaction's shadow queue. 380 * copying is moved to the transaction's shadow queue.
381 */ 381 */
382 JBUFFER_TRACE(jh_in, "file as BJ_Shadow"); 382 JBUFFER_TRACE(jh_in, "file as BJ_Shadow");
383 journal_file_buffer(jh_in, transaction, BJ_Shadow); 383 jbd2_journal_file_buffer(jh_in, transaction, BJ_Shadow);
384 JBUFFER_TRACE(new_jh, "file as BJ_IO"); 384 JBUFFER_TRACE(new_jh, "file as BJ_IO");
385 journal_file_buffer(new_jh, transaction, BJ_IO); 385 jbd2_journal_file_buffer(new_jh, transaction, BJ_IO);
386 386
387 return do_escape | (done_copy_out << 1); 387 return do_escape | (done_copy_out << 1);
388} 388}
@@ -393,14 +393,14 @@ repeat:
393 */ 393 */
394 394
395/* 395/*
396 * __log_space_left: Return the number of free blocks left in the journal. 396 * __jbd2_log_space_left: Return the number of free blocks left in the journal.
397 * 397 *
398 * Called with the journal already locked. 398 * Called with the journal already locked.
399 * 399 *
400 * Called under j_state_lock 400 * Called under j_state_lock
401 */ 401 */
402 402
403int __log_space_left(journal_t *journal) 403int __jbd2_log_space_left(journal_t *journal)
404{ 404{
405 int left = journal->j_free; 405 int left = journal->j_free;
406 406
@@ -424,7 +424,7 @@ int __log_space_left(journal_t *journal)
424/* 424/*
425 * Called under j_state_lock. Returns true if a transaction was started. 425 * Called under j_state_lock. Returns true if a transaction was started.
426 */ 426 */
427int __log_start_commit(journal_t *journal, tid_t target) 427int __jbd2_log_start_commit(journal_t *journal, tid_t target)
428{ 428{
429 /* 429 /*
430 * Are we already doing a recent enough commit? 430 * Are we already doing a recent enough commit?
@@ -445,12 +445,12 @@ int __log_start_commit(journal_t *journal, tid_t target)
445 return 0; 445 return 0;
446} 446}
447 447
448int log_start_commit(journal_t *journal, tid_t tid) 448int jbd2_log_start_commit(journal_t *journal, tid_t tid)
449{ 449{
450 int ret; 450 int ret;
451 451
452 spin_lock(&journal->j_state_lock); 452 spin_lock(&journal->j_state_lock);
453 ret = __log_start_commit(journal, tid); 453 ret = __jbd2_log_start_commit(journal, tid);
454 spin_unlock(&journal->j_state_lock); 454 spin_unlock(&journal->j_state_lock);
455 return ret; 455 return ret;
456} 456}
@@ -465,7 +465,7 @@ int log_start_commit(journal_t *journal, tid_t tid)
465 * 465 *
466 * Returns true if a transaction was started. 466 * Returns true if a transaction was started.
467 */ 467 */
468int journal_force_commit_nested(journal_t *journal) 468int jbd2_journal_force_commit_nested(journal_t *journal)
469{ 469{
470 transaction_t *transaction = NULL; 470 transaction_t *transaction = NULL;
471 tid_t tid; 471 tid_t tid;
@@ -473,7 +473,7 @@ int journal_force_commit_nested(journal_t *journal)
473 spin_lock(&journal->j_state_lock); 473 spin_lock(&journal->j_state_lock);
474 if (journal->j_running_transaction && !current->journal_info) { 474 if (journal->j_running_transaction && !current->journal_info) {
475 transaction = journal->j_running_transaction; 475 transaction = journal->j_running_transaction;
476 __log_start_commit(journal, transaction->t_tid); 476 __jbd2_log_start_commit(journal, transaction->t_tid);
477 } else if (journal->j_committing_transaction) 477 } else if (journal->j_committing_transaction)
478 transaction = journal->j_committing_transaction; 478 transaction = journal->j_committing_transaction;
479 479
@@ -484,7 +484,7 @@ int journal_force_commit_nested(journal_t *journal)
484 484
485 tid = transaction->t_tid; 485 tid = transaction->t_tid;
486 spin_unlock(&journal->j_state_lock); 486 spin_unlock(&journal->j_state_lock);
487 log_wait_commit(journal, tid); 487 jbd2_log_wait_commit(journal, tid);
488 return 1; 488 return 1;
489} 489}
490 490
@@ -492,7 +492,7 @@ int journal_force_commit_nested(journal_t *journal)
492 * Start a commit of the current running transaction (if any). Returns true 492 * Start a commit of the current running transaction (if any). Returns true
493 * if a transaction was started, and fills its tid in at *ptid 493 * if a transaction was started, and fills its tid in at *ptid
494 */ 494 */
495int journal_start_commit(journal_t *journal, tid_t *ptid) 495int jbd2_journal_start_commit(journal_t *journal, tid_t *ptid)
496{ 496{
497 int ret = 0; 497 int ret = 0;
498 498
@@ -500,7 +500,7 @@ int journal_start_commit(journal_t *journal, tid_t *ptid)
500 if (journal->j_running_transaction) { 500 if (journal->j_running_transaction) {
501 tid_t tid = journal->j_running_transaction->t_tid; 501 tid_t tid = journal->j_running_transaction->t_tid;
502 502
503 ret = __log_start_commit(journal, tid); 503 ret = __jbd2_log_start_commit(journal, tid);
504 if (ret && ptid) 504 if (ret && ptid)
505 *ptid = tid; 505 *ptid = tid;
506 } else if (journal->j_committing_transaction && ptid) { 506 } else if (journal->j_committing_transaction && ptid) {
@@ -519,7 +519,7 @@ int journal_start_commit(journal_t *journal, tid_t *ptid)
519 * Wait for a specified commit to complete. 519 * Wait for a specified commit to complete.
520 * The caller may not hold the journal lock. 520 * The caller may not hold the journal lock.
521 */ 521 */
522int log_wait_commit(journal_t *journal, tid_t tid) 522int jbd2_log_wait_commit(journal_t *journal, tid_t tid)
523{ 523{
524 int err = 0; 524 int err = 0;
525 525
@@ -555,7 +555,7 @@ int log_wait_commit(journal_t *journal, tid_t tid)
555 * Log buffer allocation routines: 555 * Log buffer allocation routines:
556 */ 556 */
557 557
558int journal_next_log_block(journal_t *journal, unsigned long *retp) 558int jbd2_journal_next_log_block(journal_t *journal, unsigned long *retp)
559{ 559{
560 unsigned long blocknr; 560 unsigned long blocknr;
561 561
@@ -568,7 +568,7 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp)
568 if (journal->j_head == journal->j_last) 568 if (journal->j_head == journal->j_last)
569 journal->j_head = journal->j_first; 569 journal->j_head = journal->j_first;
570 spin_unlock(&journal->j_state_lock); 570 spin_unlock(&journal->j_state_lock);
571 return journal_bmap(journal, blocknr, retp); 571 return jbd2_journal_bmap(journal, blocknr, retp);
572} 572}
573 573
574/* 574/*
@@ -578,7 +578,7 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp)
578 * this is a no-op. If needed, we can use j_blk_offset - everything is 578 * this is a no-op. If needed, we can use j_blk_offset - everything is
579 * ready. 579 * ready.
580 */ 580 */
581int journal_bmap(journal_t *journal, unsigned long blocknr, 581int jbd2_journal_bmap(journal_t *journal, unsigned long blocknr,
582 unsigned long *retp) 582 unsigned long *retp)
583{ 583{
584 int err = 0; 584 int err = 0;
@@ -610,18 +610,18 @@ int journal_bmap(journal_t *journal, unsigned long blocknr,
610 * the journal without copying their contents, but for journal 610 * the journal without copying their contents, but for journal
611 * descriptor blocks we do need to generate bona fide buffers. 611 * descriptor blocks we do need to generate bona fide buffers.
612 * 612 *
613 * After the caller of journal_get_descriptor_buffer() has finished modifying 613 * After the caller of jbd2_journal_get_descriptor_buffer() has finished modifying
614 * the buffer's contents they really should run flush_dcache_page(bh->b_page). 614 * the buffer's contents they really should run flush_dcache_page(bh->b_page).
615 * But we don't bother doing that, so there will be coherency problems with 615 * But we don't bother doing that, so there will be coherency problems with
616 * mmaps of blockdevs which hold live JBD-controlled filesystems. 616 * mmaps of blockdevs which hold live JBD-controlled filesystems.
617 */ 617 */
618struct journal_head *journal_get_descriptor_buffer(journal_t *journal) 618struct journal_head *jbd2_journal_get_descriptor_buffer(journal_t *journal)
619{ 619{
620 struct buffer_head *bh; 620 struct buffer_head *bh;
621 unsigned long blocknr; 621 unsigned long blocknr;
622 int err; 622 int err;
623 623
624 err = journal_next_log_block(journal, &blocknr); 624 err = jbd2_journal_next_log_block(journal, &blocknr);
625 625
626 if (err) 626 if (err)
627 return NULL; 627 return NULL;
@@ -632,7 +632,7 @@ struct journal_head *journal_get_descriptor_buffer(journal_t *journal)
632 set_buffer_uptodate(bh); 632 set_buffer_uptodate(bh);
633 unlock_buffer(bh); 633 unlock_buffer(bh);
634 BUFFER_TRACE(bh, "return this buffer"); 634 BUFFER_TRACE(bh, "return this buffer");
635 return journal_add_journal_head(bh); 635 return jbd2_journal_add_journal_head(bh);
636} 636}
637 637
638/* 638/*
@@ -669,10 +669,10 @@ static journal_t * journal_init_common (void)
669 journal->j_commit_interval = (HZ * JBD_DEFAULT_MAX_COMMIT_AGE); 669 journal->j_commit_interval = (HZ * JBD_DEFAULT_MAX_COMMIT_AGE);
670 670
671 /* The journal is marked for error until we succeed with recovery! */ 671 /* The journal is marked for error until we succeed with recovery! */
672 journal->j_flags = JFS_ABORT; 672 journal->j_flags = JBD2_ABORT;
673 673
674 /* Set up a default-sized revoke table for the new mount. */ 674 /* Set up a default-sized revoke table for the new mount. */
675 err = journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH); 675 err = jbd2_journal_init_revoke(journal, JOURNAL_REVOKE_DEFAULT_HASH);
676 if (err) { 676 if (err) {
677 kfree(journal); 677 kfree(journal);
678 goto fail; 678 goto fail;
@@ -682,7 +682,7 @@ fail:
682 return NULL; 682 return NULL;
683} 683}
684 684
685/* journal_init_dev and journal_init_inode: 685/* jbd2_journal_init_dev and jbd2_journal_init_inode:
686 * 686 *
687 * Create a journal structure assigned some fixed set of disk blocks to 687 * Create a journal structure assigned some fixed set of disk blocks to
688 * the journal. We don't actually touch those disk blocks yet, but we 688 * the journal. We don't actually touch those disk blocks yet, but we
@@ -692,7 +692,7 @@ fail:
692 */ 692 */
693 693
694/** 694/**
695 * journal_t * journal_init_dev() - creates an initialises a journal structure 695 * journal_t * jbd2_journal_init_dev() - creates an initialises a journal structure
696 * @bdev: Block device on which to create the journal 696 * @bdev: Block device on which to create the journal
697 * @fs_dev: Device which hold journalled filesystem for this journal. 697 * @fs_dev: Device which hold journalled filesystem for this journal.
698 * @start: Block nr Start of journal. 698 * @start: Block nr Start of journal.
@@ -700,11 +700,11 @@ fail:
700 * @blocksize: blocksize of journalling device 700 * @blocksize: blocksize of journalling device
701 * @returns: a newly created journal_t * 701 * @returns: a newly created journal_t *
702 * 702 *
703 * journal_init_dev creates a journal which maps a fixed contiguous 703 * jbd2_journal_init_dev creates a journal which maps a fixed contiguous
704 * range of blocks on an arbitrary block device. 704 * range of blocks on an arbitrary block device.
705 * 705 *
706 */ 706 */
707journal_t * journal_init_dev(struct block_device *bdev, 707journal_t * jbd2_journal_init_dev(struct block_device *bdev,
708 struct block_device *fs_dev, 708 struct block_device *fs_dev,
709 int start, int len, int blocksize) 709 int start, int len, int blocksize)
710{ 710{
@@ -740,14 +740,14 @@ journal_t * journal_init_dev(struct block_device *bdev,
740} 740}
741 741
742/** 742/**
743 * journal_t * journal_init_inode () - creates a journal which maps to a inode. 743 * journal_t * jbd2_journal_init_inode () - creates a journal which maps to a inode.
744 * @inode: An inode to create the journal in 744 * @inode: An inode to create the journal in
745 * 745 *
746 * journal_init_inode creates a journal which maps an on-disk inode as 746 * jbd2_journal_init_inode creates a journal which maps an on-disk inode as
747 * the journal. The inode must exist already, must support bmap() and 747 * the journal. The inode must exist already, must support bmap() and
748 * must have all data blocks preallocated. 748 * must have all data blocks preallocated.
749 */ 749 */
750journal_t * journal_init_inode (struct inode *inode) 750journal_t * jbd2_journal_init_inode (struct inode *inode)
751{ 751{
752 struct buffer_head *bh; 752 struct buffer_head *bh;
753 journal_t *journal = journal_init_common(); 753 journal_t *journal = journal_init_common();
@@ -780,7 +780,7 @@ journal_t * journal_init_inode (struct inode *inode)
780 return NULL; 780 return NULL;
781 } 781 }
782 782
783 err = journal_bmap(journal, 0, &blocknr); 783 err = jbd2_journal_bmap(journal, 0, &blocknr);
784 /* If that failed, give up */ 784 /* If that failed, give up */
785 if (err) { 785 if (err) {
786 printk(KERN_ERR "%s: Cannnot locate journal superblock\n", 786 printk(KERN_ERR "%s: Cannnot locate journal superblock\n",
@@ -838,27 +838,27 @@ static int journal_reset(journal_t *journal)
838 journal->j_max_transaction_buffers = journal->j_maxlen / 4; 838 journal->j_max_transaction_buffers = journal->j_maxlen / 4;
839 839
840 /* Add the dynamic fields and write it to disk. */ 840 /* Add the dynamic fields and write it to disk. */
841 journal_update_superblock(journal, 1); 841 jbd2_journal_update_superblock(journal, 1);
842 journal_start_thread(journal); 842 jbd2_journal_start_thread(journal);
843 return 0; 843 return 0;
844} 844}
845 845
846/** 846/**
847 * int journal_create() - Initialise the new journal file 847 * int jbd2_journal_create() - Initialise the new journal file
848 * @journal: Journal to create. This structure must have been initialised 848 * @journal: Journal to create. This structure must have been initialised
849 * 849 *
850 * Given a journal_t structure which tells us which disk blocks we can 850 * Given a journal_t structure which tells us which disk blocks we can
851 * use, create a new journal superblock and initialise all of the 851 * use, create a new journal superblock and initialise all of the
852 * journal fields from scratch. 852 * journal fields from scratch.
853 **/ 853 **/
854int journal_create(journal_t *journal) 854int jbd2_journal_create(journal_t *journal)
855{ 855{
856 unsigned long blocknr; 856 unsigned long blocknr;
857 struct buffer_head *bh; 857 struct buffer_head *bh;
858 journal_superblock_t *sb; 858 journal_superblock_t *sb;
859 int i, err; 859 int i, err;
860 860
861 if (journal->j_maxlen < JFS_MIN_JOURNAL_BLOCKS) { 861 if (journal->j_maxlen < JBD2_MIN_JOURNAL_BLOCKS) {
862 printk (KERN_ERR "Journal length (%d blocks) too short.\n", 862 printk (KERN_ERR "Journal length (%d blocks) too short.\n",
863 journal->j_maxlen); 863 journal->j_maxlen);
864 journal_fail_superblock(journal); 864 journal_fail_superblock(journal);
@@ -876,10 +876,10 @@ int journal_create(journal_t *journal)
876 } 876 }
877 877
878 /* Zero out the entire journal on disk. We cannot afford to 878 /* Zero out the entire journal on disk. We cannot afford to
879 have any blocks on disk beginning with JFS_MAGIC_NUMBER. */ 879 have any blocks on disk beginning with JBD2_MAGIC_NUMBER. */
880 jbd_debug(1, "JBD: Zeroing out journal blocks...\n"); 880 jbd_debug(1, "JBD: Zeroing out journal blocks...\n");
881 for (i = 0; i < journal->j_maxlen; i++) { 881 for (i = 0; i < journal->j_maxlen; i++) {
882 err = journal_bmap(journal, i, &blocknr); 882 err = jbd2_journal_bmap(journal, i, &blocknr);
883 if (err) 883 if (err)
884 return err; 884 return err;
885 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize); 885 bh = __getblk(journal->j_dev, blocknr, journal->j_blocksize);
@@ -899,8 +899,8 @@ int journal_create(journal_t *journal)
899 /* OK, fill in the initial static fields in the new superblock */ 899 /* OK, fill in the initial static fields in the new superblock */
900 sb = journal->j_superblock; 900 sb = journal->j_superblock;
901 901
902 sb->s_header.h_magic = cpu_to_be32(JFS_MAGIC_NUMBER); 902 sb->s_header.h_magic = cpu_to_be32(JBD2_MAGIC_NUMBER);
903 sb->s_header.h_blocktype = cpu_to_be32(JFS_SUPERBLOCK_V2); 903 sb->s_header.h_blocktype = cpu_to_be32(JBD2_SUPERBLOCK_V2);
904 904
905 sb->s_blocksize = cpu_to_be32(journal->j_blocksize); 905 sb->s_blocksize = cpu_to_be32(journal->j_blocksize);
906 sb->s_maxlen = cpu_to_be32(journal->j_maxlen); 906 sb->s_maxlen = cpu_to_be32(journal->j_maxlen);
@@ -908,21 +908,21 @@ int journal_create(journal_t *journal)
908 908
909 journal->j_transaction_sequence = 1; 909 journal->j_transaction_sequence = 1;
910 910
911 journal->j_flags &= ~JFS_ABORT; 911 journal->j_flags &= ~JBD2_ABORT;
912 journal->j_format_version = 2; 912 journal->j_format_version = 2;
913 913
914 return journal_reset(journal); 914 return journal_reset(journal);
915} 915}
916 916
917/** 917/**
918 * void journal_update_superblock() - Update journal sb on disk. 918 * void jbd2_journal_update_superblock() - Update journal sb on disk.
919 * @journal: The journal to update. 919 * @journal: The journal to update.
920 * @wait: Set to '0' if you don't want to wait for IO completion. 920 * @wait: Set to '0' if you don't want to wait for IO completion.
921 * 921 *
922 * Update a journal's dynamic superblock fields and write it to disk, 922 * Update a journal's dynamic superblock fields and write it to disk,
923 * optionally waiting for the IO to complete. 923 * optionally waiting for the IO to complete.
924 */ 924 */
925void journal_update_superblock(journal_t *journal, int wait) 925void jbd2_journal_update_superblock(journal_t *journal, int wait)
926{ 926{
927 journal_superblock_t *sb = journal->j_superblock; 927 journal_superblock_t *sb = journal->j_superblock;
928 struct buffer_head *bh = journal->j_sb_buffer; 928 struct buffer_head *bh = journal->j_sb_buffer;
@@ -931,7 +931,7 @@ void journal_update_superblock(journal_t *journal, int wait)
931 * As a special case, if the on-disk copy is already marked as needing 931 * As a special case, if the on-disk copy is already marked as needing
932 * no recovery (s_start == 0) and there are no outstanding transactions 932 * no recovery (s_start == 0) and there are no outstanding transactions
933 * in the filesystem, then we can safely defer the superblock update 933 * in the filesystem, then we can safely defer the superblock update
934 * until the next commit by setting JFS_FLUSHED. This avoids 934 * until the next commit by setting JBD2_FLUSHED. This avoids
935 * attempting a write to a potential-readonly device. 935 * attempting a write to a potential-readonly device.
936 */ 936 */
937 if (sb->s_start == 0 && journal->j_tail_sequence == 937 if (sb->s_start == 0 && journal->j_tail_sequence ==
@@ -966,9 +966,9 @@ out:
966 966
967 spin_lock(&journal->j_state_lock); 967 spin_lock(&journal->j_state_lock);
968 if (sb->s_start) 968 if (sb->s_start)
969 journal->j_flags &= ~JFS_FLUSHED; 969 journal->j_flags &= ~JBD2_FLUSHED;
970 else 970 else
971 journal->j_flags |= JFS_FLUSHED; 971 journal->j_flags |= JBD2_FLUSHED;
972 spin_unlock(&journal->j_state_lock); 972 spin_unlock(&journal->j_state_lock);
973} 973}
974 974
@@ -1000,17 +1000,17 @@ static int journal_get_superblock(journal_t *journal)
1000 1000
1001 err = -EINVAL; 1001 err = -EINVAL;
1002 1002
1003 if (sb->s_header.h_magic != cpu_to_be32(JFS_MAGIC_NUMBER) || 1003 if (sb->s_header.h_magic != cpu_to_be32(JBD2_MAGIC_NUMBER) ||
1004 sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) { 1004 sb->s_blocksize != cpu_to_be32(journal->j_blocksize)) {
1005 printk(KERN_WARNING "JBD: no valid journal superblock found\n"); 1005 printk(KERN_WARNING "JBD: no valid journal superblock found\n");
1006 goto out; 1006 goto out;
1007 } 1007 }
1008 1008
1009 switch(be32_to_cpu(sb->s_header.h_blocktype)) { 1009 switch(be32_to_cpu(sb->s_header.h_blocktype)) {
1010 case JFS_SUPERBLOCK_V1: 1010 case JBD2_SUPERBLOCK_V1:
1011 journal->j_format_version = 1; 1011 journal->j_format_version = 1;
1012 break; 1012 break;
1013 case JFS_SUPERBLOCK_V2: 1013 case JBD2_SUPERBLOCK_V2:
1014 journal->j_format_version = 2; 1014 journal->j_format_version = 2;
1015 break; 1015 break;
1016 default: 1016 default:
@@ -1059,14 +1059,14 @@ static int load_superblock(journal_t *journal)
1059 1059
1060 1060
1061/** 1061/**
1062 * int journal_load() - Read journal from disk. 1062 * int jbd2_journal_load() - Read journal from disk.
1063 * @journal: Journal to act on. 1063 * @journal: Journal to act on.
1064 * 1064 *
1065 * Given a journal_t structure which tells us which disk blocks contain 1065 * Given a journal_t structure which tells us which disk blocks contain
1066 * a journal, read the journal from disk to initialise the in-memory 1066 * a journal, read the journal from disk to initialise the in-memory
1067 * structures. 1067 * structures.
1068 */ 1068 */
1069int journal_load(journal_t *journal) 1069int jbd2_journal_load(journal_t *journal)
1070{ 1070{
1071 int err; 1071 int err;
1072 journal_superblock_t *sb; 1072 journal_superblock_t *sb;
@@ -1081,9 +1081,9 @@ int journal_load(journal_t *journal)
1081 1081
1082 if (journal->j_format_version >= 2) { 1082 if (journal->j_format_version >= 2) {
1083 if ((sb->s_feature_ro_compat & 1083 if ((sb->s_feature_ro_compat &
1084 ~cpu_to_be32(JFS_KNOWN_ROCOMPAT_FEATURES)) || 1084 ~cpu_to_be32(JBD2_KNOWN_ROCOMPAT_FEATURES)) ||
1085 (sb->s_feature_incompat & 1085 (sb->s_feature_incompat &
1086 ~cpu_to_be32(JFS_KNOWN_INCOMPAT_FEATURES))) { 1086 ~cpu_to_be32(JBD2_KNOWN_INCOMPAT_FEATURES))) {
1087 printk (KERN_WARNING 1087 printk (KERN_WARNING
1088 "JBD: Unrecognised features on journal\n"); 1088 "JBD: Unrecognised features on journal\n");
1089 return -EINVAL; 1089 return -EINVAL;
@@ -1093,13 +1093,13 @@ int journal_load(journal_t *journal)
1093 /* 1093 /*
1094 * Create a slab for this blocksize 1094 * Create a slab for this blocksize
1095 */ 1095 */
1096 err = journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize)); 1096 err = jbd2_journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize));
1097 if (err) 1097 if (err)
1098 return err; 1098 return err;
1099 1099
1100 /* Let the recovery code check whether it needs to recover any 1100 /* Let the recovery code check whether it needs to recover any
1101 * data from the journal. */ 1101 * data from the journal. */
1102 if (journal_recover(journal)) 1102 if (jbd2_journal_recover(journal))
1103 goto recovery_error; 1103 goto recovery_error;
1104 1104
1105 /* OK, we've finished with the dynamic journal bits: 1105 /* OK, we've finished with the dynamic journal bits:
@@ -1108,8 +1108,8 @@ int journal_load(journal_t *journal)
1108 if (journal_reset(journal)) 1108 if (journal_reset(journal))
1109 goto recovery_error; 1109 goto recovery_error;
1110 1110
1111 journal->j_flags &= ~JFS_ABORT; 1111 journal->j_flags &= ~JBD2_ABORT;
1112 journal->j_flags |= JFS_LOADED; 1112 journal->j_flags |= JBD2_LOADED;
1113 return 0; 1113 return 0;
1114 1114
1115recovery_error: 1115recovery_error:
@@ -1118,20 +1118,20 @@ recovery_error:
1118} 1118}
1119 1119
1120/** 1120/**
1121 * void journal_destroy() - Release a journal_t structure. 1121 * void jbd2_journal_destroy() - Release a journal_t structure.
1122 * @journal: Journal to act on. 1122 * @journal: Journal to act on.
1123 * 1123 *
1124 * Release a journal_t structure once it is no longer in use by the 1124 * Release a journal_t structure once it is no longer in use by the
1125 * journaled object. 1125 * journaled object.
1126 */ 1126 */
1127void journal_destroy(journal_t *journal) 1127void jbd2_journal_destroy(journal_t *journal)
1128{ 1128{
1129 /* Wait for the commit thread to wake up and die. */ 1129 /* Wait for the commit thread to wake up and die. */
1130 journal_kill_thread(journal); 1130 journal_kill_thread(journal);
1131 1131
1132 /* Force a final log commit */ 1132 /* Force a final log commit */
1133 if (journal->j_running_transaction) 1133 if (journal->j_running_transaction)
1134 journal_commit_transaction(journal); 1134 jbd2_journal_commit_transaction(journal);
1135 1135
1136 /* Force any old transactions to disk */ 1136 /* Force any old transactions to disk */
1137 1137
@@ -1139,7 +1139,7 @@ void journal_destroy(journal_t *journal)
1139 spin_lock(&journal->j_list_lock); 1139 spin_lock(&journal->j_list_lock);
1140 while (journal->j_checkpoint_transactions != NULL) { 1140 while (journal->j_checkpoint_transactions != NULL) {
1141 spin_unlock(&journal->j_list_lock); 1141 spin_unlock(&journal->j_list_lock);
1142 log_do_checkpoint(journal); 1142 jbd2_log_do_checkpoint(journal);
1143 spin_lock(&journal->j_list_lock); 1143 spin_lock(&journal->j_list_lock);
1144 } 1144 }
1145 1145
@@ -1152,21 +1152,21 @@ void journal_destroy(journal_t *journal)
1152 journal->j_tail = 0; 1152 journal->j_tail = 0;
1153 journal->j_tail_sequence = ++journal->j_transaction_sequence; 1153 journal->j_tail_sequence = ++journal->j_transaction_sequence;
1154 if (journal->j_sb_buffer) { 1154 if (journal->j_sb_buffer) {
1155 journal_update_superblock(journal, 1); 1155 jbd2_journal_update_superblock(journal, 1);
1156 brelse(journal->j_sb_buffer); 1156 brelse(journal->j_sb_buffer);
1157 } 1157 }
1158 1158
1159 if (journal->j_inode) 1159 if (journal->j_inode)
1160 iput(journal->j_inode); 1160 iput(journal->j_inode);
1161 if (journal->j_revoke) 1161 if (journal->j_revoke)
1162 journal_destroy_revoke(journal); 1162 jbd2_journal_destroy_revoke(journal);
1163 kfree(journal->j_wbuf); 1163 kfree(journal->j_wbuf);
1164 kfree(journal); 1164 kfree(journal);
1165} 1165}
1166 1166
1167 1167
1168/** 1168/**
1169 *int journal_check_used_features () - Check if features specified are used. 1169 *int jbd2_journal_check_used_features () - Check if features specified are used.
1170 * @journal: Journal to check. 1170 * @journal: Journal to check.
1171 * @compat: bitmask of compatible features 1171 * @compat: bitmask of compatible features
1172 * @ro: bitmask of features that force read-only mount 1172 * @ro: bitmask of features that force read-only mount
@@ -1176,7 +1176,7 @@ void journal_destroy(journal_t *journal)
1176 * features. Return true (non-zero) if it does. 1176 * features. Return true (non-zero) if it does.
1177 **/ 1177 **/
1178 1178
1179int journal_check_used_features (journal_t *journal, unsigned long compat, 1179int jbd2_journal_check_used_features (journal_t *journal, unsigned long compat,
1180 unsigned long ro, unsigned long incompat) 1180 unsigned long ro, unsigned long incompat)
1181{ 1181{
1182 journal_superblock_t *sb; 1182 journal_superblock_t *sb;
@@ -1197,7 +1197,7 @@ int journal_check_used_features (journal_t *journal, unsigned long compat,
1197} 1197}
1198 1198
1199/** 1199/**
1200 * int journal_check_available_features() - Check feature set in journalling layer 1200 * int jbd2_journal_check_available_features() - Check feature set in journalling layer
1201 * @journal: Journal to check. 1201 * @journal: Journal to check.
1202 * @compat: bitmask of compatible features 1202 * @compat: bitmask of compatible features
1203 * @ro: bitmask of features that force read-only mount 1203 * @ro: bitmask of features that force read-only mount
@@ -1207,7 +1207,7 @@ int journal_check_used_features (journal_t *journal, unsigned long compat,
1207 * all of a given set of features on this journal. Return true 1207 * all of a given set of features on this journal. Return true
1208 * (non-zero) if it can. */ 1208 * (non-zero) if it can. */
1209 1209
1210int journal_check_available_features (journal_t *journal, unsigned long compat, 1210int jbd2_journal_check_available_features (journal_t *journal, unsigned long compat,
1211 unsigned long ro, unsigned long incompat) 1211 unsigned long ro, unsigned long incompat)
1212{ 1212{
1213 journal_superblock_t *sb; 1213 journal_superblock_t *sb;
@@ -1224,16 +1224,16 @@ int journal_check_available_features (journal_t *journal, unsigned long compat,
1224 if (journal->j_format_version != 2) 1224 if (journal->j_format_version != 2)
1225 return 0; 1225 return 0;
1226 1226
1227 if ((compat & JFS_KNOWN_COMPAT_FEATURES) == compat && 1227 if ((compat & JBD2_KNOWN_COMPAT_FEATURES) == compat &&
1228 (ro & JFS_KNOWN_ROCOMPAT_FEATURES) == ro && 1228 (ro & JBD2_KNOWN_ROCOMPAT_FEATURES) == ro &&
1229 (incompat & JFS_KNOWN_INCOMPAT_FEATURES) == incompat) 1229 (incompat & JBD2_KNOWN_INCOMPAT_FEATURES) == incompat)
1230 return 1; 1230 return 1;
1231 1231
1232 return 0; 1232 return 0;
1233} 1233}
1234 1234
1235/** 1235/**
1236 * int journal_set_features () - Mark a given journal feature in the superblock 1236 * int jbd2_journal_set_features () - Mark a given journal feature in the superblock
1237 * @journal: Journal to act on. 1237 * @journal: Journal to act on.
1238 * @compat: bitmask of compatible features 1238 * @compat: bitmask of compatible features
1239 * @ro: bitmask of features that force read-only mount 1239 * @ro: bitmask of features that force read-only mount
@@ -1244,15 +1244,15 @@ int journal_check_available_features (journal_t *journal, unsigned long compat,
1244 * 1244 *
1245 */ 1245 */
1246 1246
1247int journal_set_features (journal_t *journal, unsigned long compat, 1247int jbd2_journal_set_features (journal_t *journal, unsigned long compat,
1248 unsigned long ro, unsigned long incompat) 1248 unsigned long ro, unsigned long incompat)
1249{ 1249{
1250 journal_superblock_t *sb; 1250 journal_superblock_t *sb;
1251 1251
1252 if (journal_check_used_features(journal, compat, ro, incompat)) 1252 if (jbd2_journal_check_used_features(journal, compat, ro, incompat))
1253 return 1; 1253 return 1;
1254 1254
1255 if (!journal_check_available_features(journal, compat, ro, incompat)) 1255 if (!jbd2_journal_check_available_features(journal, compat, ro, incompat))
1256 return 0; 1256 return 0;
1257 1257
1258 jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n", 1258 jbd_debug(1, "Setting new features 0x%lx/0x%lx/0x%lx\n",
@@ -1269,13 +1269,13 @@ int journal_set_features (journal_t *journal, unsigned long compat,
1269 1269
1270 1270
1271/** 1271/**
1272 * int journal_update_format () - Update on-disk journal structure. 1272 * int jbd2_journal_update_format () - Update on-disk journal structure.
1273 * @journal: Journal to act on. 1273 * @journal: Journal to act on.
1274 * 1274 *
1275 * Given an initialised but unloaded journal struct, poke about in the 1275 * Given an initialised but unloaded journal struct, poke about in the
1276 * on-disk structure to update it to the most recent supported version. 1276 * on-disk structure to update it to the most recent supported version.
1277 */ 1277 */
1278int journal_update_format (journal_t *journal) 1278int jbd2_journal_update_format (journal_t *journal)
1279{ 1279{
1280 journal_superblock_t *sb; 1280 journal_superblock_t *sb;
1281 int err; 1281 int err;
@@ -1287,9 +1287,9 @@ int journal_update_format (journal_t *journal)
1287 sb = journal->j_superblock; 1287 sb = journal->j_superblock;
1288 1288
1289 switch (be32_to_cpu(sb->s_header.h_blocktype)) { 1289 switch (be32_to_cpu(sb->s_header.h_blocktype)) {
1290 case JFS_SUPERBLOCK_V2: 1290 case JBD2_SUPERBLOCK_V2:
1291 return 0; 1291 return 0;
1292 case JFS_SUPERBLOCK_V1: 1292 case JBD2_SUPERBLOCK_V1:
1293 return journal_convert_superblock_v1(journal, sb); 1293 return journal_convert_superblock_v1(journal, sb);
1294 default: 1294 default:
1295 break; 1295 break;
@@ -1312,7 +1312,7 @@ static int journal_convert_superblock_v1(journal_t *journal,
1312 memset(&sb->s_feature_compat, 0, blocksize-offset); 1312 memset(&sb->s_feature_compat, 0, blocksize-offset);
1313 1313
1314 sb->s_nr_users = cpu_to_be32(1); 1314 sb->s_nr_users = cpu_to_be32(1);
1315 sb->s_header.h_blocktype = cpu_to_be32(JFS_SUPERBLOCK_V2); 1315 sb->s_header.h_blocktype = cpu_to_be32(JBD2_SUPERBLOCK_V2);
1316 journal->j_format_version = 2; 1316 journal->j_format_version = 2;
1317 1317
1318 bh = journal->j_sb_buffer; 1318 bh = journal->j_sb_buffer;
@@ -1324,7 +1324,7 @@ static int journal_convert_superblock_v1(journal_t *journal,
1324 1324
1325 1325
1326/** 1326/**
1327 * int journal_flush () - Flush journal 1327 * int jbd2_journal_flush () - Flush journal
1328 * @journal: Journal to act on. 1328 * @journal: Journal to act on.
1329 * 1329 *
1330 * Flush all data for a given journal to disk and empty the journal. 1330 * Flush all data for a given journal to disk and empty the journal.
@@ -1332,7 +1332,7 @@ static int journal_convert_superblock_v1(journal_t *journal,
1332 * recovery does not need to happen on remount. 1332 * recovery does not need to happen on remount.
1333 */ 1333 */
1334 1334
1335int journal_flush(journal_t *journal) 1335int jbd2_journal_flush(journal_t *journal)
1336{ 1336{
1337 int err = 0; 1337 int err = 0;
1338 transaction_t *transaction = NULL; 1338 transaction_t *transaction = NULL;
@@ -1343,7 +1343,7 @@ int journal_flush(journal_t *journal)
1343 /* Force everything buffered to the log... */ 1343 /* Force everything buffered to the log... */
1344 if (journal->j_running_transaction) { 1344 if (journal->j_running_transaction) {
1345 transaction = journal->j_running_transaction; 1345 transaction = journal->j_running_transaction;
1346 __log_start_commit(journal, transaction->t_tid); 1346 __jbd2_log_start_commit(journal, transaction->t_tid);
1347 } else if (journal->j_committing_transaction) 1347 } else if (journal->j_committing_transaction)
1348 transaction = journal->j_committing_transaction; 1348 transaction = journal->j_committing_transaction;
1349 1349
@@ -1352,7 +1352,7 @@ int journal_flush(journal_t *journal)
1352 tid_t tid = transaction->t_tid; 1352 tid_t tid = transaction->t_tid;
1353 1353
1354 spin_unlock(&journal->j_state_lock); 1354 spin_unlock(&journal->j_state_lock);
1355 log_wait_commit(journal, tid); 1355 jbd2_log_wait_commit(journal, tid);
1356 } else { 1356 } else {
1357 spin_unlock(&journal->j_state_lock); 1357 spin_unlock(&journal->j_state_lock);
1358 } 1358 }
@@ -1361,11 +1361,11 @@ int journal_flush(journal_t *journal)
1361 spin_lock(&journal->j_list_lock); 1361 spin_lock(&journal->j_list_lock);
1362 while (!err && journal->j_checkpoint_transactions != NULL) { 1362 while (!err && journal->j_checkpoint_transactions != NULL) {
1363 spin_unlock(&journal->j_list_lock); 1363 spin_unlock(&journal->j_list_lock);
1364 err = log_do_checkpoint(journal); 1364 err = jbd2_log_do_checkpoint(journal);
1365 spin_lock(&journal->j_list_lock); 1365 spin_lock(&journal->j_list_lock);
1366 } 1366 }
1367 spin_unlock(&journal->j_list_lock); 1367 spin_unlock(&journal->j_list_lock);
1368 cleanup_journal_tail(journal); 1368 jbd2_cleanup_journal_tail(journal);
1369 1369
1370 /* Finally, mark the journal as really needing no recovery. 1370 /* Finally, mark the journal as really needing no recovery.
1371 * This sets s_start==0 in the underlying superblock, which is 1371 * This sets s_start==0 in the underlying superblock, which is
@@ -1376,7 +1376,7 @@ int journal_flush(journal_t *journal)
1376 old_tail = journal->j_tail; 1376 old_tail = journal->j_tail;
1377 journal->j_tail = 0; 1377 journal->j_tail = 0;
1378 spin_unlock(&journal->j_state_lock); 1378 spin_unlock(&journal->j_state_lock);
1379 journal_update_superblock(journal, 1); 1379 jbd2_journal_update_superblock(journal, 1);
1380 spin_lock(&journal->j_state_lock); 1380 spin_lock(&journal->j_state_lock);
1381 journal->j_tail = old_tail; 1381 journal->j_tail = old_tail;
1382 1382
@@ -1390,24 +1390,24 @@ int journal_flush(journal_t *journal)
1390} 1390}
1391 1391
1392/** 1392/**
1393 * int journal_wipe() - Wipe journal contents 1393 * int jbd2_journal_wipe() - Wipe journal contents
1394 * @journal: Journal to act on. 1394 * @journal: Journal to act on.
1395 * @write: flag (see below) 1395 * @write: flag (see below)
1396 * 1396 *
1397 * Wipe out all of the contents of a journal, safely. This will produce 1397 * Wipe out all of the contents of a journal, safely. This will produce
1398 * a warning if the journal contains any valid recovery information. 1398 * a warning if the journal contains any valid recovery information.
1399 * Must be called between journal_init_*() and journal_load(). 1399 * Must be called between journal_init_*() and jbd2_journal_load().
1400 * 1400 *
1401 * If 'write' is non-zero, then we wipe out the journal on disk; otherwise 1401 * If 'write' is non-zero, then we wipe out the journal on disk; otherwise
1402 * we merely suppress recovery. 1402 * we merely suppress recovery.
1403 */ 1403 */
1404 1404
1405int journal_wipe(journal_t *journal, int write) 1405int jbd2_journal_wipe(journal_t *journal, int write)
1406{ 1406{
1407 journal_superblock_t *sb; 1407 journal_superblock_t *sb;
1408 int err = 0; 1408 int err = 0;
1409 1409
1410 J_ASSERT (!(journal->j_flags & JFS_LOADED)); 1410 J_ASSERT (!(journal->j_flags & JBD2_LOADED));
1411 1411
1412 err = load_superblock(journal); 1412 err = load_superblock(journal);
1413 if (err) 1413 if (err)
@@ -1421,9 +1421,9 @@ int journal_wipe(journal_t *journal, int write)
1421 printk (KERN_WARNING "JBD: %s recovery information on journal\n", 1421 printk (KERN_WARNING "JBD: %s recovery information on journal\n",
1422 write ? "Clearing" : "Ignoring"); 1422 write ? "Clearing" : "Ignoring");
1423 1423
1424 err = journal_skip_recovery(journal); 1424 err = jbd2_journal_skip_recovery(journal);
1425 if (write) 1425 if (write)
1426 journal_update_superblock(journal, 1); 1426 jbd2_journal_update_superblock(journal, 1);
1427 1427
1428 no_recovery: 1428 no_recovery:
1429 return err; 1429 return err;
@@ -1459,22 +1459,22 @@ static const char *journal_dev_name(journal_t *journal, char *buffer)
1459 * Aborts hard --- we mark the abort as occurred, but do _nothing_ else, 1459 * Aborts hard --- we mark the abort as occurred, but do _nothing_ else,
1460 * and don't attempt to make any other journal updates. 1460 * and don't attempt to make any other journal updates.
1461 */ 1461 */
1462void __journal_abort_hard(journal_t *journal) 1462void __jbd2_journal_abort_hard(journal_t *journal)
1463{ 1463{
1464 transaction_t *transaction; 1464 transaction_t *transaction;
1465 char b[BDEVNAME_SIZE]; 1465 char b[BDEVNAME_SIZE];
1466 1466
1467 if (journal->j_flags & JFS_ABORT) 1467 if (journal->j_flags & JBD2_ABORT)
1468 return; 1468 return;
1469 1469
1470 printk(KERN_ERR "Aborting journal on device %s.\n", 1470 printk(KERN_ERR "Aborting journal on device %s.\n",
1471 journal_dev_name(journal, b)); 1471 journal_dev_name(journal, b));
1472 1472
1473 spin_lock(&journal->j_state_lock); 1473 spin_lock(&journal->j_state_lock);
1474 journal->j_flags |= JFS_ABORT; 1474 journal->j_flags |= JBD2_ABORT;
1475 transaction = journal->j_running_transaction; 1475 transaction = journal->j_running_transaction;
1476 if (transaction) 1476 if (transaction)
1477 __log_start_commit(journal, transaction->t_tid); 1477 __jbd2_log_start_commit(journal, transaction->t_tid);
1478 spin_unlock(&journal->j_state_lock); 1478 spin_unlock(&journal->j_state_lock);
1479} 1479}
1480 1480
@@ -1482,20 +1482,20 @@ void __journal_abort_hard(journal_t *journal)
1482 * but don't do any other IO. */ 1482 * but don't do any other IO. */
1483static void __journal_abort_soft (journal_t *journal, int errno) 1483static void __journal_abort_soft (journal_t *journal, int errno)
1484{ 1484{
1485 if (journal->j_flags & JFS_ABORT) 1485 if (journal->j_flags & JBD2_ABORT)
1486 return; 1486 return;
1487 1487
1488 if (!journal->j_errno) 1488 if (!journal->j_errno)
1489 journal->j_errno = errno; 1489 journal->j_errno = errno;
1490 1490
1491 __journal_abort_hard(journal); 1491 __jbd2_journal_abort_hard(journal);
1492 1492
1493 if (errno) 1493 if (errno)
1494 journal_update_superblock(journal, 1); 1494 jbd2_journal_update_superblock(journal, 1);
1495} 1495}
1496 1496
1497/** 1497/**
1498 * void journal_abort () - Shutdown the journal immediately. 1498 * void jbd2_journal_abort () - Shutdown the journal immediately.
1499 * @journal: the journal to shutdown. 1499 * @journal: the journal to shutdown.
1500 * @errno: an error number to record in the journal indicating 1500 * @errno: an error number to record in the journal indicating
1501 * the reason for the shutdown. 1501 * the reason for the shutdown.
@@ -1504,7 +1504,7 @@ static void __journal_abort_soft (journal_t *journal, int errno)
1504 * journal (not of a single transaction). This operation cannot be 1504 * journal (not of a single transaction). This operation cannot be
1505 * undone without closing and reopening the journal. 1505 * undone without closing and reopening the journal.
1506 * 1506 *
1507 * The journal_abort function is intended to support higher level error 1507 * The jbd2_journal_abort function is intended to support higher level error
1508 * recovery mechanisms such as the ext2/ext3 remount-readonly error 1508 * recovery mechanisms such as the ext2/ext3 remount-readonly error
1509 * mode. 1509 * mode.
1510 * 1510 *
@@ -1520,13 +1520,13 @@ static void __journal_abort_soft (journal_t *journal, int errno)
1520 * 1520 *
1521 * Any attempt to get a new transaction handle on a journal which is in 1521 * Any attempt to get a new transaction handle on a journal which is in
1522 * ABORT state will just result in an -EROFS error return. A 1522 * ABORT state will just result in an -EROFS error return. A
1523 * journal_stop on an existing handle will return -EIO if we have 1523 * jbd2_journal_stop on an existing handle will return -EIO if we have
1524 * entered abort state during the update. 1524 * entered abort state during the update.
1525 * 1525 *
1526 * Recursive transactions are not disturbed by journal abort until the 1526 * Recursive transactions are not disturbed by journal abort until the
1527 * final journal_stop, which will receive the -EIO error. 1527 * final jbd2_journal_stop, which will receive the -EIO error.
1528 * 1528 *
1529 * Finally, the journal_abort call allows the caller to supply an errno 1529 * Finally, the jbd2_journal_abort call allows the caller to supply an errno
1530 * which will be recorded (if possible) in the journal superblock. This 1530 * which will be recorded (if possible) in the journal superblock. This
1531 * allows a client to record failure conditions in the middle of a 1531 * allows a client to record failure conditions in the middle of a
1532 * transaction without having to complete the transaction to record the 1532 * transaction without having to complete the transaction to record the
@@ -1540,28 +1540,28 @@ static void __journal_abort_soft (journal_t *journal, int errno)
1540 * 1540 *
1541 */ 1541 */
1542 1542
1543void journal_abort(journal_t *journal, int errno) 1543void jbd2_journal_abort(journal_t *journal, int errno)
1544{ 1544{
1545 __journal_abort_soft(journal, errno); 1545 __journal_abort_soft(journal, errno);
1546} 1546}
1547 1547
1548/** 1548/**
1549 * int journal_errno () - returns the journal's error state. 1549 * int jbd2_journal_errno () - returns the journal's error state.
1550 * @journal: journal to examine. 1550 * @journal: journal to examine.
1551 * 1551 *
1552 * This is the errno numbet set with journal_abort(), the last 1552 * This is the errno numbet set with jbd2_journal_abort(), the last
1553 * time the journal was mounted - if the journal was stopped 1553 * time the journal was mounted - if the journal was stopped
1554 * without calling abort this will be 0. 1554 * without calling abort this will be 0.
1555 * 1555 *
1556 * If the journal has been aborted on this mount time -EROFS will 1556 * If the journal has been aborted on this mount time -EROFS will
1557 * be returned. 1557 * be returned.
1558 */ 1558 */
1559int journal_errno(journal_t *journal) 1559int jbd2_journal_errno(journal_t *journal)
1560{ 1560{
1561 int err; 1561 int err;
1562 1562
1563 spin_lock(&journal->j_state_lock); 1563 spin_lock(&journal->j_state_lock);
1564 if (journal->j_flags & JFS_ABORT) 1564 if (journal->j_flags & JBD2_ABORT)
1565 err = -EROFS; 1565 err = -EROFS;
1566 else 1566 else
1567 err = journal->j_errno; 1567 err = journal->j_errno;
@@ -1570,18 +1570,18 @@ int journal_errno(journal_t *journal)
1570} 1570}
1571 1571
1572/** 1572/**
1573 * int journal_clear_err () - clears the journal's error state 1573 * int jbd2_journal_clear_err () - clears the journal's error state
1574 * @journal: journal to act on. 1574 * @journal: journal to act on.
1575 * 1575 *
1576 * An error must be cleared or Acked to take a FS out of readonly 1576 * An error must be cleared or Acked to take a FS out of readonly
1577 * mode. 1577 * mode.
1578 */ 1578 */
1579int journal_clear_err(journal_t *journal) 1579int jbd2_journal_clear_err(journal_t *journal)
1580{ 1580{
1581 int err = 0; 1581 int err = 0;
1582 1582
1583 spin_lock(&journal->j_state_lock); 1583 spin_lock(&journal->j_state_lock);
1584 if (journal->j_flags & JFS_ABORT) 1584 if (journal->j_flags & JBD2_ABORT)
1585 err = -EROFS; 1585 err = -EROFS;
1586 else 1586 else
1587 journal->j_errno = 0; 1587 journal->j_errno = 0;
@@ -1590,21 +1590,21 @@ int journal_clear_err(journal_t *journal)
1590} 1590}
1591 1591
1592/** 1592/**
1593 * void journal_ack_err() - Ack journal err. 1593 * void jbd2_journal_ack_err() - Ack journal err.
1594 * @journal: journal to act on. 1594 * @journal: journal to act on.
1595 * 1595 *
1596 * An error must be cleared or Acked to take a FS out of readonly 1596 * An error must be cleared or Acked to take a FS out of readonly
1597 * mode. 1597 * mode.
1598 */ 1598 */
1599void journal_ack_err(journal_t *journal) 1599void jbd2_journal_ack_err(journal_t *journal)
1600{ 1600{
1601 spin_lock(&journal->j_state_lock); 1601 spin_lock(&journal->j_state_lock);
1602 if (journal->j_errno) 1602 if (journal->j_errno)
1603 journal->j_flags |= JFS_ACK_ERR; 1603 journal->j_flags |= JBD2_ACK_ERR;
1604 spin_unlock(&journal->j_state_lock); 1604 spin_unlock(&journal->j_state_lock);
1605} 1605}
1606 1606
1607int journal_blocks_per_page(struct inode *inode) 1607int jbd2_journal_blocks_per_page(struct inode *inode)
1608{ 1608{
1609 return 1 << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits); 1609 return 1 << (PAGE_CACHE_SHIFT - inode->i_sb->s_blocksize_bits);
1610} 1610}
@@ -1613,7 +1613,7 @@ int journal_blocks_per_page(struct inode *inode)
1613 * Simple support for retrying memory allocations. Introduced to help to 1613 * Simple support for retrying memory allocations. Introduced to help to
1614 * debug different VM deadlock avoidance strategies. 1614 * debug different VM deadlock avoidance strategies.
1615 */ 1615 */
1616void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry) 1616void * __jbd2_kmalloc (const char *where, size_t size, gfp_t flags, int retry)
1617{ 1617{
1618 return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0)); 1618 return kmalloc(size, flags | (retry ? __GFP_NOFAIL : 0));
1619} 1619}
@@ -1634,7 +1634,7 @@ static const char *jbd_slab_names[JBD_MAX_SLABS] = {
1634 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k" 1634 "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k"
1635}; 1635};
1636 1636
1637static void journal_destroy_jbd_slabs(void) 1637static void jbd2_journal_destroy_jbd_slabs(void)
1638{ 1638{
1639 int i; 1639 int i;
1640 1640
@@ -1645,7 +1645,7 @@ static void journal_destroy_jbd_slabs(void)
1645 } 1645 }
1646} 1646}
1647 1647
1648static int journal_create_jbd_slab(size_t slab_size) 1648static int jbd2_journal_create_jbd_slab(size_t slab_size)
1649{ 1649{
1650 int i = JBD_SLAB_INDEX(slab_size); 1650 int i = JBD_SLAB_INDEX(slab_size);
1651 1651
@@ -1671,7 +1671,7 @@ static int journal_create_jbd_slab(size_t slab_size)
1671 return 0; 1671 return 0;
1672} 1672}
1673 1673
1674void * jbd_slab_alloc(size_t size, gfp_t flags) 1674void * jbd2_slab_alloc(size_t size, gfp_t flags)
1675{ 1675{
1676 int idx; 1676 int idx;
1677 1677
@@ -1680,7 +1680,7 @@ void * jbd_slab_alloc(size_t size, gfp_t flags)
1680 return kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL); 1680 return kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL);
1681} 1681}
1682 1682
1683void jbd_slab_free(void *ptr, size_t size) 1683void jbd2_slab_free(void *ptr, size_t size)
1684{ 1684{
1685 int idx; 1685 int idx;
1686 1686
@@ -1692,35 +1692,35 @@ void jbd_slab_free(void *ptr, size_t size)
1692/* 1692/*
1693 * Journal_head storage management 1693 * Journal_head storage management
1694 */ 1694 */
1695static kmem_cache_t *journal_head_cache; 1695static kmem_cache_t *jbd2_journal_head_cache;
1696#ifdef CONFIG_JBD_DEBUG 1696#ifdef CONFIG_JBD_DEBUG
1697static atomic_t nr_journal_heads = ATOMIC_INIT(0); 1697static atomic_t nr_journal_heads = ATOMIC_INIT(0);
1698#endif 1698#endif
1699 1699
1700static int journal_init_journal_head_cache(void) 1700static int journal_init_jbd2_journal_head_cache(void)
1701{ 1701{
1702 int retval; 1702 int retval;
1703 1703
1704 J_ASSERT(journal_head_cache == 0); 1704 J_ASSERT(jbd2_journal_head_cache == 0);
1705 journal_head_cache = kmem_cache_create("journal_head", 1705 jbd2_journal_head_cache = kmem_cache_create("journal_head",
1706 sizeof(struct journal_head), 1706 sizeof(struct journal_head),
1707 0, /* offset */ 1707 0, /* offset */
1708 0, /* flags */ 1708 0, /* flags */
1709 NULL, /* ctor */ 1709 NULL, /* ctor */
1710 NULL); /* dtor */ 1710 NULL); /* dtor */
1711 retval = 0; 1711 retval = 0;
1712 if (journal_head_cache == 0) { 1712 if (jbd2_journal_head_cache == 0) {
1713 retval = -ENOMEM; 1713 retval = -ENOMEM;
1714 printk(KERN_EMERG "JBD: no memory for journal_head cache\n"); 1714 printk(KERN_EMERG "JBD: no memory for journal_head cache\n");
1715 } 1715 }
1716 return retval; 1716 return retval;
1717} 1717}
1718 1718
1719static void journal_destroy_journal_head_cache(void) 1719static void jbd2_journal_destroy_jbd2_journal_head_cache(void)
1720{ 1720{
1721 J_ASSERT(journal_head_cache != NULL); 1721 J_ASSERT(jbd2_journal_head_cache != NULL);
1722 kmem_cache_destroy(journal_head_cache); 1722 kmem_cache_destroy(jbd2_journal_head_cache);
1723 journal_head_cache = NULL; 1723 jbd2_journal_head_cache = NULL;
1724} 1724}
1725 1725
1726/* 1726/*
@@ -1734,7 +1734,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1734#ifdef CONFIG_JBD_DEBUG 1734#ifdef CONFIG_JBD_DEBUG
1735 atomic_inc(&nr_journal_heads); 1735 atomic_inc(&nr_journal_heads);
1736#endif 1736#endif
1737 ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); 1737 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
1738 if (ret == 0) { 1738 if (ret == 0) {
1739 jbd_debug(1, "out of memory for journal_head\n"); 1739 jbd_debug(1, "out of memory for journal_head\n");
1740 if (time_after(jiffies, last_warning + 5*HZ)) { 1740 if (time_after(jiffies, last_warning + 5*HZ)) {
@@ -1744,7 +1744,7 @@ static struct journal_head *journal_alloc_journal_head(void)
1744 } 1744 }
1745 while (ret == 0) { 1745 while (ret == 0) {
1746 yield(); 1746 yield();
1747 ret = kmem_cache_alloc(journal_head_cache, GFP_NOFS); 1747 ret = kmem_cache_alloc(jbd2_journal_head_cache, GFP_NOFS);
1748 } 1748 }
1749 } 1749 }
1750 return ret; 1750 return ret;
@@ -1756,7 +1756,7 @@ static void journal_free_journal_head(struct journal_head *jh)
1756 atomic_dec(&nr_journal_heads); 1756 atomic_dec(&nr_journal_heads);
1757 memset(jh, JBD_POISON_FREE, sizeof(*jh)); 1757 memset(jh, JBD_POISON_FREE, sizeof(*jh));
1758#endif 1758#endif
1759 kmem_cache_free(journal_head_cache, jh); 1759 kmem_cache_free(jbd2_journal_head_cache, jh);
1760} 1760}
1761 1761
1762/* 1762/*
@@ -1775,22 +1775,22 @@ static void journal_free_journal_head(struct journal_head *jh)
1775 * 1775 *
1776 * A journal_head may be detached from its buffer_head when the journal_head's 1776 * A journal_head may be detached from its buffer_head when the journal_head's
1777 * b_transaction, b_cp_transaction and b_next_transaction pointers are NULL. 1777 * b_transaction, b_cp_transaction and b_next_transaction pointers are NULL.
1778 * Various places in JBD call journal_remove_journal_head() to indicate that the 1778 * Various places in JBD call jbd2_journal_remove_journal_head() to indicate that the
1779 * journal_head can be dropped if needed. 1779 * journal_head can be dropped if needed.
1780 * 1780 *
1781 * Various places in the kernel want to attach a journal_head to a buffer_head 1781 * Various places in the kernel want to attach a journal_head to a buffer_head
1782 * _before_ attaching the journal_head to a transaction. To protect the 1782 * _before_ attaching the journal_head to a transaction. To protect the
1783 * journal_head in this situation, journal_add_journal_head elevates the 1783 * journal_head in this situation, jbd2_journal_add_journal_head elevates the
1784 * journal_head's b_jcount refcount by one. The caller must call 1784 * journal_head's b_jcount refcount by one. The caller must call
1785 * journal_put_journal_head() to undo this. 1785 * jbd2_journal_put_journal_head() to undo this.
1786 * 1786 *
1787 * So the typical usage would be: 1787 * So the typical usage would be:
1788 * 1788 *
1789 * (Attach a journal_head if needed. Increments b_jcount) 1789 * (Attach a journal_head if needed. Increments b_jcount)
1790 * struct journal_head *jh = journal_add_journal_head(bh); 1790 * struct journal_head *jh = jbd2_journal_add_journal_head(bh);
1791 * ... 1791 * ...
1792 * jh->b_transaction = xxx; 1792 * jh->b_transaction = xxx;
1793 * journal_put_journal_head(jh); 1793 * jbd2_journal_put_journal_head(jh);
1794 * 1794 *
1795 * Now, the journal_head's b_jcount is zero, but it is safe from being released 1795 * Now, the journal_head's b_jcount is zero, but it is safe from being released
1796 * because it has a non-zero b_transaction. 1796 * because it has a non-zero b_transaction.
@@ -1802,7 +1802,7 @@ static void journal_free_journal_head(struct journal_head *jh)
1802 * Doesn't need the journal lock. 1802 * Doesn't need the journal lock.
1803 * May sleep. 1803 * May sleep.
1804 */ 1804 */
1805struct journal_head *journal_add_journal_head(struct buffer_head *bh) 1805struct journal_head *jbd2_journal_add_journal_head(struct buffer_head *bh)
1806{ 1806{
1807 struct journal_head *jh; 1807 struct journal_head *jh;
1808 struct journal_head *new_jh = NULL; 1808 struct journal_head *new_jh = NULL;
@@ -1845,7 +1845,7 @@ repeat:
1845 * Grab a ref against this buffer_head's journal_head. If it ended up not 1845 * Grab a ref against this buffer_head's journal_head. If it ended up not
1846 * having a journal_head, return NULL 1846 * having a journal_head, return NULL
1847 */ 1847 */
1848struct journal_head *journal_grab_journal_head(struct buffer_head *bh) 1848struct journal_head *jbd2_journal_grab_journal_head(struct buffer_head *bh)
1849{ 1849{
1850 struct journal_head *jh = NULL; 1850 struct journal_head *jh = NULL;
1851 1851
@@ -1877,13 +1877,13 @@ static void __journal_remove_journal_head(struct buffer_head *bh)
1877 printk(KERN_WARNING "%s: freeing " 1877 printk(KERN_WARNING "%s: freeing "
1878 "b_frozen_data\n", 1878 "b_frozen_data\n",
1879 __FUNCTION__); 1879 __FUNCTION__);
1880 jbd_slab_free(jh->b_frozen_data, bh->b_size); 1880 jbd2_slab_free(jh->b_frozen_data, bh->b_size);
1881 } 1881 }
1882 if (jh->b_committed_data) { 1882 if (jh->b_committed_data) {
1883 printk(KERN_WARNING "%s: freeing " 1883 printk(KERN_WARNING "%s: freeing "
1884 "b_committed_data\n", 1884 "b_committed_data\n",
1885 __FUNCTION__); 1885 __FUNCTION__);
1886 jbd_slab_free(jh->b_committed_data, bh->b_size); 1886 jbd2_slab_free(jh->b_committed_data, bh->b_size);
1887 } 1887 }
1888 bh->b_private = NULL; 1888 bh->b_private = NULL;
1889 jh->b_bh = NULL; /* debug, really */ 1889 jh->b_bh = NULL; /* debug, really */
@@ -1897,7 +1897,7 @@ static void __journal_remove_journal_head(struct buffer_head *bh)
1897} 1897}
1898 1898
1899/* 1899/*
1900 * journal_remove_journal_head(): if the buffer isn't attached to a transaction 1900 * jbd2_journal_remove_journal_head(): if the buffer isn't attached to a transaction
1901 * and has a zero b_jcount then remove and release its journal_head. If we did 1901 * and has a zero b_jcount then remove and release its journal_head. If we did
1902 * see that the buffer is not used by any transaction we also "logically" 1902 * see that the buffer is not used by any transaction we also "logically"
1903 * decrement ->b_count. 1903 * decrement ->b_count.
@@ -1905,11 +1905,11 @@ static void __journal_remove_journal_head(struct buffer_head *bh)
1905 * We in fact take an additional increment on ->b_count as a convenience, 1905 * We in fact take an additional increment on ->b_count as a convenience,
1906 * because the caller usually wants to do additional things with the bh 1906 * because the caller usually wants to do additional things with the bh
1907 * after calling here. 1907 * after calling here.
1908 * The caller of journal_remove_journal_head() *must* run __brelse(bh) at some 1908 * The caller of jbd2_journal_remove_journal_head() *must* run __brelse(bh) at some
1909 * time. Once the caller has run __brelse(), the buffer is eligible for 1909 * time. Once the caller has run __brelse(), the buffer is eligible for
1910 * reaping by try_to_free_buffers(). 1910 * reaping by try_to_free_buffers().
1911 */ 1911 */
1912void journal_remove_journal_head(struct buffer_head *bh) 1912void jbd2_journal_remove_journal_head(struct buffer_head *bh)
1913{ 1913{
1914 jbd_lock_bh_journal_head(bh); 1914 jbd_lock_bh_journal_head(bh);
1915 __journal_remove_journal_head(bh); 1915 __journal_remove_journal_head(bh);
@@ -1920,7 +1920,7 @@ void journal_remove_journal_head(struct buffer_head *bh)
1920 * Drop a reference on the passed journal_head. If it fell to zero then try to 1920 * Drop a reference on the passed journal_head. If it fell to zero then try to
1921 * release the journal_head from the buffer_head. 1921 * release the journal_head from the buffer_head.
1922 */ 1922 */
1923void journal_put_journal_head(struct journal_head *jh) 1923void jbd2_journal_put_journal_head(struct journal_head *jh)
1924{ 1924{
1925 struct buffer_head *bh = jh2bh(jh); 1925 struct buffer_head *bh = jh2bh(jh);
1926 1926
@@ -1938,8 +1938,8 @@ void journal_put_journal_head(struct journal_head *jh)
1938 * /proc tunables 1938 * /proc tunables
1939 */ 1939 */
1940#if defined(CONFIG_JBD_DEBUG) 1940#if defined(CONFIG_JBD_DEBUG)
1941int journal_enable_debug; 1941int jbd2_journal_enable_debug;
1942EXPORT_SYMBOL(journal_enable_debug); 1942EXPORT_SYMBOL(jbd2_journal_enable_debug);
1943#endif 1943#endif
1944 1944
1945#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS) 1945#if defined(CONFIG_JBD_DEBUG) && defined(CONFIG_PROC_FS)
@@ -1951,7 +1951,7 @@ static int read_jbd_debug(char *page, char **start, off_t off,
1951{ 1951{
1952 int ret; 1952 int ret;
1953 1953
1954 ret = sprintf(page + off, "%d\n", journal_enable_debug); 1954 ret = sprintf(page + off, "%d\n", jbd2_journal_enable_debug);
1955 *eof = 1; 1955 *eof = 1;
1956 return ret; 1956 return ret;
1957} 1957}
@@ -1966,11 +1966,11 @@ static int write_jbd_debug(struct file *file, const char __user *buffer,
1966 if (copy_from_user(buf, buffer, count)) 1966 if (copy_from_user(buf, buffer, count))
1967 return -EFAULT; 1967 return -EFAULT;
1968 buf[ARRAY_SIZE(buf) - 1] = '\0'; 1968 buf[ARRAY_SIZE(buf) - 1] = '\0';
1969 journal_enable_debug = simple_strtoul(buf, NULL, 10); 1969 jbd2_journal_enable_debug = simple_strtoul(buf, NULL, 10);
1970 return count; 1970 return count;
1971} 1971}
1972 1972
1973#define JBD_PROC_NAME "sys/fs/jbd-debug" 1973#define JBD_PROC_NAME "sys/fs/jbd2-debug"
1974 1974
1975static void __init create_jbd_proc_entry(void) 1975static void __init create_jbd_proc_entry(void)
1976{ 1976{
@@ -1982,7 +1982,7 @@ static void __init create_jbd_proc_entry(void)
1982 } 1982 }
1983} 1983}
1984 1984
1985static void __exit remove_jbd_proc_entry(void) 1985static void __exit jbd2_remove_jbd_proc_entry(void)
1986{ 1986{
1987 if (proc_jbd_debug) 1987 if (proc_jbd_debug)
1988 remove_proc_entry(JBD_PROC_NAME, NULL); 1988 remove_proc_entry(JBD_PROC_NAME, NULL);
@@ -1991,31 +1991,31 @@ static void __exit remove_jbd_proc_entry(void)
1991#else 1991#else
1992 1992
1993#define create_jbd_proc_entry() do {} while (0) 1993#define create_jbd_proc_entry() do {} while (0)
1994#define remove_jbd_proc_entry() do {} while (0) 1994#define jbd2_remove_jbd_proc_entry() do {} while (0)
1995 1995
1996#endif 1996#endif
1997 1997
1998kmem_cache_t *jbd_handle_cache; 1998kmem_cache_t *jbd2_handle_cache;
1999 1999
2000static int __init journal_init_handle_cache(void) 2000static int __init journal_init_handle_cache(void)
2001{ 2001{
2002 jbd_handle_cache = kmem_cache_create("journal_handle", 2002 jbd2_handle_cache = kmem_cache_create("journal_handle",
2003 sizeof(handle_t), 2003 sizeof(handle_t),
2004 0, /* offset */ 2004 0, /* offset */
2005 0, /* flags */ 2005 0, /* flags */
2006 NULL, /* ctor */ 2006 NULL, /* ctor */
2007 NULL); /* dtor */ 2007 NULL); /* dtor */
2008 if (jbd_handle_cache == NULL) { 2008 if (jbd2_handle_cache == NULL) {
2009 printk(KERN_EMERG "JBD: failed to create handle cache\n"); 2009 printk(KERN_EMERG "JBD: failed to create handle cache\n");
2010 return -ENOMEM; 2010 return -ENOMEM;
2011 } 2011 }
2012 return 0; 2012 return 0;
2013} 2013}
2014 2014
2015static void journal_destroy_handle_cache(void) 2015static void jbd2_journal_destroy_handle_cache(void)
2016{ 2016{
2017 if (jbd_handle_cache) 2017 if (jbd2_handle_cache)
2018 kmem_cache_destroy(jbd_handle_cache); 2018 kmem_cache_destroy(jbd2_handle_cache);
2019} 2019}
2020 2020
2021/* 2021/*
@@ -2026,20 +2026,20 @@ static int __init journal_init_caches(void)
2026{ 2026{
2027 int ret; 2027 int ret;
2028 2028
2029 ret = journal_init_revoke_caches(); 2029 ret = jbd2_journal_init_revoke_caches();
2030 if (ret == 0) 2030 if (ret == 0)
2031 ret = journal_init_journal_head_cache(); 2031 ret = journal_init_jbd2_journal_head_cache();
2032 if (ret == 0) 2032 if (ret == 0)
2033 ret = journal_init_handle_cache(); 2033 ret = journal_init_handle_cache();
2034 return ret; 2034 return ret;
2035} 2035}
2036 2036
2037static void journal_destroy_caches(void) 2037static void jbd2_journal_destroy_caches(void)
2038{ 2038{
2039 journal_destroy_revoke_caches(); 2039 jbd2_journal_destroy_revoke_caches();
2040 journal_destroy_journal_head_cache(); 2040 jbd2_journal_destroy_jbd2_journal_head_cache();
2041 journal_destroy_handle_cache(); 2041 jbd2_journal_destroy_handle_cache();
2042 journal_destroy_jbd_slabs(); 2042 jbd2_journal_destroy_jbd_slabs();
2043} 2043}
2044 2044
2045static int __init journal_init(void) 2045static int __init journal_init(void)
@@ -2050,7 +2050,7 @@ static int __init journal_init(void)
2050 2050
2051 ret = journal_init_caches(); 2051 ret = journal_init_caches();
2052 if (ret != 0) 2052 if (ret != 0)
2053 journal_destroy_caches(); 2053 jbd2_journal_destroy_caches();
2054 create_jbd_proc_entry(); 2054 create_jbd_proc_entry();
2055 return ret; 2055 return ret;
2056} 2056}
@@ -2062,8 +2062,8 @@ static void __exit journal_exit(void)
2062 if (n) 2062 if (n)
2063 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n); 2063 printk(KERN_EMERG "JBD: leaked %d journal_heads!\n", n);
2064#endif 2064#endif
2065 remove_jbd_proc_entry(); 2065 jbd2_remove_jbd_proc_entry();
2066 journal_destroy_caches(); 2066 jbd2_journal_destroy_caches();
2067} 2067}
2068 2068
2069MODULE_LICENSE("GPL"); 2069MODULE_LICENSE("GPL");