Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp7006811ybi; Thu, 13 Jun 2019 08:03:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqy7eV8/5SYneMlGmX/cNPLIDcwww+PPk6a3Tcz7uFLtU/KGBzlrHQ3vxznfFqlINOisyqiM X-Received: by 2002:a63:e24c:: with SMTP id y12mr31008203pgj.276.1560438229785; Thu, 13 Jun 2019 08:03:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560438229; cv=none; d=google.com; s=arc-20160816; b=Kw0RfU1i+ueOLuqrjPoL00csNkrQF2mdR5dydfpzrUnMuZKAZI1IJyArxqrdZ9FgPM aMKCMB7X0QuOjH0TUtU4Lhwzhan3prB85GLZQ/S3FnXgWcUky/JeWKKT58hH17dc6SBF BcW1xuXgMCRrdE4ndp7TKUFGZMrISlJIcVAr227ap9pPi9UuB9vGN9n9SdMJiXGW6GI2 +4oj5ABK8+vtL0haVNHLCdUb788TG4jfoB4pMMfuIhJcIwfkmuDFb4hG9gAGkT/UQLKh q00x6i/VRRVuMmQ8tetsERPlaaROlCDqoqjvigE3qkPaFSxaagcYKTUBpNxhrHSaHWQh IbzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=rAcjR0pqPdG5Us0NbXDDnNaxX9+juuDY3Rw9/QdD/Kc=; b=cJUsjS4aZCbJd7q8ScC17BKwsAKXRWvfRPH/p6GCnHevCyfWNsCaBg1ss9LqhEjSZP 0U3mvjLqolTG9I0i/cFFRMFmEze2NoKU6dwxP22bzdT0fSfVuCCvPc00yvWWxEV8ueoj TFt2EcPAtbMEnT8ki/mgYs2kywxPOfyrTvbb2uPi8U2vPMdfUaiAyP5vlLxSbI2XIX9s CdEh2pCqX5PACpRcKmUO7PvD8R3KCVKShAOGlcKl95njDbNgfb89uutKu1WFcKBpXRhD NzZ43a1v2Eiz9ELrQk6qMCH7u8u/5dsDHfCXczLyEaHUuwK+WbRFxCc69couPIOc4oft y96w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s17si45455pgj.186.2019.06.13.08.03.20; Thu, 13 Jun 2019 08:03:49 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1733104AbfFMPB4 (ORCPT + 99 others); Thu, 13 Jun 2019 11:01:56 -0400 Received: from fieldses.org ([173.255.197.46]:52414 "EHLO fieldses.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732521AbfFMObv (ORCPT ); Thu, 13 Jun 2019 10:31:51 -0400 Received: by fieldses.org (Postfix, from userid 2815) id 34E742012; Thu, 13 Jun 2019 10:31:51 -0400 (EDT) Date: Thu, 13 Jun 2019 10:31:51 -0400 From: "J . Bruce Fields" To: Miklos Szeredi Cc: Amir Goldstein , Jeff Layton , linux-fsdevel@vger.kernel.org, Linux NFS list , overlayfs Subject: Re: [PATCH v2] locks: eliminate false positive conflicts for write lease Message-ID: <20190613143151.GC2145@fieldses.org> References: <20190612172408.22671-1-amir73il@gmail.com> <20190612183156.GA27576@fieldses.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org 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)