Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

jbd2: Don't call __bforget() unnecessarily

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>
Link: https://lore.kernel.org/r/20190809124233.13277-6-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

authored by

Jan Kara and committed by
Theodore Ts'o
2e710ff0 6d69843e

+4 -5
+4 -5
fs/jbd2/transaction.c
··· 1550 1550 if (!J_EXPECT_JH(jh, !jh->b_committed_data, 1551 1551 "inconsistent data on disk")) { 1552 1552 err = -EIO; 1553 - goto not_jbd; 1553 + goto drop; 1554 1554 } 1555 1555 1556 1556 /* keep track of whether or not this transaction modified us */ ··· 1640 1640 if (!jh->b_cp_transaction) { 1641 1641 JBUFFER_TRACE(jh, "belongs to none transaction"); 1642 1642 spin_unlock(&journal->j_list_lock); 1643 - goto not_jbd; 1643 + goto drop; 1644 1644 } 1645 1645 1646 1646 /* ··· 1650 1650 if (!buffer_dirty(bh)) { 1651 1651 __jbd2_journal_remove_checkpoint(jh); 1652 1652 spin_unlock(&journal->j_list_lock); 1653 - goto not_jbd; 1653 + goto drop; 1654 1654 } 1655 1655 1656 1656 /* ··· 1663 1663 __jbd2_journal_file_buffer(jh, transaction, BJ_Forget); 1664 1664 spin_unlock(&journal->j_list_lock); 1665 1665 } 1666 - 1666 + drop: 1667 1667 jbd_unlock_bh_state(bh); 1668 1668 __brelse(bh); 1669 - drop: 1670 1669 if (drop_reserve) { 1671 1670 /* no need to reserve log space for this block -bzzz */ 1672 1671 handle->h_buffer_credits++;