From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size
Date: Mon, 30 Mar 2026 15:16:00 +0200 [thread overview]
Message-ID: <20260330131607.3904269-3-hch@lst.de> (raw)
In-Reply-To: <20260330131607.3904269-1-hch@lst.de>
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
next prev parent reply other threads:[~2026-03-30 13:16 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Christoph Hellwig [this message]
2026-04-07 11:02 ` [PATCH 2/2] xfs: fold xfs_setattr_size into xfs_vn_setattr_size Carlos Maiolino
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260330131607.3904269-3-hch@lst.de \
--to=hch@lst.de \
--cc=cem@kernel.org \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox