Skip to content

Commit

Permalink
jbd2: Simplify journal_unmap_buffer()
Browse files Browse the repository at this point in the history
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>
Reviewed-by: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org
Cc: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20190809124233.13277-2-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
  • Loading branch information
Thomas Gleixner authored and Theodore Ts'o committed Oct 21, 2019
1 parent 4f5cafb commit d84560f
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions fs/jbd2/transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -2199,18 +2199,15 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
* 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 */
write_lock(&journal->j_state_lock);
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)
Expand Down Expand Up @@ -2332,7 +2329,6 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
*/
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);
Expand Down

0 comments on commit d84560f

Please sign in to comment.