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=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS 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 EF15AC43381 for ; Thu, 21 Mar 2019 21:51:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C449521917 for ; Thu, 21 Mar 2019 21:51:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726835AbfCUVvf (ORCPT ); Thu, 21 Mar 2019 17:51:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:60564 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725999AbfCUVvf (ORCPT ); Thu, 21 Mar 2019 17:51:35 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id E5259AFA5; Thu, 21 Mar 2019 21:51:33 +0000 (UTC) From: NeilBrown To: Jeff Layton , linux-fsdevel@vger.kernel.org Date: Fri, 22 Mar 2019 08:51:27 +1100 Cc: bfields@fieldses.org, asn@redhat.com Subject: Re: [PATCH] locks: ignore same lock in blocked_lock_hash In-Reply-To: <20190321112744.7832-1-jlayton@kernel.org> References: <20190321112744.7832-1-jlayton@kernel.org> Message-ID: <87a7hn7v6o.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: quoted-printable On Thu, Mar 21 2019, 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, 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=3D202975 There is a weak pattern of using URL: https://bugzilla.kernel.org/show_bug.cgi?id=3D202975 > > Cc: stable@vger.kernel.org > Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other reque= sts.") > 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 =3D what_owner_is_waiting_for(block_fl))) { > if (i++ > MAX_DEADLK_ITERATIONS) > return 0; > + > + if (caller_fl =3D=3D block_fl) > + return 0; > + I would always write this with the value being tested first, and the value it is being tested against second (and yes, I know that equality is mathematically symmetric). if (block_fl =3D=3D caller_fl) return 0; But .... whatever. At least your ordering matches the posix_same_owner() below, and consistency is a good thing too. Thanks, NeilBrown > if (posix_same_owner(caller_fl, block_fl)) > return 1; > } > --=20 > 2.20.1 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlyUB18ACgkQOeye3VZi gbn6bhAAgS6aI1mpBTq3kUjCmKRm1DWVCkdjovJppDquHQey3tLuamIaMx5kFqyF blLfPF+7P/remRhVN3Cv+MdzlYEgBshHOw9Poa4upbtiIqP0lAKRfLNFEfKfb/m2 JyJle9BQbNYaVEbDqZHcZ7sbvR982szyZ608GbzjGsrxV7uEbgyeKjRcceEVgNu7 cGTseUtw/o/3/iafm6Hl4DrBveDemwTlkx1PC58LnBYGsIfXKgFJuheNWKNts4yN lp6bJdkH8dH+pkXGb55GUiKFVZdHHnaawAmtSwgoDYxB7/z43gbtZX6b6yaDZGcB 2Bu2HIgvtxevX46evAHWhnOI654FbPssuoMxFGsDSa92kozjdRCx+YSj6qQRAwrH EjvQyU5c6XPuUVZfKc2ioOGUhbEInX6hr8Cwjnx+juZ3zcEzvsGKILNaNipIzZhm Ves749/7y0eGZmQAfgWN5vsweWWN91KL19ErIgSQWyFTz5egoLj1uOUB0ZjhZ21f Aaw4H1ajtLPwngK959MtG4/Go1wCsZV7XQBVjLap/l5AcWtyrt53HT/xEMBcdixu mCxzM75k9agrBcFkp8WcmmaGqLONIqG6OStUoU8zYo/mIg3qQcXHx99JvlKBsa1h 3S/hgyQFclwJzg/LfrTb3ZQXUjAZeZX4ZqS7nKrbvjsnvuRbraE= =8Hut -----END PGP SIGNATURE----- --=-=-=--