nfsd/blocklayout: always ignore loca_time_modify

RFC 8881 Section 18.42 makes it clear that the client provided timestamp
is a "may" condition, and clients that want to force a specific timestamp
should send a separate SETATTR in the compound.

Since commit b82f92d5dd ("fs: have setattr_copy handle multigrain
timestamps appropriately") the ia_mtime value is ignored by file
systems using multi-grain timestamps like XFS, which is the only
file system supporting blocklayout exports right now, so make that
explicit in NFSD as well.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Link: https://patch.msgid.link/20260423181854.743150-2-cel@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
This commit is contained in:
Christoph Hellwig 2026-04-23 14:18:51 -04:00 committed by Christian Brauner
parent 254f49634e
commit 0d9ff5c421
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2

View File

@ -179,15 +179,20 @@ static __be32
nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
struct iomap *iomaps, int nr_iomaps)
{
struct timespec64 mtime = inode_get_mtime(inode);
struct iattr iattr = { .ia_valid = 0 };
int error;
if (lcp->lc_mtime.tv_nsec == UTIME_NOW ||
timespec64_compare(&lcp->lc_mtime, &mtime) < 0)
lcp->lc_mtime = current_time(inode);
/*
* This ignores the client provided mtime in loca_time_modify, as a
* fully client specified mtime doesn't really fit into the Linux
* multi-grain timestamp architecture.
*
* RFC 8881 Section 18.42 makes it clear that the client provided
* timestamp is a "may" condition, and clients that want to force a
* specific timestamp should send a separate SETATTR in the compound.
*/
iattr.ia_valid |= ATTR_ATIME | ATTR_CTIME | ATTR_MTIME;
iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = lcp->lc_mtime;
iattr.ia_atime = iattr.ia_ctime = iattr.ia_mtime = current_time(inode);
if (lcp->lc_size_chg) {
iattr.ia_valid |= ATTR_SIZE;