Received: by 10.213.65.68 with SMTP id h4csp268660imn; Fri, 23 Mar 2018 04:21:11 -0700 (PDT) X-Google-Smtp-Source: AG47ELvZZ4dJNyqaThMVsXMnbb4Yv+XSvZJfe7FxntCWZDVi3H/U5NPt3agua09uh+5cjPRSthuj X-Received: by 10.101.98.85 with SMTP id q21mr20182700pgv.182.1521804071843; Fri, 23 Mar 2018 04:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521804071; cv=none; d=google.com; s=arc-20160816; b=HoRB9r2YTBMxvxmP5FpAnVWDJdAnntLqP9hKQcGKH6QefLB3fZwfYAI0n9i0KH0zs8 ylJ9FPN/H+XEOYEUR7wgZtgEGInoLPDLzbCYvmm33i4UKUJ0+oPd8AQaKk4gDPRZgj/n wrJYQc02Z+GPvkCrHtL246MfbPCZM0CulhfFSHpjiqHjz0Wq6KKeO0RGpXV/qFJWna3b JgwC5JMSrbIWJ8C5bY/XJOjlJj0vYaghVOsFArfoMP/90EAndD9wRikM1X0P1+5MaQqw IEWoWffsbDfYIjcYgClFQRBV9Udt25U3DwNARc4Ftu7NxK/rnqrqRc6aqFyoo+e+N6qI 5yMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Wx7OKly+DH7y3OSMPpKpvUF9BJmTth0sQqsstP6uAnM=; b=dDXC6fNNUGdGDb553uQsBUE/82ktn59y5sIQwYu7HVmy1tuffKzEAQK3Rge+G/l9V8 ubp0fzghW12eM4i1/+ueZ739SKIjTM5m3Rgkl4LAkbKov7BIn5OrpEX52RSZOXqXvhB1 pTYOsErXuObRKQkAVCtqpOyQTjCrw2vqo9g++ue8WI/s6/AhBUwcL+zwNVkcVoaey8WM oiaLqGh9QspxCvFiJoEpVkmwn2tFfPnfs4f+fl1V89zFM1iLstbqNqDoz8uFge6xImv0 2oTJrqb8wK3TH0Fh9+qJ18viA++sDLI/4wmZUcWHG/4xgDzjYBahU6PNio2RNQEji5Ux /cpQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t23-v6si8564394plo.637.2018.03.23.04.20.57; Fri, 23 Mar 2018 04:21:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755622AbeCWKIr (ORCPT + 99 others); Fri, 23 Mar 2018 06:08:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41786 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755601AbeCWKIm (ORCPT ); Fri, 23 Mar 2018 06:08:42 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 8C831E8B; Fri, 23 Mar 2018 10:08:41 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jan Kara , Theodore Tso , Sasha Levin Subject: [PATCH 4.9 102/177] jbd2: Fix lockdep splat with generic/270 test Date: Fri, 23 Mar 2018 10:53:50 +0100 Message-Id: <20180323094209.786100619@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094205.090519271@linuxfoundation.org> References: <20180323094205.090519271@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jan Kara [ Upstream commit c52c47e4b4fbe4284602fc2ccbfc4a4d8dc05b49 ] I've hit a lockdep splat with generic/270 test complaining that: 3216.fsstress.b/3533 is trying to acquire lock: (jbd2_handle){++++..}, at: [] jbd2_log_wait_commit+0x0/0x150 but task is already holding lock: (jbd2_handle){++++..}, at: [] 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 Signed-off-by: Theodore Ts'o Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- fs/jbd2/journal.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) --- a/fs/jbd2/journal.c +++ b/fs/jbd2/journal.c @@ -691,8 +691,21 @@ int jbd2_log_wait_commit(journal_t *jour { 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