From 2ad399279c229399fd360a9939247292c969cfa6 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Mon, 13 Jul 2015 16:54:07 -0400 Subject: [PATCH] add patch speedup-jbd2_journal_dirty_metadata --- series | 2 + speedup-jbd2_journal_dirty_metadata | 95 +++++++++++++++++++++++++++++++++++++ timestamps | 7 +-- 3 files changed, 101 insertions(+), 3 deletions(-) create mode 100644 speedup-jbd2_journal_dirty_metadata diff --git a/series b/series index 5b117da5..bfb7ec86 100644 --- a/series +++ b/series @@ -1,5 +1,7 @@ # BASE 1c4c7159ed24 +speedup-jbd2_journal_dirty_metadata + ########################################## # unstable patches #################################################### diff --git a/speedup-jbd2_journal_dirty_metadata b/speedup-jbd2_journal_dirty_metadata new file mode 100644 index 00000000..943e5174 --- /dev/null +++ b/speedup-jbd2_journal_dirty_metadata @@ -0,0 +1,95 @@ +jbd2: speedup jbd2_journal_dirty_metadata() + +From: Jan Kara + +It is often the case that we mark buffer as having dirty metadata when +the buffer is already in that state (frequent for bitmaps, inode table +blocks, superblock). Thus it is unnecessary to contend on grabbing +journal head reference and bh_state lock. Avoid that by checking whether +any modification to the buffer is needed before grabbing any locks or +references. + +[ Note: this is a fixed version of commit 2143c1965a761, which was + reverted in ebeaa8ddb3663b5 due to a false positive triggering of an + assertion check. -- Ted ] + +Signed-off-by: Jan Kara +Signed-off-by: Theodore Ts'o +--- + fs/jbd2/transaction.c | 38 ++++++++++++++++++++++++++++++++------ + 1 file changed, 32 insertions(+), 6 deletions(-) + + Ted, this is the speedup patch with fixed assertion. It survived several +hours of beating with xfstests generic/269. Ming Lei, can you verify this +patch passes testing on your machine as well? Thanks! + +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c +index f3d06174b051..546ce0e76605 100644 +--- a/fs/jbd2/transaction.c ++++ b/fs/jbd2/transaction.c +@@ -1280,8 +1280,6 @@ void jbd2_buffer_abort_trigger(struct journal_head *jh, + triggers->t_abort(triggers, jh2bh(jh)); + } + +- +- + /** + * int jbd2_journal_dirty_metadata() - mark a buffer as containing dirty metadata + * @handle: transaction to add buffer to. +@@ -1314,12 +1312,41 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) + + if (is_handle_aborted(handle)) + return -EROFS; +- journal = transaction->t_journal; +- jh = jbd2_journal_grab_journal_head(bh); +- if (!jh) { ++ if (!buffer_jbd(bh)) { + ret = -EUCLEAN; + goto out; + } ++ /* ++ * We don't grab jh reference here since the buffer must be part ++ * of the running transaction. ++ */ ++ jh = bh2jh(bh); ++ /* ++ * This and the following assertions are unreliable since we may see jh ++ * in inconsistent state unless we grab bh_state lock. But this is ++ * crucial to catch bugs so let's do a reliable check until the ++ * lockless handling is fully proven. ++ */ ++ if (jh->b_transaction != transaction && ++ jh->b_next_transaction != transaction) { ++ jbd_lock_bh_state(bh); ++ J_ASSERT_JH(jh, jh->b_transaction == transaction || ++ jh->b_next_transaction == transaction); ++ jbd_unlock_bh_state(bh); ++ } ++ if (jh->b_modified == 1) { ++ /* If it's in our transaction it must be in BJ_Metadata list. */ ++ if (jh->b_transaction == transaction && ++ jh->b_jlist != BJ_Metadata) { ++ jbd_lock_bh_state(bh); ++ J_ASSERT_JH(jh, jh->b_transaction != transaction || ++ jh->b_jlist == BJ_Metadata); ++ jbd_unlock_bh_state(bh); ++ } ++ goto out; ++ } ++ ++ journal = transaction->t_journal; + jbd_debug(5, "journal_head %p\n", jh); + JBUFFER_TRACE(jh, "entry"); + +@@ -1410,7 +1437,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) + spin_unlock(&journal->j_list_lock); + out_unlock_bh: + jbd_unlock_bh_state(bh); +- jbd2_journal_put_journal_head(jh); + out: + JBUFFER_TRACE(jh, "exit"); + return ret; +-- +2.1.4 + + diff --git a/timestamps b/timestamps index d2eb64cd..180f9e22 100755 --- a/timestamps +++ b/timestamps @@ -24,6 +24,7 @@ touch -d @1436139174 add-sysfs-bool-support touch -d @1436139234 add-squelch-errors-support touch -d @1436139294 dump-in-use-buffers touch -d @1436139354 akpm-jbd2-locking-fix -touch -d @1436145929 series -touch -d @1436146097 status -touch -d @1436146110 timestamps +touch -d @1436146757 speedup-jbd2_journal_dirty_metadata +touch -d @1436147638 series +touch -d @1436147646 status +touch -d @1436820838 timestamps -- 2.11.4.GIT