public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
* small cleanups for ->setattr
@ 2026-03-30 13:15 Christoph Hellwig
  2026-03-30 13:15 ` [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size Christoph Hellwig
  2026-03-30 13:16 ` [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size Christoph Hellwig
  0 siblings, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-03-30 13:15 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

Hi all,

this series has two trivial cleanups for ->setattr.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size
  2026-03-30 13:15 small cleanups for ->setattr Christoph Hellwig
@ 2026-03-30 13:15 ` Christoph Hellwig
  2026-04-07 11:01   ` Carlos Maiolino
  2026-04-07 13:38   ` Carlos Maiolino
  2026-03-30 13:16 ` [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size Christoph Hellwig
  1 sibling, 2 replies; 6+ messages in thread
From: Christoph Hellwig @ 2026-03-30 13:15 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

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

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_iops.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 208543e57eda..b0256a4a8aa8 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -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);
 
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size
  2026-03-30 13:15 small cleanups for ->setattr Christoph Hellwig
  2026-03-30 13:15 ` [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size Christoph Hellwig
@ 2026-03-30 13:16 ` Christoph Hellwig
  2026-04-07 11:02   ` Carlos Maiolino
  1 sibling, 1 reply; 6+ messages in thread
From: Christoph Hellwig @ 2026-03-30 13:16 UTC (permalink / raw)
  To: Carlos Maiolino; +Cc: linux-xfs

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>
---
 fs/xfs/xfs_iops.c | 38 +++++++++++---------------------------
 1 file changed, 11 insertions(+), 27 deletions(-)

diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index b0256a4a8aa8..325c2200c501 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -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,
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size
  2026-03-30 13:15 ` [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size Christoph Hellwig
@ 2026-04-07 11:01   ` Carlos Maiolino
  2026-04-07 13:38   ` Carlos Maiolino
  1 sibling, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2026-04-07 11:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Mon, Mar 30, 2026 at 03:15:59PM +0200, Christoph Hellwig wrote:
> There already is an assert that checks for uid and gid changes besides a
> lot of others at the beginning of the function.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---

Looks good

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

>  fs/xfs/xfs_iops.c | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 208543e57eda..b0256a4a8aa8 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -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);
>  
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size
  2026-03-30 13:16 ` [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size Christoph Hellwig
@ 2026-04-07 11:02   ` Carlos Maiolino
  0 siblings, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2026-04-07 11:02 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Mon, Mar 30, 2026 at 03:16:00PM +0200, Christoph Hellwig wrote:
> 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>


>  fs/xfs/xfs_iops.c | 38 +++++++++++---------------------------
>  1 file changed, 11 insertions(+), 27 deletions(-)
> 
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index b0256a4a8aa8..325c2200c501 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -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,
> -- 
> 2.47.3
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size
  2026-03-30 13:15 ` [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size Christoph Hellwig
  2026-04-07 11:01   ` Carlos Maiolino
@ 2026-04-07 13:38   ` Carlos Maiolino
  1 sibling, 0 replies; 6+ messages in thread
From: Carlos Maiolino @ 2026-04-07 13:38 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: linux-xfs

On Mon, 30 Mar 2026 15:15:59 +0200, Christoph Hellwig wrote:
> 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,
-- 
Carlos Maiolino <cem@kernel.org>


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-07 13:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-30 13:15 small cleanups for ->setattr Christoph Hellwig
2026-03-30 13:15 ` [PATCH 1/2] xfs: remove a duplicate assert in xfs_setattr_size Christoph Hellwig
2026-04-07 11:01   ` Carlos Maiolino
2026-04-07 13:38   ` Carlos Maiolino
2026-03-30 13:16 ` [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size Christoph Hellwig
2026-04-07 11:02   ` Carlos Maiolino

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox