Skip to content

Commit 83fe6b1

Browse files
jankaratytso
authored andcommitted
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: [email protected] Reported-by: Hao Sun <[email protected]> Signed-off-by: Jan Kara <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Theodore Ts'o <[email protected]>
1 parent 3b1833e commit 83fe6b1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

fs/jbd2/transaction.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1479,17 +1479,17 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh)
14791479
* crucial to catch bugs so let's do a reliable check until the
14801480
* lockless handling is fully proven.
14811481
*/
1482-
if (jh->b_transaction != transaction &&
1483-
jh->b_next_transaction != transaction) {
1482+
if (data_race(jh->b_transaction != transaction &&
1483+
jh->b_next_transaction != transaction)) {
14841484
spin_lock(&jh->b_state_lock);
14851485
J_ASSERT_JH(jh, jh->b_transaction == transaction ||
14861486
jh->b_next_transaction == transaction);
14871487
spin_unlock(&jh->b_state_lock);
14881488
}
14891489
if (jh->b_modified == 1) {
14901490
/* If it's in our transaction it must be in BJ_Metadata list. */
1491-
if (jh->b_transaction == transaction &&
1492-
jh->b_jlist != BJ_Metadata) {
1491+
if (data_race(jh->b_transaction == transaction &&
1492+
jh->b_jlist != BJ_Metadata)) {
14931493
spin_lock(&jh->b_state_lock);
14941494
if (jh->b_transaction == transaction &&
14951495
jh->b_jlist != BJ_Metadata)

0 commit comments

Comments
 (0)