All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Ted Tso <tytso@mit.edu>
Cc: <linux-ext4@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Anna-Maria Gleixner <anna-maria@linutronix.de>,
	Julia Cartwright <julia@ni.com>, Jan Kara <jack@suse.cz>
Subject: [PATCH 5/7] jbd2: Don't call __bforget() unnecessarily
Date: Fri,  9 Aug 2019 14:42:31 +0200	[thread overview]
Message-ID: <20190809124233.13277-6-jack@suse.cz> (raw)
In-Reply-To: <20190809124233.13277-1-jack@suse.cz>

jbd2_journal_forget() jumps to 'not_jbd' branch which calls __bforget()
in cases where the buffer is clean which is pointless. In case of failed
assertion, it can be even argued that it is safer not to touch buffer's
dirty bits. Also logically it makes more sense to just jump to 'drop'
and that will make logic also simpler when we switch bh_state_lock to a
spinlock.

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

diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index 9ccef3d6e817..d752d7f6929e 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -1547,7 +1547,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 	if (!J_EXPECT_JH(jh, !jh->b_committed_data,
 			 "inconsistent data on disk")) {
 		err = -EIO;
-		goto not_jbd;
+		goto drop;
 	}
 
 	/* keep track of whether or not this transaction modified us */
@@ -1637,7 +1637,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 		if (!jh->b_cp_transaction) {
 			JBUFFER_TRACE(jh, "belongs to none transaction");
 			spin_unlock(&journal->j_list_lock);
-			goto not_jbd;
+			goto drop;
 		}
 
 		/*
@@ -1647,7 +1647,7 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 		if (!buffer_dirty(bh)) {
 			__jbd2_journal_remove_checkpoint(jh);
 			spin_unlock(&journal->j_list_lock);
-			goto not_jbd;
+			goto drop;
 		}
 
 		/*
@@ -1660,10 +1660,9 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh)
 		__jbd2_journal_file_buffer(jh, transaction, BJ_Forget);
 		spin_unlock(&journal->j_list_lock);
 	}
-
+drop:
 	jbd_unlock_bh_state(bh);
 	__brelse(bh);
-drop:
 	if (drop_reserve) {
 		/* no need to reserve log space for this block -bzzz */
 		handle->h_buffer_credits++;
-- 
2.16.4


  parent reply	other threads:[~2019-08-09 12:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-09 12:42 [PATCH 0/7 v2] jbd2: Bit spinlock conversions Jan Kara
2019-08-09 12:42 ` [PATCH 1/7] jbd2: Simplify journal_unmap_buffer() Jan Kara
2019-08-09 12:42 ` [PATCH 2/7] jbd2: Remove jbd_trylock_bh_state() Jan Kara
2019-08-09 12:42 ` [PATCH 3/7] jbd2: Move dropping of jh reference out of un/re-filing functions Jan Kara
2019-08-09 12:42 ` [PATCH 4/7] jbd2: Drop unnecessary branch from jbd2_journal_forget() Jan Kara
2019-08-09 12:42 ` Jan Kara [this message]
2019-10-28 15:28   ` [PATCH 5/7] jbd2: Don't call __bforget() unnecessarily Theodore Y. Ts'o
2019-10-28 16:01     ` Theodore Y. Ts'o
2019-10-30 11:49       ` Jan Kara
2019-08-09 12:42 ` [PATCH 6/7] jbd2: Make state lock a spinlock Jan Kara
2019-08-09 12:42 ` [PATCH 7/7] jbd2: Free journal head outside of locked region Jan Kara
2019-10-11 12:31 ` [PATCH 0/7 v2] jbd2: Bit spinlock conversions Sebastian Andrzej Siewior
2019-11-03 19:01 ` Theodore Y. Ts'o
  -- strict thread matches above, loose matches on Subject: below --
2019-08-02 15:13 [PATCH 0/7] " Jan Kara
2019-08-02 15:13 ` [PATCH 5/7] jbd2: Don't call __bforget() unnecessarily 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=20190809124233.13277-6-jack@suse.cz \
    --to=jack@suse.cz \
    --cc=anna-maria@linutronix.de \
    --cc=julia@ni.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.