]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
exportfs: don't pass struct iattr to ->commit_blocks
authorChristoph Hellwig <hch@lst.de>
Thu, 23 Apr 2026 18:18:53 +0000 (14:18 -0400)
committerChristian Brauner <brauner@kernel.org>
Mon, 11 May 2026 09:11:48 +0000 (11:11 +0200)
The only thing ->commit_blocks really needs is the new size, with a magic
-1 placeholder 0 for "do not change the size" because it only ever
extends the size.

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-4-cel@kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/nfsd/blocklayout.c
fs/xfs/xfs_pnfs.c
include/linux/exportfs_block.h

index e612fcf8666a8dc7d376ad09db0b2e849e9bb4ae..5be7721c22c2359145824e7570601af240538a83 100644 (file)
@@ -179,7 +179,6 @@ static __be32
 nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
                struct iomap *iomaps, int nr_iomaps)
 {
-       struct iattr iattr = { .ia_valid = 0 };
        int error;
 
        /*
@@ -191,16 +190,9 @@ nfsd4_block_commit_blocks(struct inode *inode, struct nfsd4_layoutcommit *lcp,
         * 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 = current_time(inode);
-
-       if (lcp->lc_size_chg) {
-               iattr.ia_valid |= ATTR_SIZE;
-               iattr.ia_size = lcp->lc_newsize;
-       }
-
        error = inode->i_sb->s_export_op->block_ops->commit_blocks(inode,
-                       iomaps, nr_iomaps, &iattr);
+                       iomaps, nr_iomaps,
+                       lcp->lc_size_chg ? lcp->lc_newsize : 0);
        kfree(iomaps);
        return nfserrno(error);
 }
index 12e083f1b9bafb37c3e77720d79165efa9250737..7d689bb2efd915a04d6c3386e7841935a64ce3cf 100644 (file)
@@ -257,23 +257,22 @@ xfs_fs_commit_blocks(
        struct inode            *inode,
        struct iomap            *maps,
        int                     nr_maps,
-       struct iattr            *iattr)
+       loff_t                  new_size)
 {
        struct xfs_inode        *ip = XFS_I(inode);
        struct xfs_mount        *mp = ip->i_mount;
        struct xfs_trans        *tp;
+       struct timespec64       now;
        bool                    update_isize = false;
        int                     error, i;
        loff_t                  size;
 
-       ASSERT(iattr->ia_valid & (ATTR_ATIME|ATTR_CTIME|ATTR_MTIME));
-
        xfs_ilock(ip, XFS_IOLOCK_EXCL);
 
        size = i_size_read(inode);
-       if ((iattr->ia_valid & ATTR_SIZE) && iattr->ia_size > size) {
+       if (new_size > size) {
                update_isize = true;
-               size = iattr->ia_size;
+               size = new_size;
        }
 
        for (i = 0; i < nr_maps; i++) {
@@ -318,11 +317,13 @@ xfs_fs_commit_blocks(
        xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
        xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
-       ASSERT(!(iattr->ia_valid & (ATTR_UID | ATTR_GID)));
-       setattr_copy(&nop_mnt_idmap, inode, iattr);
+       now = inode_set_ctime_current(inode);
+       inode_set_atime_to_ts(inode, now);
+       inode_set_mtime_to_ts(inode, now);
+
        if (update_isize) {
-               i_size_write(inode, iattr->ia_size);
-               ip->i_disk_size = iattr->ia_size;
+               i_size_write(inode, new_size);
+               ip->i_disk_size = new_size;
        }
 
        xfs_trans_set_sync(tp);
index 1f52fea8e4dce1ab7ef86d709481fafabf04a254..d1dec4689b14adc8e67de95c1f225b21fba5bed9 100644 (file)
@@ -9,7 +9,6 @@
 
 #include <linux/types.h>
 
-struct iattr;
 struct inode;
 struct iomap;
 struct super_block;
@@ -33,7 +32,7 @@ struct exportfs_block_ops {
         * the client.
         */
        int (*commit_blocks)(struct inode *inode, struct iomap *iomaps,
-                       int nr_iomaps, struct iattr *iattr);
+                       int nr_iomaps, loff_t new_size);
 };
 
 #endif /* LINUX_EXPORTFS_BLOCK_H */