diff mbox series

[V2,5/7] fs/jbd2: Simplify journal_unmap_buffer()

Message ID 20190801010944.364767635@linutronix.de (mailing list archive)
State New, archived
Headers show
Series fs: Substitute bit-spinlocks for PREEMPT_RT and debugging | expand

Commit Message

Thomas Gleixner Aug. 1, 2019, 1:01 a.m. UTC
journal_unmap_buffer() checks first whether the buffer head is a journal.
If so it takes locks and then invokes jbd2_journal_grab_journal_head()
followed by another check whether this is journal head buffer.

The double checking is pointless.

Replace the initial check with jbd2_journal_grab_journal_head() which
alredy checks whether the buffer head is actually a journal.

Allows also early access to the journal head pointer for the upcoming
conversion of state lock to a regular spinlock.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-ext4@vger.kernel.org
Cc: "Theodore Ts'o" <tytso@mit.edu>
Cc: Jan Kara <jack@suse.com>
---
V2: New patch
---
 fs/jbd2/transaction.c |    8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Comments

Jan Kara Aug. 1, 2019, 9:04 a.m. UTC | #1
On Thu 01-08-19 03:01:31, Thomas Gleixner wrote:
> journal_unmap_buffer() checks first whether the buffer head is a journal.
> If so it takes locks and then invokes jbd2_journal_grab_journal_head()
> followed by another check whether this is journal head buffer.
> 
> The double checking is pointless.
> 
> Replace the initial check with jbd2_journal_grab_journal_head() which
> alredy checks whether the buffer head is actually a journal.
> 
> Allows also early access to the journal head pointer for the upcoming
> conversion of state lock to a regular spinlock.
> 
> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
> Cc: linux-ext4@vger.kernel.org
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Cc: Jan Kara <jack@suse.com>

Nice simplification. You can add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
> V2: New patch
> ---
>  fs/jbd2/transaction.c |    8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> --- a/fs/jbd2/transaction.c
> +++ b/fs/jbd2/transaction.c
> @@ -2196,7 +2196,8 @@ static int journal_unmap_buffer(journal_
>  	 * holding the page lock. --sct
>  	 */
>  
> -	if (!buffer_jbd(bh))
> +	jh = jbd2_journal_grab_journal_head(bh);
> +	if (!jh)
>  		goto zap_buffer_unlocked;
>  
>  	/* OK, we have data buffer in journaled mode */
> @@ -2204,10 +2205,6 @@ static int journal_unmap_buffer(journal_
>  	jbd_lock_bh_state(bh);
>  	spin_lock(&journal->j_list_lock);
>  
> -	jh = jbd2_journal_grab_journal_head(bh);
> -	if (!jh)
> -		goto zap_buffer_no_jh;
> -
>  	/*
>  	 * We cannot remove the buffer from checkpoint lists until the
>  	 * transaction adding inode to orphan list (let's call it T)
> @@ -2329,7 +2326,6 @@ static int journal_unmap_buffer(journal_
>  	 */
>  	jh->b_modified = 0;
>  	jbd2_journal_put_journal_head(jh);
> -zap_buffer_no_jh:
>  	spin_unlock(&journal->j_list_lock);
>  	jbd_unlock_bh_state(bh);
>  	write_unlock(&journal->j_state_lock);
> 
>
diff mbox series

Patch

--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -2196,7 +2196,8 @@  static int journal_unmap_buffer(journal_
 	 * holding the page lock. --sct
 	 */
 
-	if (!buffer_jbd(bh))
+	jh = jbd2_journal_grab_journal_head(bh);
+	if (!jh)
 		goto zap_buffer_unlocked;
 
 	/* OK, we have data buffer in journaled mode */
@@ -2204,10 +2205,6 @@  static int journal_unmap_buffer(journal_
 	jbd_lock_bh_state(bh);
 	spin_lock(&journal->j_list_lock);
 
-	jh = jbd2_journal_grab_journal_head(bh);
-	if (!jh)
-		goto zap_buffer_no_jh;
-
 	/*
 	 * We cannot remove the buffer from checkpoint lists until the
 	 * transaction adding inode to orphan list (let's call it T)
@@ -2329,7 +2326,6 @@  static int journal_unmap_buffer(journal_
 	 */
 	jh->b_modified = 0;
 	jbd2_journal_put_journal_head(jh);
-zap_buffer_no_jh:
 	spin_unlock(&journal->j_list_lock);
 	jbd_unlock_bh_state(bh);
 	write_unlock(&journal->j_state_lock);