Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7056783ybi; Thu, 13 Jun 2019 08:51:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzS71IMd/MeU4KcWedp90m4g0XXAZCVRL7j0p1p68F+YkPMxdMCo4ezR/6TGdDgg/4fwxw5 X-Received: by 2002:a17:90a:ac0e:: with SMTP id o14mr6387152pjq.142.1560441069038; Thu, 13 Jun 2019 08:51:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560441069; cv=none; d=google.com; s=arc-20160816; b=pCVvbb5F4QhbD8Q6oHgR36rl2pT9Lp9ElsbL0TTCbRuk2iDA5dx6XVYx/soR0XsW8f 9HbVKy+rzcGMJUB1QyWJr53z04WQcmifR0IC9ow139lqSsSUYowNQCpXpvb1PPjA6R3j DcNGl2imj5QsFFM9FpkTZj1iBqZ/aKa97ptM7V/nToCplH30FZUdecfHWMfWxPM87s6p OGhNoeJUgF9iDskuqlpXo7MDQvgOuKLjaZTwSXVZvwVVidiqemCrBxF3hUD8AEid/XUM LALV7fmpPONJY3VwHHO8O6912267RkqFd0cvKnIeWICC7l3WM3mYimbohwBJrpowH4cf 23FQ== 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:date:cc:to:from:subject :message-id:dkim-signature; bh=+Ozh0T9zeUsCbE3n47TLBSj2nTaqmNwRJ9tVdIf7rAw=; b=xqy3cAeec1Zqu8okdw76Slk0f8MXiMK227eUkUrQUdBStGF9t1wWv3KMn4sr/Kpt3P JmWrS3hl9lJ5NtHSmxBcmI+0DfM4NaKUG3fyMbWdi29yGAsvAmEv4FSiMQIO5GuphHgp JXKdn0xdeS3KswLu584dN82Dw4pcVdv6T59hAOAXpy7sDkGa9fhdQJ/R6gICncyiXm9m XB94dnbIC8fjjCHGaQCVHwvcRK6Sts1+slAycygfQgROvhpRbUshJRC9NCDYV91g68GM 0Dg7jnZWWYmKdLSFIJ+WSSZ34CSchHBkULGEDQ60o6u4woyKzEnXtFBdnPrlXjBQtU2z Jljg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m1kNRddd; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c14si33605pjr.51.2019.06.13.08.50.54; Thu, 13 Jun 2019 08:51:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-nfs-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=m1kNRddd; spf=pass (google.com: best guess record for domain of linux-nfs-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389876AbfFMPuR (ORCPT + 99 others); Thu, 13 Jun 2019 11:50:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:45092 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389867AbfFMPuQ (ORCPT ); Thu, 13 Jun 2019 11:50:16 -0400 Received: from tleilax.poochiereds.net (cpe-71-70-156-158.nc.res.rr.com [71.70.156.158]) (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 E98FD20851; Thu, 13 Jun 2019 15:50:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560441015; bh=K2TNgrw4R37jC2wvNP4NHp0ffDkAz0bEuDOQ1i8V7ek=; h=Subject:From:To:Cc:Date:In-Reply-To:References:From; b=m1kNRdddxbXGayevadF9jfE0nvRRBTCCggZjBzxfXcycF0EMw3iRJ551T4Yw7KW/w mLWKjnyjUKybN1jKLgWu4/8ThKtiCTZoHUt70uCgNYwQHVZ8ajxtXsZ8R/o9hCJusV tRasdxZsU1hEz3yaRkBUWXpDOg3GlUhaHnp14Tgg= Message-ID: Subject: Re: [PATCH v2] locks: eliminate false positive conflicts for write lease From: Jeff Layton To: Amir Goldstein , "J . Bruce Fields" Cc: Miklos Szeredi , linux-fsdevel , Linux NFS list , overlayfs Date: Thu, 13 Jun 2019 11:50:13 -0400 In-Reply-To: References: <20190612172408.22671-1-amir73il@gmail.com> <20190612183156.GA27576@fieldses.org> <20190613143151.GC2145@fieldses.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.32.2 (3.32.2-1.fc30) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Thu, 2019-06-13 at 18:47 +0300, Amir Goldstein wrote: > On Thu, Jun 13, 2019 at 5:32 PM J . Bruce Fields wrote: > > On Thu, Jun 13, 2019 at 04:13:15PM +0200, Miklos Szeredi wrote: > > > On Wed, Jun 12, 2019 at 8:31 PM J . Bruce Fields wrote: > > > > How do opens for execute work? I guess they create a struct file with > > > > FMODE_EXEC and FMODE_RDONLY set and they decrement i_writecount. Do > > > > they also increment i_readcount? Reading do_open_execat and alloc_file, > > > > looks like it does, so, good, they should conflict with write leases, > > > > which sounds right. > > > > > > Right, but then why this: > > > > > > > > + /* Eliminate deny writes from actual writers count */ > > > > > + if (wcount < 0) > > > > > + wcount = 0; > > > > > > It's basically a no-op, as you say. And it doesn't make any sense > > > logically, since denying writes *should* deny write leases as well... > > > > Yes. I feel like the negative writecount case is a little nonobvious, > > so maybe replace that by a comment, something like this?: > > > > --b. > > > > diff --git a/fs/locks.c b/fs/locks.c > > index 2056595751e8..379829b913c1 100644 > > --- a/fs/locks.c > > +++ b/fs/locks.c > > @@ -1772,11 +1772,12 @@ check_conflicting_open(struct file *filp, const long arg, int flags) > > if (arg == F_RDLCK && wcount > 0) > > return -EAGAIN; > > > > - /* Eliminate deny writes from actual writers count */ > > - if (wcount < 0) > > - wcount = 0; > > - > > - /* Make sure that only read/write count is from lease requestor */ > > + /* > > + * Make sure that only read/write count is from lease requestor. > > + * Note that this will result in denying write leases when wcount > > + * is negative, which is what we want. (We shouldn't grant > > + * write leases on files open for execution.) > > + */ > > if (filp->f_mode & FMODE_WRITE) > > self_wcount = 1; > > else if (filp->f_mode & FMODE_READ) > > I'm fine with targeting 5.3 and I'm fine with all suggested changes > and adding some of my own. At this point we no longer need wcount > variable and code becomes more readable without it. > See attached patch (also tested). > > Thanks, > Amir. Thanks Amir. In that case, I'll go ahead and pick this up for v5.3, and will get it into linux-next soon. Thanks, -- Jeff Layton