Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1505153lqt; Wed, 20 Mar 2024 06:14:07 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUOSPgiL4j8Wtzs8eVCTgTYs9gEPlotGUJlTR4zThYyCrZJyNgZYeikxo3KFVhvZRRVpAxvi8j2KU/iFiFozjnVTG2KCSld9HRALgyqAg== X-Google-Smtp-Source: AGHT+IGDEQT22ws5woag/miaHyPQJZYIlKr2zW0rWGkuZ6FvwC1x5oHpmRPlf9PAvbjHWYF/KOw0 X-Received: by 2002:a17:906:355a:b0:a46:9671:b461 with SMTP id s26-20020a170906355a00b00a469671b461mr9764436eja.61.1710940447492; Wed, 20 Mar 2024 06:14:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710940447; cv=pass; d=google.com; s=arc-20160816; b=f9I/LO2XCzqVSZVy1cHhjcpVKzUiH4VFc2Or+is+IOmdL0yUyU+DMsw6p6QCZRuiVu vVUrH5QkGDD8e661pfE+tbS79fGnBRNVvYfzO+xh1OflaWOmxYS0+ZGRMO4tknzzcPVm bDfr/IyKYIA1De/CCYQX5poURO74ApL+k8ftgajQV2Le4P2+gIswJqzst2Nnl5aG9JeN biAjnOM+rKwv4RLrKvEsTh26RqiSHnBjmnS7/eR5JpC39dHr3y2iJTSeb/rQqbzF1uYO N+4T15TZUJlP/eP0LWgYAQ9TAXELph2rm64iQj9GR4LnPNF7F/RJ8IBLXN10lhLXN6aF u5zA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=JZEQlb9co9bqi36NRzKeXZeYjXBJuUoMTQv6YcBqxkI=; fh=scMLWB4D2jbCb3aoVJcHWzL26fVrjozWuZkrYEXvyJM=; b=sALe5fG9mFPAIgJQIpmt1Epa8c43WIzzGL7yHZccW8ICaHfuMBFFTZoKFUaldbg7sa yBf9m58g9295p4NoH6aePW7f7KcQxU7+b9SJ3Nb3mVmB3n3UTLl0HUrn7cGW4JmjJaFa PHZtmFuByal73IJBkt+aBesTbdlxwbrsFzAQdKFwK1KJGPqdR47RexunYVgIXB42frBk m+BkqZYFFWxQ880emkOP4dbkKLLUp2oyAU7mfHFHF4z8usAU2MiNA792yOU5uWbxssj9 QW0sXJ5/KecGqbGwWtv1oM4cK745pbZW7IGjuJZGar40vKkOZomAhcbH/Fbkupv7mwQn O03A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HUeELnCF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id me25-20020a170906aed900b00a46dcae3bb5si1788153ejb.207.2024.03.20.06.14.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Mar 2024 06:14:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-2411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=HUeELnCF; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-2411-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-nfs+bounces-2411-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3B0A01F24C6F for ; Wed, 20 Mar 2024 13:14:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 082364087B; Wed, 20 Mar 2024 13:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="HUeELnCF" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B81E240847; Wed, 20 Mar 2024 13:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710940438; cv=none; b=IBQ28E857yOPIuWcosWbYs2exuZ0XxEJpiVVC90A/7o4bbGXwy3kwLLFriV27Hk2gII/6C8SlG9yvbLr0Ei45r3+w3nwzocal12lb9D0mHpuN/zvJIalcu3iBbTv3dqReUL04kRUoDihyROrusElcSNLJY+bOipJG+nI5rIEtqs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710940438; c=relaxed/simple; bh=ghCN61ofXI0Tf62QAiLIvxh+oQl1kd8cAWHEsmu/bDg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HysKZ5mJzoqPt/4t9pGF1nip2Q270uDY8MHF1GqGLQYkbq4tG06woA21N7jxQoKe/4Jh3Vu5ITYQov0EwUXxUjyFuD/0umqntQ3j9btB+vozlqRynFgV0TEk3rkO8xr014ueb8S2Cg+DucTLxDHKWAMt7x7FwmjUMI7Iuqzrpy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=HUeELnCF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9396C433F1; Wed, 20 Mar 2024 13:13:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710940438; bh=ghCN61ofXI0Tf62QAiLIvxh+oQl1kd8cAWHEsmu/bDg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=HUeELnCFnUj3wvloClJuzTNugchOpDzTWWkkMdQaB3sqR8vtfAqyHagXs+H2Xj1mO ecblLQCaISXQFeqgrXi8ZNaf8EaEaC663/0+5jfAcIxV8cMPHlm0QxutNY/nvBG6tE JKq1+g+QgLAXEKFWocsj6dvM2Ps6ybe/+G8AVxC/ncU9GOrG9UN955V8DQHkXrJq4p PDGewkWQ65RfOMJNcTGVS4aCkpd4tRRZfbF01WI4EXaEzbqun2MJLUGyHykPw+frbW 65ijs0IFtmvHd685+YoIjn8J+nJ21RtcsMfVqTp/nTG3cTwvBq/boKoJ8KPm3bD92I i6s9gHFkYdo7A== Date: Wed, 20 Mar 2024 14:13:47 +0100 From: Christian Brauner To: Jeff Layton Cc: Alexander Viro , Jan Kara , Chuck Lever , Alexander Aring , Trond Myklebust , Anna Schumaker , Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey , Greg Kroah-Hartman , "Rafael J. Wysocki" , David Howells , Tyler Hicks , Neil Brown , Olga Kornievskaia , Dai Ngo , Miklos Szeredi , Amir Goldstein , Namjae Jeon , Sergey Senozhatsky , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, netfs@lists.linux.dev, ecryptfs@vger.kernel.org, linux-unionfs@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH RFC 02/24] filelock: add a lm_set_conflict lease_manager callback Message-ID: <20240320-gaspreis-mitunter-217e0d82f50f@brauner> References: <20240315-dir-deleg-v1-0-a1d6209a3654@kernel.org> <20240315-dir-deleg-v1-2-a1d6209a3654@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20240315-dir-deleg-v1-2-a1d6209a3654@kernel.org> On Fri, Mar 15, 2024 at 12:52:53PM -0400, Jeff Layton wrote: > The NFSv4.1 protocol adds support for directory delegations, but it > specifies that if you already have a delegation and try to request a new > one on the same filehandle, the server must reply that the delegation is > unavailable. > > Add a new lease_manager callback to allow the lease manager (nfsd in > this case) to impose extra checks when performing a setlease. > > Signed-off-by: Jeff Layton > --- > fs/locks.c | 5 +++++ > include/linux/filelock.h | 10 ++++++++++ > 2 files changed, 15 insertions(+) > > diff --git a/fs/locks.c b/fs/locks.c > index cb4b35d26162..415cca8e9565 100644 > --- a/fs/locks.c > +++ b/fs/locks.c > @@ -1822,6 +1822,11 @@ generic_add_lease(struct file *filp, int arg, struct file_lease **flp, void **pr > continue; > } > > + /* Allow the lease manager to veto the setlease */ > + if (lease->fl_lmops->lm_set_conflict && > + lease->fl_lmops->lm_set_conflict(lease, fl)) > + goto out; > + > /* > * No exclusive leases if someone else has a lease on > * this file: > diff --git a/include/linux/filelock.h b/include/linux/filelock.h > index daee999d05f3..c5fc768087df 100644 > --- a/include/linux/filelock.h > +++ b/include/linux/filelock.h > @@ -49,6 +49,16 @@ struct lease_manager_operations { > int (*lm_change)(struct file_lease *, int, struct list_head *); > void (*lm_setup)(struct file_lease *, void **); > bool (*lm_breaker_owns_lease)(struct file_lease *); > + > + /** > + * lm_set_conflict - extra conditions for setlease > + * @new: new file_lease being set > + * @old: old (extant) file_lease > + * > + * This allows the lease manager to add extra conditions when > + * setting a lease. > + */ > + bool (*lm_set_conflict)(struct file_lease *new, struct file_lease *old); Minor, but it seems a bit misnamed to me. I'd recommend calling this lm_may_set_lease() or lm_may_lease().