Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796239555; b=EDPhjF3D49YQb/9/T4BdDKsaW816bfcYmS+vamRXaA96xjc/r1ignQa6G1pKMJrCUzB9 3Hp07NH1nTGUPoaZqNjw+OWGejKD5XlnHgFcq7ho8adU2ytltSz96CUGfeC1jXDlf7ph1 bNxzPXAC/k7wL3VP92IAJHUiThHFsNvRe6d7Z5OY8YI5kuW3jBvQk6ZXbxOnfR6jw1uP/ HGJzz4Gv6qUnMx/u0hQqNxDQKSA1uD3HMeJPrP+vELjmSXREjlL9iZpaliSsV+yD0JHwl wMHiiOmkHAOom/QoH8ywo1l0pzFa9uZJem66pqGPkfr+9SlQ6rre18Xmw7q3TfbGFHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796239555; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=1ANxuZ5cCBfr4mV+eUgCvj/jehnW24dQ32MTQFKGEak=; b=3FdhVSWuuOnTBE74riUeONls5iVmP4iWKy89xs+PgqWk66onuJxpvUizAwV6fRn3EMOx t37dSlCiCjNE/DbSSZmzKeerYJMLuBo2/uB3aEi/tDuuG2QABNRTPw7tFKB2gVHSid4TR TTVtV4rddViwdKdEr6f++Gr3jUAzSjpSFJoB3bUUYcXLsrBHyeirYbuzUNt+aX/tA/Rya 6bfeg45bJkF86IvX3T38akj10FHMSz+WYNRgpkU0KdM5+czEMGm4wUwv9l5IE76BbHpRQ tm+521kshZR3BryDv7moa8uMhWiFt6jolQwhKPpMmFUyTaHyTPww5FoYlHWaMvImwqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jhz+pp01; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BCD3F606A322 for ; Wed, 2 Dec 2026 19:25:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jhz+pp01 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 154D01F0089C; Wed, 2 Dec 2026 19:25:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796239555; bh=1ANxuZ5cCBfr4mV+eUgCvj/jehnW24dQ32MTQFKGEak=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jhz+pp01lEWp3dwkaH84TjJHk8ci+Dz8W4o0rsY9HJnSeJ6gCRLqxSQbHij9ZqF09 JGxff25AkfIxvHAG5FBAZkFvMzJ/n3taXuK3Jx/bUwkbRMvhNTO3N8gclluQ1GcKah swOtfZAyJoDleDPmfybw1UR8CeFlqxnz96vjPjcJFJrCvVIPA+AF1YMYtRVGZgpHLV +cYKZ1MrmYfT3HtHBdVZuskdh54kbuoEf7j7K66A4bnt0DtBMKSNfk9BTIIEDQMj1V GCDCKtNiW6Rj6Yja6ggCowx6QpFuKBEHjl/FTsKszubOW0/Z00ADLsCvBihsFq1a4K O4QTo6Gd2l1JQ== From: Jeff Layton Date: Wed, 02 Dec 2026 14:25:42 -0500 Subject: [PATCH 5/5] nfsd: apply delegated times from CB_GETATTR when change and size match X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261202-delegts-fixes-v1-5-e3b237925b24@kernel.org> References: <20261202-delegts-fixes-v1-0-e3b237925b24@kernel.org> In-Reply-To: <20261202-delegts-fixes-v1-0-e3b237925b24@kernel.org> To: Chuck Lever , NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: linux-nfs@vger.kernel.org, Jeff Layton X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4121; i=jlayton@kernel.org; h=from:subject:message-id; bh=p63oOcGha/xVCAFD7IUfMsefsvjk0kcJS9nq1JYgFog=; b=owEBbQKS/ZANAwAKAQAOaEEZVoIVAcsmYgBrEHC/fXI8nQsMEjGxPZb/U2F92sBJ/RiqjwoxI nBufogoiUGJAjMEAAEKAB0WIQRLwNeyRHGyoYTq9dMADmhBGVaCFQUCaxBwvwAKCRAADmhBGVaC FQvZD/9IZtcoo4nCzpAEM1Yd2m8e+KlauKZOCU1ygXyDoFZze/aBjk8IohFaBdcGC5MAgBHPR/r qSDnQ0Z4i23UvtGMmfBcYtdPj+OLbAB8Xau6wJk+fwmjAp19sE1tDdsNXvfJI2dWuJymLWZDqcw NCVBvq010EYe/eKixVEK6P6LnE/lWdACt1ism/CLBzzG7J7ZbEDfPYavBBhtfNZ8gtSaqBQPUfD 6fU3NrekTUPA0Qhol4y5U2GVrvM2Oc1KKWRaOoaZ3H2d0bXWtLwJU/7QM2uKu/18LgcHwp8O2ZT 07wPhX6vkj4Nj0/GtXBP8WUrLfGOV5f6qkLSrTEfGLYhHvSHRTvkEDxSyGAvkDAglGWxMbKsRY4 iZO27zDh2t5N4vxyPddjJQUFNbMv4uA3bC3dncwR5iQv1iyrp3BtdHZOXv7YiTCJZnW+PBI/Mhv 3BDM9tjSAwlgsduMd9h9xgPrxq3K2rEXubqBbcxsjxRRBkuyMoNt0KcY0la260kgjbbL6htA0Bb Xn/ohN4YgFjsIP4bkbwi3DnC7hGbeIJSeTc/q0kkb9zm0J2Y8wCnB4lVMtfJKULFZvL4xlPEcUp gOlIT97UGKPOLrhcTa+kWi50N2GbC+G0XxeZi/QE4c9kimhtCiUPgH3ZfGqG/6jXi3YdJRJyzpT planvuCRz9fbSPg== X-Developer-Key: i=jlayton@kernel.org; a=openpgp; fpr=4BC0D7B24471B2A184EAF5D3000E684119568215 nfsd4_deleg_getattr_conflict() applies time_deleg_access and time_deleg_modify from a CB_GETATTR reply only when the reply's change or size differs from the server's. RFC 9754 section 5 makes the holder of a timestamp delegation the authority for atime and mtime, with no such condition. FMODE_NOCMTIME keeps the holder's WRITEs from moving mtime or the change attribute. After a flushed WRITE, change and size match, the holder's times are dropped, and other clients see new data with the mtime from grant time. pynfs DELEG27, DELEG30 and DELEG31 fail this way. - For timestamp delegations, always vet and apply the CB_GETATTR times. - Return the delegation to the caller even when nothing looks modified. Applying the times can bump i_version, so the reply must take change from ncf_initial_cinfo, not the inode. - Mark the file modified when a newer mtime is applied, so change advances along with it. dl_[amc]time stay at their grant values. The holder's SETATTR of the same times at return then still passes vetting and sets dl_setattr, so DELEGRETURN doesn't restamp over times other clients have seen. Repeated replies now reach cb_getattr_update_times() on every GETATTR, but the previous two patches already skip times with nothing to apply without taking freeze protection or the exclusive inode_lock. The file is marked modified only when a newer mtime is actually written: by a CB_GETATTR, or by the holder's own SETATTR of time_deleg_modify. Without the latter, a reply repeating that SETATTR's mtime applies nothing, and other clients would see the new mtime under the grant-time change attribute where they used to see the inode's. Fixes: 6ae30d6eb26b ("nfsd: add support for delegated timestamps") Signed-off-by: Jeff Layton --- fs/nfsd/nfs4proc.c | 8 ++++++++ fs/nfsd/nfs4state.c | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 2b83c6a4e289..33858c9035c8 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c @@ -1409,6 +1409,14 @@ nfsd4_deleg_set_times(struct svc_rqst *rqstp, struct svc_fh *fhp, iattr.ia_valid |= ATTR_FORCE; inode_lock(inode); host_err = notify_change(&nop_mnt_idmap, fhp->fh_dentry, &iattr, NULL); + /* + * Other clients' GETATTRs report ncf_initial_cinfo rather than the + * inode's change attribute, and a CB_GETATTR reply repeating this + * mtime applies nothing. As in cb_getattr_update_times(), a newer + * delegated mtime marks the file modified, so change moves with it. + */ + if (!host_err && deleg_mtime) + dp->dl_cb_fattr.ncf_file_modified = true; inode_unlock(inode); if (host_err) return nfserrno(host_err); diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f8817e60b0a2..0bb5e135210b 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -10834,8 +10834,14 @@ static int cb_getattr_update_times(struct dentry *dentry, struct nfs4_delegation ret = notify_change(&nop_mnt_idmap, dentry, &attrs, NULL); if (!ret && (valid & ATTR_ATIME_SET)) dp->dl_cb_atime = cb_atime; - if (!ret && (valid & ATTR_MTIME_SET)) + if (!ret && (valid & ATTR_MTIME_SET)) { dp->dl_cb_mtime = cb_mtime; + /* + * FMODE_NOCMTIME keeps the holder's WRITEs from moving the + * change attribute. A newer delegated mtime shows them. + */ + ncf->ncf_file_modified = true; + } out_unlock: inode_unlock(inode); file_end_write(nf->nf_file); @@ -10928,7 +10934,13 @@ nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp, struct dentry *dentry, else if (i_size_read(inode) != ncf->ncf_cb_fsize) ncf->ncf_file_modified = true; } - if (ncf->ncf_file_modified) { + /* + * The holder of a timestamp delegation is the authority for atime + * and mtime (RFC 9754, section 5), even if change and size match. + * Applying them can bump i_version, so the reply must take its + * change attribute from ncf_initial_cinfo. + */ + if (ncf->ncf_file_modified || deleg_attrs_deleg(dp->dl_type)) { int err; /* -- 2.56.1