From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 EC19344D686; Tue, 16 Jun 2026 11:59:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781611169; cv=none; b=Wsy2c021KTOe4RrPcviHn9b9W/rLE9miscZW7ppnHXPO4e9RjtScAJaO8CfbMSjU8IVye0ArdKBeUOm1A/O8QqQdjJJ9Zk/sni9CRioeBt0o58jGzuqcAjAVZQwSHndGaiRZeALal6uOVeu4OtJkwe/GG5gRcNSVrmmUHssvZJ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781611169; c=relaxed/simple; bh=dzhbe6mUJxXgN4SX7Eyg5Xl7uMQlnFJZNU93EiQBCFg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GbFWuGuaaDKiEZ6SqjFPCiZV/WWgUoV+K2d7D2u4VxX1XthG/Xu16eE4sZbZrXgFDtQK+WPoI8pYr1LgxBxVO8qJJygPfGNGTiug9DWOB7pLl6HKiQ7BZCfCTAvp54f0veMytQRqnjieizTEkDOv0cgTff0bOgbg9i4tabD0gOw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cEHWfTIe; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cEHWfTIe" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EFA1C1F00A3A; Tue, 16 Jun 2026 11:59:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781611167; bh=Db3tXM0PvChLue9Ulw423Nw6xQGvOX9BOAxo1UifGuY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=cEHWfTIe9Mz/lLrtRTqUSXSU+40rJ6Favw5yQNJDYWbfNGqGgrrEXiZFx/HX/NOTa QL1OY4CiUNg6bP7uMEg48My7Y1K2xVsdatKmRiANDSpCF8tGozAcM1IAkStmsgnPBQ xx3mCkwE+bG+lhRvVfObG5iY3upDC0iWrK6uXvgAmUIOQEImjvQM5Mlm1UPUzGyuGX iGkQ704dBUwZxeV8RpBaWmBe1L6obOCGcSfHKD2RV6gkixCeYKPSiCDJaWn6pcWuUF o9Etg3Hy/qCbqoSS8DwqPnY6UHeKjxS6Ku21Ns8aD1fqzLe3ycy4DKsP9bR8gFUDsr eEkCdIi8EjY9w== From: Jeff Layton Date: Tue, 16 Jun 2026 07:58:54 -0400 Subject: [PATCH v7 11/20] nfsd: apply the notify mask to the delegation when requested Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260616-dir-deleg-v7-11-6cbc7eac0ade@kernel.org> References: <20260616-dir-deleg-v7-0-6cbc7eac0ade@kernel.org> In-Reply-To: <20260616-dir-deleg-v7-0-6cbc7eac0ade@kernel.org> To: NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Trond Myklebust , Anna Schumaker , Jonathan Corbet , Shuah Khan , Chuck Lever Cc: Steven Rostedt , Alexander Aring , Amir Goldstein , Jan Kara , Alexander Viro , Christian Brauner , Calum Mackay , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3568; i=jlayton@kernel.org; h=from:subject:message-id; bh=dzhbe6mUJxXgN4SX7Eyg5Xl7uMQlnFJZNU93EiQBCFg=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBqMTqG194yz6rmsaZxbJXv6IJd+5nthWMR8AHEg U4Spu20+CWJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCajE6hgAKCRAADmhBGVaC FWvLD/9ZCUL9CXuTGPT6DS+07fQ5AQI5eS+eyBk1lJL3gvSNTorbc4JzzYqWGtOqBnFyUwGh4ys kTsRwFtFbMUBPwIAyfX0CFbzR4GZeRtp2ede3T57M+5kfAqOGUdbaJQWP156x8Fm8h3zM5b98zq zOEsEcmyz/wpCi8VuHjq0CkH2htERqnGajrxDaGxxFAYaovCD7QOuNm0QqsmME/Trdby0uoSDue 4DAfbsZiWu6GLpvROH7Rx/QoKyj9s6KQXoVKQ6O2zpzBC8aoy2522LY6y12RUDuMC8lDo5GBTCG ETtmabmN0fmsgWHsRLf1knmriskPPMQ4d43SSxqq8vRHW28OSjWGTV+dCDUHQnGYj6SC8YvUy2u XI42rCty+jf84HWAAJUZwEsG/K9LOLUwleFFHt1LGP4ALu4Ic8E3Zzu7mcRxWcrBvGQrhPHi7YQ iTMqgAh45nZeNaQmW1uMwCSbe03BK5C+K1DZvcuzsKNilqQ5eaOU/+0P0/rH/JWgF8G8bvOUd3B m7bAU/3E6YBS6tpQC/HaoS+aCzBs4Bck3UwlNZqDUygL94qXVljD8NP9nYdOXr/ilzy8gvk7CaZ QV7SqQnFoPAfTLOnjBmowyHa6KVHys0xm6XQa7DlNUMXZ1cUiIN9v3zzet8aegGfGQ2gM/d8r3Z YO8MYF0rX233WwQ== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 If the client requests a directory delegation with notifications enabled, set the appropriate return mask in gddr_notification[0]. This will ensure the lease acquisition sets the appropriate ignore mask. Also store the granted mask in the delegation's dl_notify_mask field, so that the CB_NOTIFY encoder can later tell which notifications the client was granted. If the client doesn't set NOTIFY4_GFLAG_EXTEND, then don't offer any notifications, as nfsd won't provide directory offset information, and "classic" notifications require them. Similarly, if the client sets GFLAG_EXTEND | CFLAG_ORDER, then zero out the notification mask. The Linux server can't provide the necessary ordering info to those clients. Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 21 +++++++++++++++++++++ fs/nfsd/nfs4state.c | 3 ++- fs/nfsd/state.h | 3 +++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 3e4de45aa360..565bf76c08ed 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -2552,12 +2552,18 @@ nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, return status == nfserr_same ? nfs_ok : status; } +#define SUPPORTED_NOTIFY_MASK (BIT(NOTIFY4_REMOVE_ENTRY) | \ + BIT(NOTIFY4_ADD_ENTRY) | \ + BIT(NOTIFY4_RENAME_ENTRY) | \ + BIT(NOTIFY4_GFLAG_EXTEND)) + static __be32 nfsd4_get_dir_delegation(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, union nfsd4_op_u *u) { struct nfsd4_get_dir_delegation *gdd = &u->get_dir_delegation; + u32 requested = gdd->gdda_notification_types[0]; struct nfs4_delegation *dd; struct nfsd_file *nf; __be32 status; @@ -2566,6 +2572,21 @@ nfsd4_get_dir_delegation(struct svc_rqst *rqstp, if (status != nfs_ok) return status; + /* + * Offer no notifications to an order-aware client. RFC8881bis section + * 16.2.13 defines order-aware as NOTIFY4_CFLAG_ORDER being set or + * NOTIFY4_GFLAG_EXTEND being reset. Such a client expects cookie and + * previous-entry information with its notifications (e.g. 27.4.5), and + * nfsd does not track or emit directory offset information. Per + * 16.2.11.3 the alternative would be to recall the delegation, so it's + * simpler to just decline the notifications here. + */ + if (!(requested & BIT(NOTIFY4_GFLAG_EXTEND)) || + (requested & BIT(NOTIFY4_CFLAG_ORDER))) + requested = 0; + + gdd->gddr_notification[0] = requested & SUPPORTED_NOTIFY_MASK; + /* * RFC 8881, section 18.39.3 says: * diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 5a4f0843c2fe..682c00fbd2fb 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -10031,7 +10031,8 @@ nfsd_get_dir_deleg(struct nfsd4_compound_state *cstate, * NB: gddr_notification[0] represents the notifications that * will be granted to the client */ - fl = nfs4_alloc_init_lease(dp, gdd->gddr_notification[0]); + dp->dl_notify_mask = gdd->gddr_notification[0]; + fl = nfs4_alloc_init_lease(dp, dp->dl_notify_mask); if (!fl) goto out_put_stid; diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index f8457e0f2b57..7a66048a130c 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h @@ -297,6 +297,9 @@ struct nfs4_delegation { struct timespec64 dl_atime; struct timespec64 dl_mtime; struct timespec64 dl_ctime; + + /* For dir delegations */ + u32 dl_notify_mask; }; static inline bool deleg_is_read(u32 dl_type) -- 2.54.0