All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] jbd2: Fix lockdep splat with generic/270 test
@ 2017-04-11 13:46 Jan Kara
  2017-04-30  0:28 ` Theodore Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2017-04-11 13:46 UTC (permalink / raw)
  To: Ted Tso; +Cc: linux-ext4, Jan Kara

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>
---
 fs/jbd2/journal.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

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)
 {
 	int err = 0;
 
-	jbd2_might_wait_for_commit(journal);
 	read_lock(&journal->j_state_lock);
+#ifdef CONFIG_PROVE_LOCKING
+	/*
+	 * Some callers make sure transaction is already committing and in that
+	 * case we cannot block on open handles anymore. So don't warn in that
+	 * case.
+	 */
+	if (tid_gt(tid, journal->j_commit_sequence) &&
+	    (!journal->j_committing_transaction ||
+	     journal->j_committing_transaction->t_tid != tid)) {
+		read_unlock(&journal->j_state_lock);
+		jbd2_might_wait_for_commit(journal);
+		read_lock(&journal->j_state_lock);
+	}
+#endif
 #ifdef CONFIG_JBD2_DEBUG
 	if (!tid_geq(journal->j_commit_request, tid)) {
 		printk(KERN_ERR
-- 
2.12.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] jbd2: Fix lockdep splat with generic/270 test
  2017-04-11 13:46 [PATCH] jbd2: Fix lockdep splat with generic/270 test Jan Kara
@ 2017-04-30  0:28 ` Theodore Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2017-04-30  0:28 UTC (permalink / raw)
  To: Jan Kara; +Cc: linux-ext4

On Tue, Apr 11, 2017 at 03:46:44PM +0200, Jan Kara wrote:
> 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>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-04-30  0:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-11 13:46 [PATCH] jbd2: Fix lockdep splat with generic/270 test Jan Kara
2017-04-30  0:28 ` Theodore Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.