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 0438FC10F05 for ; Sun, 24 Mar 2019 00:51:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CF7FF21841 for ; Sun, 24 Mar 2019 00:51:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727736AbfCXAvb (ORCPT ); Sat, 23 Mar 2019 20:51:31 -0400 Received: from mx2.suse.de ([195.135.220.15]:40960 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727628AbfCXAvb (ORCPT ); Sat, 23 Mar 2019 20:51:31 -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 7DDA2AD0C; Sun, 24 Mar 2019 00:51:29 +0000 (UTC) From: NeilBrown To: Jeff Layton , linux-fsdevel@vger.kernel.org Date: Sun, 24 Mar 2019 11:51:20 +1100 Cc: bfields@fieldses.org, asn@redhat.com Subject: Re: [PATCH v2] locks: ignore same lock in blocked_lock_hash In-Reply-To: <20190323120832.28123-1-jlayton@kernel.org> References: <20190322202751.GB10961@fieldses.org> <20190323120832.28123-1-jlayton@kernel.org> Message-ID: <878sx55c3b.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 The patch title locks: ignore same lock in blocked_lock_hash is a bit misleading the lock isn't in the hash, but it is linked from something that is. Maybe locks: ignore same lock in posix_locks_deadlock() ?? On Sat, Mar 23 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. > > URL: https://bugzilla.kernel.org/show_bug.cgi?id=3D202975 > Fixes: 5946c4319ebb ("fs/locks: allow a lock request to block other reque= sts.") > Cc: stable@vger.kernel.org > Reported-by: Andreas Schneider > Signed-off-by: Neil Brown > Signed-off-by: Jeff Layton > --- > fs/locks.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index eaa1cfaf73b0..a939a274dc71 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -1023,6 +1023,19 @@ 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; > + > + /* > + * It's possible that we're retrying this lock request after > + * another task is has blocked on it. A lock request can't > + * block itself, and any locks that are blocked on it will > + * also be awoken soon (and have their fl_blocker pointer > + * cleared). Any dependency chain that contains the request > + * itself is therefore about to be broken, so we can safely > + * ignore it. That first sentence isn't working for me .... maybe remove the "is" ?? Thanks, NeilBrown > + */ > + if (block_fl =3D=3D caller_fl) > + return 0; > + > 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----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlyW1IgACgkQOeye3VZi gbmyoxAAk046c0Fp+M+mn6iJHOZBWquMtMBbzHN+Y57FMuy3/u+HFsRjE+oAt/Fh MbfraSRJ7V7QxtwGEFydhHdJMGEkfCxvfUGEbsaMtW6bhfcmOWAtP6htlwwHqXRv rEGChdPfIlAPz2Vp/NtcP1MJdrTFJ1vI1hHkwbrL1QQ42wuYjAGWYZ00wiUXlR71 jqfa7ryACJzjvKKpnQsFwJKZcDz6znYaFLDL+NqkoQcd9i+Xe8k+ybhX6+gSSk23 GL3THgWCzcuhnvKEqdAtiO5H352DIJzgUIT9yEhNux2/IfVdHSz4lcS+CY7Dymzz vv0Qu4hP8cMlUJUwTlPCDD0JdM3c8mpeRHd90OtR812yHC6ffA6sOxg6fGyBuvLM u+jmcaykwCSmLysoD6/aHfNCffH7XmLv0OikgekBqqf2BaQXjncZOxpts/IDdHUN HEUToTjexW6NpCMAsiZ/T2/EnQP9bgWIlxX65HHEZMZXtl9w38Wpt/plqruYswRe EfiibpTi0N2AwTMO6f87Tf/I5cwKBKo+l1PbSHrRedO4uUvEgkwBncaqsBP7BSYY 4G7h6U2wngbJjK+lGeiU03p+3PuaDfLNFKkt8Bqt/mjc7c6p/yyY7K0I38VzbSGd 9hdezOCGIaSH0vJKEbFa4ZXMrBDqcs8ZOC5uVEyf27gU3zMAb9c= =nxG+ -----END PGP SIGNATURE----- --=-=-=--