Skip to content

Commit e92b3fc

Browse files
Christoph Hellwigcmaiolino
authored andcommitted
xfs: fold xfs_setattr_size into xfs_vn_setattr_size
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>
1 parent 0f7d2a9 commit e92b3fc

1 file changed

Lines changed: 11 additions & 27 deletions

File tree

fs/xfs/xfs_iops.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -901,20 +901,18 @@ xfs_setattr_nonsize(
901901

902902
/*
903903
* Truncate file. Must have write permission and not be a directory.
904-
*
905-
* Caution: The caller of this function is responsible for calling
906-
* setattr_prepare() or otherwise verifying the change is fine.
907904
*/
908-
STATIC int
909-
xfs_setattr_size(
905+
int
906+
xfs_vn_setattr_size(
910907
struct mnt_idmap *idmap,
911908
struct dentry *dentry,
912-
struct xfs_inode *ip,
913909
struct iattr *iattr)
914910
{
911+
struct inode *inode = d_inode(dentry);
912+
struct xfs_inode *ip = XFS_I(inode);
915913
struct xfs_mount *mp = ip->i_mount;
916-
struct inode *inode = VFS_I(ip);
917-
xfs_off_t oldsize, newsize;
914+
xfs_off_t oldsize = inode->i_size;
915+
xfs_off_t newsize = iattr->ia_size;
918916
struct xfs_trans *tp;
919917
int error;
920918
uint lock_flags = 0;
@@ -927,8 +925,11 @@ xfs_setattr_size(
927925
ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET|
928926
ATTR_MTIME_SET|ATTR_TIMES_SET)) == 0);
929927

930-
oldsize = inode->i_size;
931-
newsize = iattr->ia_size;
928+
trace_xfs_setattr(ip);
929+
930+
error = xfs_vn_change_ok(idmap, dentry, iattr);
931+
if (error)
932+
return error;
932933

933934
/*
934935
* Short circuit the truncate case for zero length files.
@@ -1128,23 +1129,6 @@ xfs_setattr_size(
11281129
goto out_unlock;
11291130
}
11301131

1131-
int
1132-
xfs_vn_setattr_size(
1133-
struct mnt_idmap *idmap,
1134-
struct dentry *dentry,
1135-
struct iattr *iattr)
1136-
{
1137-
struct xfs_inode *ip = XFS_I(d_inode(dentry));
1138-
int error;
1139-
1140-
trace_xfs_setattr(ip);
1141-
1142-
error = xfs_vn_change_ok(idmap, dentry, iattr);
1143-
if (error)
1144-
return error;
1145-
return xfs_setattr_size(idmap, dentry, ip, iattr);
1146-
}
1147-
11481132
STATIC int
11491133
xfs_vn_setattr(
11501134
struct mnt_idmap *idmap,

0 commit comments

Comments
 (0)