diff options
Diffstat (limited to 'fs/jbd/journal.c')
-rw-r--r-- | fs/jbd/journal.c | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 737f7246a4b5..bd3c073b485d 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
@@ -276,7 +276,7 @@ static void journal_kill_thread(journal_t *journal) | |||
276 | int journal_write_metadata_buffer(transaction_t *transaction, | 276 | int journal_write_metadata_buffer(transaction_t *transaction, |
277 | struct journal_head *jh_in, | 277 | struct journal_head *jh_in, |
278 | struct journal_head **jh_out, | 278 | struct journal_head **jh_out, |
279 | unsigned long blocknr) | 279 | unsigned int blocknr) |
280 | { | 280 | { |
281 | int need_copy_out = 0; | 281 | int need_copy_out = 0; |
282 | int done_copy_out = 0; | 282 | int done_copy_out = 0; |
@@ -287,6 +287,7 @@ int journal_write_metadata_buffer(transaction_t *transaction, | |||
287 | struct page *new_page; | 287 | struct page *new_page; |
288 | unsigned int new_offset; | 288 | unsigned int new_offset; |
289 | struct buffer_head *bh_in = jh2bh(jh_in); | 289 | struct buffer_head *bh_in = jh2bh(jh_in); |
290 | journal_t *journal = transaction->t_journal; | ||
290 | 291 | ||
291 | /* | 292 | /* |
292 | * The buffer really shouldn't be locked: only the current committing | 293 | * The buffer really shouldn't be locked: only the current committing |
@@ -300,6 +301,11 @@ int journal_write_metadata_buffer(transaction_t *transaction, | |||
300 | J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in)); | 301 | J_ASSERT_BH(bh_in, buffer_jbddirty(bh_in)); |
301 | 302 | ||
302 | new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL); | 303 | new_bh = alloc_buffer_head(GFP_NOFS|__GFP_NOFAIL); |
304 | /* keep subsequent assertions sane */ | ||
305 | new_bh->b_state = 0; | ||
306 | init_buffer(new_bh, NULL, NULL); | ||
307 | atomic_set(&new_bh->b_count, 1); | ||
308 | new_jh = journal_add_journal_head(new_bh); /* This sleeps */ | ||
303 | 309 | ||
304 | /* | 310 | /* |
305 | * If a new transaction has already done a buffer copy-out, then | 311 | * If a new transaction has already done a buffer copy-out, then |
@@ -361,14 +367,6 @@ repeat: | |||
361 | kunmap_atomic(mapped_data, KM_USER0); | 367 | kunmap_atomic(mapped_data, KM_USER0); |
362 | } | 368 | } |
363 | 369 | ||
364 | /* keep subsequent assertions sane */ | ||
365 | new_bh->b_state = 0; | ||
366 | init_buffer(new_bh, NULL, NULL); | ||
367 | atomic_set(&new_bh->b_count, 1); | ||
368 | jbd_unlock_bh_state(bh_in); | ||
369 | |||
370 | new_jh = journal_add_journal_head(new_bh); /* This sleeps */ | ||
371 | |||
372 | set_bh_page(new_bh, new_page, new_offset); | 370 | set_bh_page(new_bh, new_page, new_offset); |
373 | new_jh->b_transaction = NULL; | 371 | new_jh->b_transaction = NULL; |
374 | new_bh->b_size = jh2bh(jh_in)->b_size; | 372 | new_bh->b_size = jh2bh(jh_in)->b_size; |
@@ -385,7 +383,11 @@ repeat: | |||
385 | * copying is moved to the transaction's shadow queue. | 383 | * copying is moved to the transaction's shadow queue. |
386 | */ | 384 | */ |
387 | JBUFFER_TRACE(jh_in, "file as BJ_Shadow"); | 385 | JBUFFER_TRACE(jh_in, "file as BJ_Shadow"); |
388 | journal_file_buffer(jh_in, transaction, BJ_Shadow); | 386 | spin_lock(&journal->j_list_lock); |
387 | __journal_file_buffer(jh_in, transaction, BJ_Shadow); | ||
388 | spin_unlock(&journal->j_list_lock); | ||
389 | jbd_unlock_bh_state(bh_in); | ||
390 | |||
389 | JBUFFER_TRACE(new_jh, "file as BJ_IO"); | 391 | JBUFFER_TRACE(new_jh, "file as BJ_IO"); |
390 | journal_file_buffer(new_jh, transaction, BJ_IO); | 392 | journal_file_buffer(new_jh, transaction, BJ_IO); |
391 | 393 | ||
@@ -565,9 +567,9 @@ int log_wait_commit(journal_t *journal, tid_t tid) | |||
565 | * Log buffer allocation routines: | 567 | * Log buffer allocation routines: |
566 | */ | 568 | */ |
567 | 569 | ||
568 | int journal_next_log_block(journal_t *journal, unsigned long *retp) | 570 | int journal_next_log_block(journal_t *journal, unsigned int *retp) |
569 | { | 571 | { |
570 | unsigned long blocknr; | 572 | unsigned int blocknr; |
571 | 573 | ||
572 | spin_lock(&journal->j_state_lock); | 574 | spin_lock(&journal->j_state_lock); |
573 | J_ASSERT(journal->j_free > 1); | 575 | J_ASSERT(journal->j_free > 1); |
@@ -588,11 +590,11 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp) | |||
588 | * this is a no-op. If needed, we can use j_blk_offset - everything is | 590 | * this is a no-op. If needed, we can use j_blk_offset - everything is |
589 | * ready. | 591 | * ready. |
590 | */ | 592 | */ |
591 | int journal_bmap(journal_t *journal, unsigned long blocknr, | 593 | int journal_bmap(journal_t *journal, unsigned int blocknr, |
592 | unsigned long *retp) | 594 | unsigned int *retp) |
593 | { | 595 | { |
594 | int err = 0; | 596 | int err = 0; |
595 | unsigned long ret; | 597 | unsigned int ret; |
596 | 598 | ||
597 | if (journal->j_inode) { | 599 | if (journal->j_inode) { |
598 | ret = bmap(journal->j_inode, blocknr); | 600 | ret = bmap(journal->j_inode, blocknr); |
@@ -602,7 +604,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr, | |||
602 | char b[BDEVNAME_SIZE]; | 604 | char b[BDEVNAME_SIZE]; |
603 | 605 | ||
604 | printk(KERN_ALERT "%s: journal block not found " | 606 | printk(KERN_ALERT "%s: journal block not found " |
605 | "at offset %lu on %s\n", | 607 | "at offset %u on %s\n", |
606 | __func__, | 608 | __func__, |
607 | blocknr, | 609 | blocknr, |
608 | bdevname(journal->j_dev, b)); | 610 | bdevname(journal->j_dev, b)); |
@@ -628,7 +630,7 @@ int journal_bmap(journal_t *journal, unsigned long blocknr, | |||
628 | struct journal_head *journal_get_descriptor_buffer(journal_t *journal) | 630 | struct journal_head *journal_get_descriptor_buffer(journal_t *journal) |
629 | { | 631 | { |
630 | struct buffer_head *bh; | 632 | struct buffer_head *bh; |
631 | unsigned long blocknr; | 633 | unsigned int blocknr; |
632 | int err; | 634 | int err; |
633 | 635 | ||
634 | err = journal_next_log_block(journal, &blocknr); | 636 | err = journal_next_log_block(journal, &blocknr); |
@@ -772,7 +774,7 @@ journal_t * journal_init_inode (struct inode *inode) | |||
772 | journal_t *journal = journal_init_common(); | 774 | journal_t *journal = journal_init_common(); |
773 | int err; | 775 | int err; |
774 | int n; | 776 | int n; |
775 | unsigned long blocknr; | 777 | unsigned int blocknr; |
776 | 778 | ||
777 | if (!journal) | 779 | if (!journal) |
778 | return NULL; | 780 | return NULL; |
@@ -844,10 +846,16 @@ static void journal_fail_superblock (journal_t *journal) | |||
844 | static int journal_reset(journal_t *journal) | 846 | static int journal_reset(journal_t *journal) |
845 | { | 847 | { |
846 | journal_superblock_t *sb = journal->j_superblock; | 848 | journal_superblock_t *sb = journal->j_superblock; |
847 | unsigned long first, last; | 849 | unsigned int first, last; |
848 | 850 | ||
849 | first = be32_to_cpu(sb->s_first); | 851 | first = be32_to_cpu(sb->s_first); |
850 | last = be32_to_cpu(sb->s_maxlen); | 852 | last = be32_to_cpu(sb->s_maxlen); |
853 | if (first + JFS_MIN_JOURNAL_BLOCKS > last + 1) { | ||
854 | printk(KERN_ERR "JBD: Journal too short (blocks %u-%u).\n", | ||
855 | first, last); | ||
856 | journal_fail_superblock(journal); | ||
857 | return -EINVAL; | ||
858 | } | ||
851 | 859 | ||
852 | journal->j_first = first; | 860 | journal->j_first = first; |
853 | journal->j_last = last; | 861 | journal->j_last = last; |
@@ -877,7 +885,7 @@ static int journal_reset(journal_t *journal) | |||
877 | **/ | 885 | **/ |
878 | int journal_create(journal_t *journal) | 886 | int journal_create(journal_t *journal) |
879 | { | 887 | { |
880 | unsigned long blocknr; | 888 | unsigned int blocknr; |
881 | struct buffer_head *bh; | 889 | struct buffer_head *bh; |
882 | journal_superblock_t *sb; | 890 | journal_superblock_t *sb; |
883 | int i, err; | 891 | int i, err; |
@@ -961,14 +969,14 @@ void journal_update_superblock(journal_t *journal, int wait) | |||
961 | if (sb->s_start == 0 && journal->j_tail_sequence == | 969 | if (sb->s_start == 0 && journal->j_tail_sequence == |
962 | journal->j_transaction_sequence) { | 970 | journal->j_transaction_sequence) { |
963 | jbd_debug(1,"JBD: Skipping superblock update on recovered sb " | 971 | jbd_debug(1,"JBD: Skipping superblock update on recovered sb " |
964 | "(start %ld, seq %d, errno %d)\n", | 972 | "(start %u, seq %d, errno %d)\n", |
965 | journal->j_tail, journal->j_tail_sequence, | 973 | journal->j_tail, journal->j_tail_sequence, |
966 | journal->j_errno); | 974 | journal->j_errno); |
967 | goto out; | 975 | goto out; |
968 | } | 976 | } |
969 | 977 | ||
970 | spin_lock(&journal->j_state_lock); | 978 | spin_lock(&journal->j_state_lock); |
971 | jbd_debug(1,"JBD: updating superblock (start %ld, seq %d, errno %d)\n", | 979 | jbd_debug(1,"JBD: updating superblock (start %u, seq %d, errno %d)\n", |
972 | journal->j_tail, journal->j_tail_sequence, journal->j_errno); | 980 | journal->j_tail, journal->j_tail_sequence, journal->j_errno); |
973 | 981 | ||
974 | sb->s_sequence = cpu_to_be32(journal->j_tail_sequence); | 982 | sb->s_sequence = cpu_to_be32(journal->j_tail_sequence); |
@@ -1363,7 +1371,7 @@ int journal_flush(journal_t *journal) | |||
1363 | { | 1371 | { |
1364 | int err = 0; | 1372 | int err = 0; |
1365 | transaction_t *transaction = NULL; | 1373 | transaction_t *transaction = NULL; |
1366 | unsigned long old_tail; | 1374 | unsigned int old_tail; |
1367 | 1375 | ||
1368 | spin_lock(&journal->j_state_lock); | 1376 | spin_lock(&journal->j_state_lock); |
1369 | 1377 | ||