Skip to content

Commit d84560f

Browse files
KAGA-KOKOtytso
authored andcommitted
jbd2: Simplify journal_unmap_buffer()
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>
1 parent 4f5cafb commit d84560f

1 file changed

Lines changed: 2 additions & 6 deletions

File tree

‎fs/jbd2/transaction.c‎

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2199,18 +2199,15 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
21992199
* holding the page lock. --sct
22002200
*/
22012201

2202-
if (!buffer_jbd(bh))
2202+
jh = jbd2_journal_grab_journal_head(bh);
2203+
if (!jh)
22032204
goto zap_buffer_unlocked;
22042205

22052206
/* OK, we have data buffer in journaled mode */
22062207
write_lock(&journal->j_state_lock);
22072208
jbd_lock_bh_state(bh);
22082209
spin_lock(&journal->j_list_lock);
22092210

2210-
jh = jbd2_journal_grab_journal_head(bh);
2211-
if (!jh)
2212-
goto zap_buffer_no_jh;
2213-
22142211
/*
22152212
* We cannot remove the buffer from checkpoint lists until the
22162213
* transaction adding inode to orphan list (let's call it T)
@@ -2332,7 +2329,6 @@ static int journal_unmap_buffer(journal_t *journal, struct buffer_head *bh,
23322329
*/
23332330
jh->b_modified = 0;
23342331
jbd2_journal_put_journal_head(jh);
2335-
zap_buffer_no_jh:
23362332
spin_unlock(&journal->j_list_lock);
23372333
jbd_unlock_bh_state(bh);
23382334
write_unlock(&journal->j_state_lock);

0 commit comments

Comments
 (0)