linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: linux-ext4@vger.kernel.org
Cc: Ted Tso <tytso@mit.edu>, Jan Kara <jack@suse.cz>
Subject: [PATCH 5/5] jbd2: Speedup jbd2_journal_dirty_metadata()
Date: Thu,  2 Apr 2015 15:58:20 +0200	[thread overview]
Message-ID: <1427983100-29889-6-git-send-email-jack@suse.cz> (raw)
In-Reply-To: <1427983100-29889-1-git-send-email-jack@suse.cz>

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.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 fs/jbd2/transaction.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index a91f639af6c3..ad10ca8fb9ef 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1290,8 +1290,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.
@@ -1325,12 +1323,25 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
 	WARN_ON(!transaction);
 	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);
+	J_ASSERT_JH(jh, jh->b_transaction == transaction ||
+			jh->b_next_transaction == transaction);
+	if (jh->b_modified == 1) {
+		/* If it's in our transaction it must be in BJ_Metadata list */
+		J_ASSERT_JH(jh, jh->b_transaction != transaction ||
+				jh->b_jlist == BJ_Metadata);
+		goto out;
+	}
+
+	journal = transaction->t_journal;
 	jbd_debug(5, "journal_head %p\n", jh);
 	JBUFFER_TRACE(jh, "entry");
 
@@ -1421,7 +1432,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


  parent reply	other threads:[~2015-04-02 13:58 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-02 13:58 [PATCH 0/5] jbd2: Avoid unnecessary locking when buffer is already journaled Jan Kara
2015-04-02 13:58 ` [PATCH 1/5] jbd2: Simplify code flow in do_get_write_access() Jan Kara
2015-06-08 16:39   ` Theodore Ts'o
2015-04-02 13:58 ` [PATCH 2/5] jbd2: Simplify error path on allocation failure " Jan Kara
2015-06-08 16:42   ` Theodore Ts'o
2015-04-02 13:58 ` [PATCH 3/5] jbd2: Simplify code flow " Jan Kara
2015-06-08 16:45   ` Theodore Ts'o
2015-04-02 13:58 ` [PATCH 4/5] jbd2: Speedup jbd2_journal_get_[write|undo]_access() Jan Kara
2015-06-08 16:47   ` Theodore Ts'o
2015-06-08 22:32     ` Theodore Ts'o
2015-06-09  5:24       ` Theodore Ts'o
2015-06-17 16:39         ` Jan Kara
2015-06-17 16:56     ` Jan Kara
     [not found]       ` <CAA1ppbhojR0aaDr-BUWQLWQDo5+sO9Tc6b=Dxf5XrRAr2DT0oQ@mail.gmail.com>
2015-06-18  8:52         ` Jan Kara
2015-06-21  1:56           ` Theodore Ts'o
2015-04-02 13:58 ` Jan Kara [this message]
2015-06-08 16:50   ` [PATCH 5/5] jbd2: Speedup jbd2_journal_dirty_metadata() Theodore Ts'o
2015-04-02 14:23 ` [PATCH 0/5] jbd2: Avoid unnecessary locking when buffer is already journaled Theodore Ts'o
2015-04-12 10:09 ` Dmitry Monakhov
2015-04-16 10:46   ` Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1427983100-29889-6-git-send-email-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).