mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-01 10:45:49 +00:00
jbd2: fix assertion failure in jbd2_journal_flush()
commit d7961c7fa4
upstream.
The following race is possible between start_this_handle() and someone
calling jbd2_journal_flush().
Process A Process B
start_this_handle().
if (journal->j_barrier_count) # false
if (!journal->j_running_transaction) { #true
read_unlock(&journal->j_state_lock);
jbd2_journal_lock_updates()
jbd2_journal_flush()
write_lock(&journal->j_state_lock);
if (journal->j_running_transaction) {
# false
... wait for committing trans ...
write_unlock(&journal->j_state_lock);
...
write_lock(&journal->j_state_lock);
if (!journal->j_running_transaction) { # true
jbd2_get_transaction(journal, new_transaction);
write_unlock(&journal->j_state_lock);
goto repeat; # eventually blocks on j_barrier_count > 0
...
J_ASSERT(!journal->j_running_transaction);
# fails
We fix the race by rechecking j_barrier_count after reacquiring j_state_lock
in exclusive mode.
Reported-by: yjwsignal@empal.com
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7b563c7c8d
commit
3a06c3ff07
@ -209,7 +209,8 @@ static int start_this_handle(journal_t *journal, handle_t *handle,
|
||||
if (!new_transaction)
|
||||
goto alloc_transaction;
|
||||
write_lock(&journal->j_state_lock);
|
||||
if (!journal->j_running_transaction) {
|
||||
if (!journal->j_running_transaction &&
|
||||
!journal->j_barrier_count) {
|
||||
jbd2_get_transaction(journal, new_transaction);
|
||||
new_transaction = NULL;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user