提交 a2fcd456 编写于 作者: J Jan Kara 提交者: Yang Yingliang

jbd2: Don't call __bforget() unnecessarily

mainline inclusion
from mainline-5.5-rc1
commit 2e710ff0
category: bugfix
bugzilla: 176007
CVE: NA
---------------------------

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

Conflicts:
	fs/jbd2/transaction.c
Signed-off-by: Nyangerkun <yangerkun@huawei.com>
Reviewed-by: NZhang Yi <yi.zhang@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 f882f126
......@@ -1591,7 +1591,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 */
......@@ -1680,7 +1680,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;
}
/*
......@@ -1690,7 +1690,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;
}
/*
......@@ -1703,10 +1703,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_total_credits++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册