aboutsummaryrefslogtreecommitdiffstats
path: root/fs/jbd
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2008-04-28 05:16:10 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:44 -0400
commit5bc833feaa8b2236265764e7e81f44937be46eda (patch)
tree9aa34ee4e898d268fade3e6e2b9b5678f49caa54 /fs/jbd
parent269b26191650be46ce6c91dec24cf20f59650529 (diff)
jbd: fix the way the b_modified flag is cleared
Currently at the start of a journal commit we loop through all of the buffers on the committing transaction and clear the b_modified flag (the flag that is set when a transaction modifies the buffer) under the j_list_lock. The problem is that everywhere else this flag is modified only under the jbd lock buffer flag, so it will race with a running transaction who could potentially set it, and have it unset by the committing transaction. This is also a big waste, you can have several thousands of buffers that you are clearing the modified flag on when you may not need to. This patch removes this code and instead clears the b_modified flag upon entering do_get_write_access/journal_get_create_access, so if that transaction does indeed use the buffer then it will be accounted for properly, and if it does not then we know we didn't use it. That will be important for the next patch in this series. Tested thoroughly by myself using postmark/iozone/bonnie++. Signed-off-by: Josef Bacik <jbacik@redhat.com> Cc: <linux-ext4@vger.kernel.org> Acked-by: Jan Kara <jack@ucw.cz> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/jbd')
-rw-r--r--fs/jbd/commit.c16
-rw-r--r--fs/jbd/transaction.c13
2 files changed, 13 insertions, 16 deletions
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c
index a38c7186c570..d2f652e6e22e 100644
--- a/fs/jbd/commit.c
+++ b/fs/jbd/commit.c
@@ -407,22 +407,6 @@ void journal_commit_transaction(journal_t *journal)
407 jbd_debug (3, "JBD: commit phase 2\n"); 407 jbd_debug (3, "JBD: commit phase 2\n");
408 408
409 /* 409 /*
410 * First, drop modified flag: all accesses to the buffers
411 * will be tracked for a new trasaction only -bzzz
412 */
413 spin_lock(&journal->j_list_lock);
414 if (commit_transaction->t_buffers) {
415 new_jh = jh = commit_transaction->t_buffers->b_tnext;
416 do {
417 J_ASSERT_JH(new_jh, new_jh->b_modified == 1 ||
418 new_jh->b_modified == 0);
419 new_jh->b_modified = 0;
420 new_jh = new_jh->b_tnext;
421 } while (new_jh != jh);
422 }
423 spin_unlock(&journal->j_list_lock);
424
425 /*
426 * Now start flushing things to disk, in the order they appear 410 * Now start flushing things to disk, in the order they appear
427 * on the transaction lists. Data blocks go first. 411 * on the transaction lists. Data blocks go first.
428 */ 412 */
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c
index 2c9e8f5d13aa..2e9670e2237e 100644
--- a/fs/jbd/transaction.c
+++ b/fs/jbd/transaction.c
@@ -609,6 +609,12 @@ repeat:
609 goto done; 609 goto done;
610 610
611 /* 611 /*
612 * this is the first time this transaction is touching this buffer,
613 * reset the modified flag
614 */
615 jh->b_modified = 0;
616
617 /*
612 * If there is already a copy-out version of this buffer, then we don't 618 * If there is already a copy-out version of this buffer, then we don't
613 * need to make another one 619 * need to make another one
614 */ 620 */
@@ -820,9 +826,16 @@ int journal_get_create_access(handle_t *handle, struct buffer_head *bh)
820 826
821 if (jh->b_transaction == NULL) { 827 if (jh->b_transaction == NULL) {
822 jh->b_transaction = transaction; 828 jh->b_transaction = transaction;
829
830 /* first access by this transaction */
831 jh->b_modified = 0;
832
823 JBUFFER_TRACE(jh, "file as BJ_Reserved"); 833 JBUFFER_TRACE(jh, "file as BJ_Reserved");
824 __journal_file_buffer(jh, transaction, BJ_Reserved); 834 __journal_file_buffer(jh, transaction, BJ_Reserved);
825 } else if (jh->b_transaction == journal->j_committing_transaction) { 835 } else if (jh->b_transaction == journal->j_committing_transaction) {
836 /* first access by this transaction */
837 jh->b_modified = 0;
838
826 JBUFFER_TRACE(jh, "set next transaction"); 839 JBUFFER_TRACE(jh, "set next transaction");
827 jh->b_next_transaction = transaction; 840 jh->b_next_transaction = transaction;
828 } 841 }