Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp481055yba; Mon, 1 Apr 2019 10:09:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZh7WM1CjrXinN0hOg2QmYJ+qpG7Crf26WdIOboNFXkm4m33vaZMoYe0hMj/dsotZ/OtwL X-Received: by 2002:a62:4553:: with SMTP id s80mr62895786pfa.141.1554138568171; Mon, 01 Apr 2019 10:09:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554138568; cv=none; d=google.com; s=arc-20160816; b=u1Ta868sol+i7x6Dg5hTdr5YTRQ6eNceCy/1n/oR6nhRCgUrDupSel1fLy5mTuXl5A dv0jE/QdrobpumVH4msQ6SAhH947Z3uG5vZ9ws5G6KSgY8fEZMTzymbS+/iv3fJvx3zI XOxsQiI1CDwsl17ibyyiS+davLWX/0UGJh4dWVpERy6NrEDECS/U5y+jvV5WxGkI5A9H WIdI+0S/1ATr9c/O7D7s/iEHFpFqFUhMLTI4jHXXb3D/iOe8BLhFSDYefExqQBjfMYlU R8V7eygFhBvWuh45xZqr6gZ4FxM/0OGgaIwcSRvMyZWojZVj0Pk9lYZ6nS3Lx7napxMd iZWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=B+A+mNOUlTRdCn2cMcp84OdR2MrtlcDmbuxCDnyBMJQ=; b=Q2zzVnllw15Cr5Z76BGy7pfbvKsi0FjOG0U2Nzj0JPdg+HEdKO5nNCG+nzSMthKVTw Fx4LK32DGXW+0gQ6An7Ucy+arx0yElRSycXGZVzrqeze8JtOA3hWJAdlHgS7rksCNMba L23dPnxfUHazxmcComK5sK9yi5kv4aWdrVpbL2bU2/qDqZiDIsRITDm3A8hVAYsjnP5b aPL/mAK6bIf2V1SV/Tnn91wtUbdqLS+zUwLsy49gzNLjKojYH20K7bmbbyfbyRCbb/Qn emPnwLRvS+QLto1y+/ttyH6pqZVPVgkP8Y9FwuXvRINldIZLSPYY7wmha437PVgnNhb+ Hhkw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dcQcuLt8; 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 q1si9375754pfb.68.2019.04.01.10.09.13; Mon, 01 Apr 2019 10:09:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=dcQcuLt8; 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 S1729532AbfDARHp (ORCPT + 99 others); Mon, 1 Apr 2019 13:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:53954 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729511AbfDARHk (ORCPT ); Mon, 1 Apr 2019 13:07:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1102321934; Mon, 1 Apr 2019 17:07:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1554138459; bh=us4Nj+9dtFwj9PlRB3x0nW0aBqmZvsSlbgRM/Pbvgyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dcQcuLt801kEZSHTPDU2ZihWY8SSvGGoooQd6FB8WNnxahTwIFfemHQW/NALhDzat EXZaiW0nu2aTDitqx6ugSzSKZpZIV1rrH4nEzEEoOHgdoUMiSrriwcfHsxoG1jcm+A dwU5BZxmtzoZULsAEbz2AYibYBHo/qlzCO9m2udU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andreas Schneider , Neil Brown , Jeff Layton Subject: [PATCH 5.0 045/146] locks: wake any locks blocked on request before deadlock check Date: Mon, 1 Apr 2019 19:00:57 +0200 Message-Id: <20190401170052.385151385@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190401170048.449559024@linuxfoundation.org> References: <20190401170048.449559024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 5.0-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Layton commit 945ab8f6de94430c23a82f3cf2e3f6d6f2945ff7 upstream. Andreas reported that he was seeing the tdbtorture test fail in some cases with -EDEADLCK when it wasn't before. Some debugging showed that deadlock detection was sometimes discovering the caller's lock request itself in a dependency chain. While we remove the request from the blocked_lock_hash prior to reattempting to acquire it, any locks that are blocked on that request will still be present in the hash and will still have their fl_blocker pointer set to the current request. This causes posix_locks_deadlock to find a deadlock dependency chain when it shouldn't, as a lock request cannot block itself. We are going to end up waking all of those blocked locks anyway when we go to reinsert the request back into the blocked_lock_hash, so just do it prior to checking for deadlocks. This ensures that any lock blocked on the current request will no longer be part of any blocked request chain. URL: https://bugzilla.kernel.org/show_bug.cgi?id=202975 Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other requests.") Cc: stable@vger.kernel.org Reported-by: Andreas Schneider Signed-off-by: Neil Brown Signed-off-by: Jeff Layton Signed-off-by: Greg Kroah-Hartman --- fs/locks.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/fs/locks.c +++ b/fs/locks.c @@ -1160,6 +1160,11 @@ static int posix_lock_inode(struct inode */ error = -EDEADLK; spin_lock(&blocked_lock_lock); + /* + * Ensure that we don't find any locks blocked on this + * request during deadlock detection. + */ + __locks_wake_up_blocks(request); if (likely(!posix_locks_deadlock(request, fl))) { error = FILE_LOCK_DEFERRED; __locks_insert_block(fl, request,