Commit 83fe6b18 authored by Jan Kara's avatar Jan Kara Committed by Theodore Ts'o

ext4: annotate data race in jbd2_journal_dirty_metadata()

Assertion checks in jbd2_journal_dirty_metadata() are known to be racy
but we don't want to be grabbing locks just for them.  We thus recheck
them under b_state_lock only if it looks like they would fail. Annotate
the checks with data_race().

Cc: stable@kernel.org
Reported-by: default avatarHao Sun <sunhao.th@gmail.com>
Signed-off-by: default avatarJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20210406161804.20150-2-jack@suse.czSigned-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 3b1833e9
...@@ -1479,8 +1479,8 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) ...@@ -1479,8 +1479,8 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
* crucial to catch bugs so let's do a reliable check until the * crucial to catch bugs so let's do a reliable check until the
* lockless handling is fully proven. * lockless handling is fully proven.
*/ */
if (jh->b_transaction != transaction && if (data_race(jh->b_transaction != transaction &&
jh->b_next_transaction != transaction) { jh->b_next_transaction != transaction)) {
spin_lock(&jh->b_state_lock); spin_lock(&jh->b_state_lock);
J_ASSERT_JH(jh, jh->b_transaction == transaction || J_ASSERT_JH(jh, jh->b_transaction == transaction ||
jh->b_next_transaction == transaction); jh->b_next_transaction == transaction);
...@@ -1488,8 +1488,8 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) ...@@ -1488,8 +1488,8 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
} }
if (jh->b_modified == 1) { if (jh->b_modified == 1) {
/* If it's in our transaction it must be in BJ_Metadata list. */ /* If it's in our transaction it must be in BJ_Metadata list. */
if (jh->b_transaction == transaction && if (data_race(jh->b_transaction == transaction &&
jh->b_jlist != BJ_Metadata) { jh->b_jlist != BJ_Metadata)) {
spin_lock(&jh->b_state_lock); spin_lock(&jh->b_state_lock);
if (jh->b_transaction == transaction && if (jh->b_transaction == transaction &&
jh->b_jlist != BJ_Metadata) jh->b_jlist != BJ_Metadata)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment