]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
nfsd/blocklayout: always ignore loca_time_modify
authorChristoph Hellwig <hch@lst.de>
Thu, 23 Apr 2026 18:18:51 +0000 (14:18 -0400)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 09:11:48 +0000 (11:11 +0200)
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 b82f92d5dd1a ("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>
fs/nfsd/blocklayout.c

index 9d829c84f374ec3b8b862279a0ad59c8675bc7a4..24cc5025f649289633c1b7455281f3f193976cce 100644 (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;