Skip to content

Commit 3b1833e

Browse files
jankaratytso
authored andcommitted
ext4: annotate data race in start_this_handle()
Access to journal->j_running_transaction is not protected by appropriate lock and thus is racy. We are well aware of that and the code handles the race properly. Just add a comment and data_race() annotation. Cc: [email protected] Reported-by: [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 6810fad commit 3b1833e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

fs/jbd2/transaction.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,12 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
349349
}
350350

351351
alloc_transaction:
352-
if (!journal->j_running_transaction) {
352+
/*
353+
* This check is racy but it is just an optimization of allocating new
354+
* transaction early if there are high chances we'll need it. If we
355+
* guess wrong, we'll retry or free unused transaction.
356+
*/
357+
if (!data_race(journal->j_running_transaction)) {
353358
/*
354359
* If __GFP_FS is not present, then we may be being called from
355360
* inside the fs writeback layer, so we MUST NOT fail.

0 commit comments

Comments
 (0)