Skip to content

Commit

Permalink
jbd2: don't read journal->j_commit_sequence without taking a lock
Browse files Browse the repository at this point in the history
Take journal state lock before reading journal->j_commit_sequence.

Signed-off-by: Harshad Shirwadkar <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Theodore Ts'o <[email protected]>
  • Loading branch information
harshadjs authored and tytso committed Nov 7, 2020
1 parent 0ee66dd commit 480f89d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions fs/jbd2/journal.c
Original file line number Diff line number Diff line change
Expand Up @@ -734,10 +734,12 @@ int jbd2_fc_begin_commit(journal_t *journal, tid_t tid)
if (!journal->j_stats.ts_tid)
return -EINVAL;

if (tid <= journal->j_commit_sequence)
write_lock(&journal->j_state_lock);
if (tid <= journal->j_commit_sequence) {
write_unlock(&journal->j_state_lock);
return -EALREADY;
}

write_lock(&journal->j_state_lock);
if (journal->j_flags & JBD2_FULL_COMMIT_ONGOING ||
(journal->j_flags & JBD2_FAST_COMMIT_ONGOING)) {
DEFINE_WAIT(wait);
Expand Down

0 comments on commit 480f89d

Please sign in to comment.