From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DC4FC43381 for ; Fri, 22 Mar 2019 00:42:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 65C0021902 for ; Fri, 22 Mar 2019 00:42:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727207AbfCVAmd (ORCPT ); Thu, 21 Mar 2019 20:42:33 -0400 Received: from fieldses.org ([173.255.197.46]:51816 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727047AbfCVAmd (ORCPT ); Thu, 21 Mar 2019 20:42:33 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 537F41CEA; Thu, 21 Mar 2019 20:42:33 -0400 (EDT) Date: Thu, 21 Mar 2019 20:42:33 -0400 From: "J. Bruce Fields" To: Jeff Layton Cc: linux-fsdevel@vger.kernel.org, neilb@suse.com, asn@redhat.com Subject: Re: [PATCH] locks: ignore same lock in blocked_lock_hash Message-ID: <20190322004233.GA28329@fieldses.org> References: <20190321112744.7832-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190321112744.7832-1-jlayton@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Thu, Mar 21, 2019 at 07:27:44AM -0400, Jeff Layton wrote: > 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. > > If posix_locks_deadlock() fails to find a deadlock, the caller_fl > will be passed to __locks_insert_block(), and this wakes up all > locks that are blocked on caller_fl, clearing the fl_blocker link. > > So if posix_locks_deadlock() finds caller_fl while searching for > a deadlock, I'm feeling dense. Could you step me through the scenario in a little more detail? Also, how do we know this catches every such case? And why aren't we unhashing blocks when we wake them up? --b. > it can be sure that link in the cycle is about to be > broken and it need not treat it as the cause of a deadlock. > > More details here: https://bugzilla.kernel.org/show_bug.cgi?id=202975 > > Cc: stable@vger.kernel.org > Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other requests.") > Reported-by: Andreas Schneider > Signed-off-by: Neil Brown > Signed-off-by: Jeff Layton > --- > fs/locks.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index eaa1cfaf73b0..b074f6d7fd2d 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -1023,6 +1023,10 @@ static int posix_locks_deadlock(struct file_lock *caller_fl, > while ((block_fl = what_owner_is_waiting_for(block_fl))) { > if (i++ > MAX_DEADLK_ITERATIONS) > return 0; > + > + if (caller_fl == block_fl) > + return 0; > + > if (posix_same_owner(caller_fl, block_fl)) > return 1; > } > -- > 2.20.1