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 8DF84C43381 for ; Mon, 25 Mar 2019 22:33:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6693D2082F for ; Mon, 25 Mar 2019 22:33:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730479AbfCYWd5 (ORCPT ); Mon, 25 Mar 2019 18:33:57 -0400 Received: from mx2.suse.de ([195.135.220.15]:45846 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729548AbfCYWd5 (ORCPT ); Mon, 25 Mar 2019 18:33:57 -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 5F4DDAFE7; Mon, 25 Mar 2019 22:33:56 +0000 (UTC) From: NeilBrown To: Jeff Layton , linux-fsdevel@vger.kernel.org Date: Tue, 26 Mar 2019 09:33:47 +1100 Cc: bfields@fieldses.org, asn@redhat.com Subject: Re: [PATCH v3] locks: wake any locks blocked on request before deadlock check In-Reply-To: <20190325123252.10211-1-jlayton@kernel.org> References: <20190325123252.10211-1-jlayton@kernel.org> Message-ID: <87k1gm4m9g.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 Mon, Mar 25 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. > > 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=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 Yes, I'm happy with this patch and description. It is more "obviously correct" than the other patch. Thanks, NeilBrown > --- > fs/locks.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index eaa1cfaf73b0..71d0c6c2aac5 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -1160,6 +1160,11 @@ static int posix_lock_inode(struct inode *inode, s= truct file_lock *request, > */ > error =3D -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 =3D FILE_LOCK_DEFERRED; > __locks_insert_block(fl, request, > --=20 > 2.20.1 --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAlyZV0wACgkQOeye3VZi gbmJ/A/8DPpfn3AQ34rMslAaNjWjNoLTnadB7OjN18pYVvTYPcGjmhuVUbFPrweT reE4cWezRFx11olMmvBQCtFbY7FzIZcikImtjG3RcLe9EjrUIRNcFDX1ytJkHJ1O GQDYl/bNptZ2mUAjbb/cwjNPQpJUuEzhllnpWxW3RkR/G8O2XIO1SmcHip1QLMOF Mo7GOMUtd7e7OAlBlcbmAxm89i06gpL5PaVdjdZGqfnAOQXWv+YLkZg9wGf1740/ jOWvA+gH2dIOoc3jtX9dmN4xx/vrJ+C9RTHkU3q/F5lByjv/N/UBEwWaCUIjLBDe ph5t4Fxk+SOuOlZA+RNLkUA4vhwQdOaG2lmJlSE6R+VPS5I1Z/tvEeB3rogEEbPa eSOyIHMMMJRzPaY5BFhivftHPQL7915PSpPA+Wt3rwPNCVkz8wn0vS/mfVKL7Cz+ s59V1jebK6P5zmMvR9EKW/C18QGpBZXtBIVRBcsQNERGyIvNZ0yzNI/Gfes0M15A X2rnKH92hVmqnKAzpgvJULCxftXoDv/uRn7N+Oa5luQbdDm5bFhiWDyOCeBsLpS7 KDS3pES3VFsq1agahCpMvSDLJl2fW5zhmhkJYKCiR7VsiJbVBJYYi4Yzz2kjMFGU ZeaLEik/fQtgNEiOAnhA+4CA3C/2dl74RAtcqDo+DxEFoAI2zKk= =zRu8 -----END PGP SIGNATURE----- --=-=-=--