]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: fold xfs_setattr_size into xfs_vn_setattr_size
authorChristoph Hellwig <hch@lst.de>
Mon, 30 Mar 2026 13:16:00 +0000 (15:16 +0200)
committerCarlos Maiolino <cem@kernel.org>
Tue, 7 Apr 2026 11:03:52 +0000 (13:03 +0200)
xfs_vn_setattr_size is the only caller of xfs_setattr_size, so merge the
two functions.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/xfs_iops.c

index b0256a4a8aa810bedba53423c838ed995229778b..325c2200c501f7715e3cc3e4fe6a55947824dc19 100644 (file)
@@ -901,20 +901,18 @@ out_dqrele:
 
 /*
  * Truncate file.  Must have write permission and not be a directory.
- *
- * Caution: The caller of this function is responsible for calling
- * setattr_prepare() or otherwise verifying the change is fine.
  */
-STATIC int
-xfs_setattr_size(
+int
+xfs_vn_setattr_size(
        struct mnt_idmap        *idmap,
        struct dentry           *dentry,
-       struct xfs_inode        *ip,
        struct iattr            *iattr)
 {
+       struct inode            *inode = d_inode(dentry);
+       struct xfs_inode        *ip = XFS_I(inode);
        struct xfs_mount        *mp = ip->i_mount;
-       struct inode            *inode = VFS_I(ip);
-       xfs_off_t               oldsize, newsize;
+       xfs_off_t               oldsize = inode->i_size;
+       xfs_off_t               newsize = iattr->ia_size;
        struct xfs_trans        *tp;
        int                     error;
        uint                    lock_flags = 0;
@@ -927,8 +925,11 @@ xfs_setattr_size(
        ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
                ATTR_MTIME_SET|ATTR_TIMES_SET)) == 0);
 
-       oldsize = inode->i_size;
-       newsize = iattr->ia_size;
+       trace_xfs_setattr(ip);
+
+       error = xfs_vn_change_ok(idmap, dentry, iattr);
+       if (error)
+               return error;
 
        /*
         * Short circuit the truncate case for zero length files.
@@ -1128,23 +1129,6 @@ out_trans_cancel:
        goto out_unlock;
 }
 
-int
-xfs_vn_setattr_size(
-       struct mnt_idmap        *idmap,
-       struct dentry           *dentry,
-       struct iattr            *iattr)
-{
-       struct xfs_inode        *ip = XFS_I(d_inode(dentry));
-       int error;
-
-       trace_xfs_setattr(ip);
-
-       error = xfs_vn_change_ok(idmap, dentry, iattr);
-       if (error)
-               return error;
-       return xfs_setattr_size(idmap, dentry, ip, iattr);
-}
-
 STATIC int
 xfs_vn_setattr(
        struct mnt_idmap        *idmap,