aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd/commit.c
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2006-06-23 05:05:25 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-23 10:43:04 -0400
commit9ada7340987aa24395809570840c7c6847044f52 (patch)
treee2a57c184d15cbd2415f4fce35534cf635e9fa9f /fs/jbd/commit.c
parent8e0a43d8fa953179505869ec28de78550246e795 (diff)
[PATCH] jbd: fix BUG in journal_commit_transaction()
Fix possible assertion failure in journal_commit_transaction() on jh->b_next_transaction == NULL (when we are processing BJ_Forget list and buffer is not jbddirty). !jbddirty buffers can be placed on BJ_Forget list for example by journal_forget() or by __dispose_buffer() - generally such buffer means that it has been freed by this transaction. Freed buffers should not be reallocated until the transaction has committed (that's why we have the assertion there) but they *can* be reallocated when the transaction has already been committed to disk and we are just processing the BJ_Forget list (as soon as we remove b_committed_data from the bitmap bh, ext3 will be able to reallocate buffers freed by the committing transaction). So we have to also count with the case that the buffer has been reallocated and b_next_transaction has been already set. And one more subtle point: it can happen that we manage to reallocate the buffer and also mark it jbddirty. Then we also add the freed buffer to the checkpoint list of the committing trasaction. But that should do no harm. Non-jbddirty buffers should be filed to BJ_Reserved and not BJ_Metadata list. It can actually happen that we refile such buffers during the commit phase when we reallocate in the running transaction blocks deleted in committing transaction (and that can happen if the committing transaction already wrote all the data and is just cleaning up BJ_Forget list). Signed-off-by: Jan Kara <jack@suse.cz> Acked-by: "Stephen C. Tweedie" <sct@redhat.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs/jbd/commit.c')
-rw-r--r--fs/jbd/commit.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index 002ad2bbc769..0971814c38b8 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -790,11 +790,22 @@ restart_loop:
790 jbd_unlock_bh_state(bh); 790 jbd_unlock_bh_state(bh);
791 } else { 791 } else {
792 J_ASSERT_BH(bh, !buffer_dirty(bh)); 792 J_ASSERT_BH(bh, !buffer_dirty(bh));
793 J_ASSERT_JH(jh, jh->b_next_transaction == NULL); 793 /* The buffer on BJ_Forget list and not jbddirty means
794 __journal_unfile_buffer(jh); 794 * it has been freed by this transaction and hence it
795 jbd_unlock_bh_state(bh); 795 * could not have been reallocated until this
796 journal_remove_journal_head(bh); /* needs a brelse */ 796 * transaction has committed. *BUT* it could be
797 release_buffer_page(bh); 797 * reallocated once we have written all the data to
798 * disk and before we process the buffer on BJ_Forget
799 * list. */
800 JBUFFER_TRACE(jh, "refile or unfile freed buffer");
801 __journal_refile_buffer(jh);
802 if (!jh->b_transaction) {
803 jbd_unlock_bh_state(bh);
804 /* needs a brelse */
805 journal_remove_journal_head(bh);
806 release_buffer_page(bh);
807 } else
808 jbd_unlock_bh_state(bh);
798 } 809 }
799 cond_resched_lock(&journal->j_list_lock); 810 cond_resched_lock(&journal->j_list_lock);
800 } 811 }