Skip to contentSkip to conversation

small cleanups for ->setattr

PATCH Applied Christoph Hellwig 2 participants 6 messages Mar 30 – Apr 7 XFS filesystem

lore
Share & tools
lore
#1 lore raw

PATCH 1/2 xfs: remove a duplicate assert in xfs_setattr_size

There already is an assert that checks for uid and gid changes besides a lot of others at the beginning of the function.

---
 fs/xfs/xfs_iops.c | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_iops.c +0 -1
index 208543e57eda..b0256a4a8aa8 100644
@@ -1109,7 +1109,6 @@ xfs_setattr_size(
 		xfs_inode_clear_eofblocks_tag(ip);
 	}
 
-	ASSERT(!(iattr->ia_valid & (ATTR_UID | ATTR_GID)));
 	setattr_copy(idmap, inode, iattr);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size

Quoted 5 lines · Christoph Hellwig

There already is an assert that checks for uid and gid changes besides a lot of others at the beginning of the function.

---

Looks good

Quoted 18 lines
 fs/xfs/xfs_iops.c | 1 -
 1 file changed, 1 deletion(-)
fs/xfs/xfs_iops.c +0 -1
index 208543e57eda..b0256a4a8aa8 100644
@@ -1109,7 +1109,6 @@ xfs_setattr_size(
 		xfs_inode_clear_eofblocks_tag(ip);
 	}
 
-	ASSERT(!(iattr->ia_valid & (ATTR_UID | ATTR_GID)));
 	setattr_copy(idmap, inode, iattr);
 	xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
 
Signature · 1 line
2.47.3
maintainer Applied
#3 lore raw

Re: [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size

In reply to Christoph Hellwig
Quoted 4 lines · Christoph Hellwig

There already is an assert that checks for uid and gid changes besides a lot of others at the beginning of the function.

Applied to for-next, thanks!

[1/2] xfs: remove a duplicate assert in xfs_setattr_size

      commit: 0f7d2a9e020812a787d7c6dfc98715f9c8f72f53
[2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size
      commit: e92b3fc5b17c75d3ca31983a7d35e8b88786ee4e

Best regards,

Signature · 1 line
Carlos Maiolino <[email protected]>
#4 lore raw

PATCH 2/2 xfs: fold xfs_setattr_size into xfs_vn_setattr_size

In reply to Christoph Hellwig

xfs_vn_setattr_size is the only caller of xfs_setattr_size, so merge the two functions.

---
 fs/xfs/xfs_iops.c | 38 +++++++++++---------------------------
 1 file changed, 11 insertions(+), 27 deletions(-)
fs/xfs/xfs_iops.c +11 -27
index b0256a4a8aa8..325c2200c501 100644
@@ -901,20 +901,18 @@ xfs_setattr_nonsize(
 
 /*
  * 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 @@ xfs_setattr_size(
 	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,
Signature · 1 line
2.47.3
maintainer Reviewed-by on v1 2/2
#5 lore raw

Re: [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size

Quoted 5 lines · Christoph Hellwig

xfs_vn_setattr_size is the only caller of xfs_setattr_size, so merge the two functions.

---

Quoted 75 lines
 fs/xfs/xfs_iops.c | 38 +++++++++++---------------------------
 1 file changed, 11 insertions(+), 27 deletions(-)
fs/xfs/xfs_iops.c +11 -27
index b0256a4a8aa8..325c2200c501 100644
@@ -901,20 +901,18 @@ xfs_setattr_nonsize(
 
 /*
  * 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 @@ xfs_setattr_size(
 	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,
Signature · 1 line
2.47.3