diff options
author | Jan Kara <jack@suse.cz> | 2017-04-29 20:12:16 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2017-04-29 20:12:16 -0400 |
commit | c52c47e4b4fbe4284602fc2ccbfc4a4d8dc05b49 (patch) | |
tree | 4b61b1a2c7c8ff64679d49c191149fcadfb78176 | |
parent | 80a2ea9f85850f1cdae814be03b4a16c3d3abc00 (diff) |
jbd2: Fix lockdep splat with generic/270 test
I've hit a lockdep splat with generic/270 test complaining that:
3216.fsstress.b/3533 is trying to acquire lock:
(jbd2_handle){++++..}, at: [<ffffffff813152e0>] jbd2_log_wait_commit+0x0/0x150
but task is already holding lock:
(jbd2_handle){++++..}, at: [<ffffffff8130bd3b>] start_this_handle+0x35b/0x850
The underlying problem is that jbd2_journal_force_commit_nested()
(called from ext4_should_retry_alloc()) may get called while a
transaction handle is started. In such case it takes care to not wait
for commit of the running transaction (which would deadlock) but only
for a commit of a transaction that is already committing (which is safe
as that doesn't wait for any filesystem locks).
In fact there are also other callers of jbd2_log_wait_commit() that take
care to pass tid of a transaction that is already committing and for
those cases, the lockdep instrumentation is too restrictive and leading
to false positive reports. Fix the problem by calling
jbd2_might_wait_for_commit() from jbd2_log_wait_commit() only if the
transaction isn't already committing.
Fixes: 1eaa566d368b214d99cbb973647c1b0b8102a9ae
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
-rw-r--r-- | fs/jbd2/journal.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/fs/jbd2/journal.c b/fs/jbd2/journal.c index 5adc2fb62b0f..9410ec462ba6 100644 --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c | |||
@@ -691,8 +691,21 @@ int jbd2_log_wait_commit(journal_t *journal, tid_t tid) | |||
691 | { | 691 | { |
692 | int err = 0; | 692 | int err = 0; |
693 | 693 | ||
694 | jbd2_might_wait_for_commit(journal); | ||
695 | read_lock(&journal->j_state_lock); | 694 | read_lock(&journal->j_state_lock); |
695 | #ifdef CONFIG_PROVE_LOCKING | ||
696 | /* | ||
697 | * Some callers make sure transaction is already committing and in that | ||
698 | * case we cannot block on open handles anymore. So don't warn in that | ||
699 | * case. | ||
700 | */ | ||
701 | if (tid_gt(tid, journal->j_commit_sequence) && | ||
702 | (!journal->j_committing_transaction || | ||
703 | journal->j_committing_transaction->t_tid != tid)) { | ||
704 | read_unlock(&journal->j_state_lock); | ||
705 | jbd2_might_wait_for_commit(journal); | ||
706 | read_lock(&journal->j_state_lock); | ||
707 | } | ||
708 | #endif | ||
696 | #ifdef CONFIG_JBD2_DEBUG | 709 | #ifdef CONFIG_JBD2_DEBUG |
697 | if (!tid_geq(journal->j_commit_request, tid)) { | 710 | if (!tid_geq(journal->j_commit_request, tid)) { |
698 | printk(KERN_ERR | 711 | printk(KERN_ERR |