From: Christoph Hellwig <hch@lst.de>
To: Carlos Maiolino <cem@kernel.org>
Cc: linux-xfs@vger.kernel.org
Subject: [PATCH 3/9] xfs: add a XFS_INO_TO_FSB helper
Date: Fri, 15 May 2026 15:50:24 +0200 [thread overview]
Message-ID: <20260515135103.4042407-4-hch@lst.de> (raw)
In-Reply-To: <20260515135103.4042407-1-hch@lst.de>
Add a shortcut for the common XFS_INO_TO_FSB(mp, ip->i_ino) pattern.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/xfs/libxfs/xfs_bmap.c | 8 +++-----
fs/xfs/libxfs/xfs_btree.c | 6 ++----
fs/xfs/libxfs/xfs_format.h | 2 ++
fs/xfs/scrub/cow_repair.c | 3 +--
fs/xfs/scrub/newbt.c | 6 ++----
fs/xfs/scrub/trace.c | 2 +-
6 files changed, 11 insertions(+), 16 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 7a4c8f1aa76c..a11a8aee5b79 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -681,8 +681,7 @@ xfs_bmap_extents_to_btree(
args.minlen = args.maxlen = args.prod = 1;
args.wasdel = wasdel;
*logflagsp = 0;
- error = xfs_alloc_vextent_start_ag(&args,
- XFS_INO_TO_FSB(mp, ip->i_ino));
+ error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip));
if (error)
goto out_root_realloc;
@@ -828,8 +827,7 @@ xfs_bmap_local_to_extents(
*/
args.total = total;
args.minlen = args.maxlen = args.prod = 1;
- error = xfs_alloc_vextent_start_ag(&args,
- XFS_INO_TO_FSB(args.mp, ip->i_ino));
+ error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip));
if (error)
goto done;
@@ -3590,7 +3588,7 @@ xfs_bmap_btalloc_best_length(
xfs_extlen_t blen = 0;
int error;
- ap->blkno = XFS_INO_TO_FSB(args->mp, ap->ip->i_ino);
+ ap->blkno = XFS_INODE_TO_FSB(ap->ip);
if (!xfs_bmap_adjacent(ap))
ap->eof = false;
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index 7012f3570c8d..71d65f2fa005 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -3243,8 +3243,7 @@ xfs_btree_new_iroot(
if (level > 0)
aptr = *xfs_btree_ptr_addr(cur, 1, block);
else
- aptr.l = cpu_to_be64(XFS_INO_TO_FSB(cur->bc_mp,
- cur->bc_ino.ip->i_ino));
+ aptr.l = cpu_to_be64(XFS_INODE_TO_FSB(cur->bc_ino.ip));
/* Allocate the new block. If we can't do it, we're toast. Give up. */
error = xfs_btree_alloc_block(cur, &aptr, &nptr, stat);
@@ -5609,8 +5608,7 @@ xfs_btree_alloc_metafile_block(
ASSERT(xfs_is_metadir_inode(ip));
xfs_rmap_ino_bmbt_owner(&args.oinfo, ip->i_ino, cur->bc_ino.whichfork);
- error = xfs_alloc_vextent_start_ag(&args,
- XFS_INO_TO_FSB(cur->bc_mp, ip->i_ino));
+ error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(ip));
if (error)
return error;
if (args.fsbno == NULLFSBLOCK) {
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index f812c6782492..9886af0507e3 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -1289,6 +1289,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip)
((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp)))
#define XFS_INO_TO_FSB(mp,i) \
XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i))
+#define XFS_INODE_TO_FSB(ip) \
+ XFS_INO_TO_FSB((ip)->i_mount, (ip)->i_ino)
#define XFS_AGINO_TO_INO(mp,a,i) \
(((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i))
#define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp))
diff --git a/fs/xfs/scrub/cow_repair.c b/fs/xfs/scrub/cow_repair.c
index bffc4666ce60..7b36b87f2c1a 100644
--- a/fs/xfs/scrub/cow_repair.c
+++ b/fs/xfs/scrub/cow_repair.c
@@ -426,8 +426,7 @@ xrep_cow_alloc(
if (error)
return error;
- error = xfs_alloc_vextent_start_ag(&args,
- XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino));
+ error = xfs_alloc_vextent_start_ag(&args, XFS_INODE_TO_FSB(sc->ip));
if (error)
return error;
if (args.fsbno == NULLFSBLOCK)
diff --git a/fs/xfs/scrub/newbt.c b/fs/xfs/scrub/newbt.c
index 2e4981c1baf2..6ab0eff7d2ea 100644
--- a/fs/xfs/scrub/newbt.c
+++ b/fs/xfs/scrub/newbt.c
@@ -123,8 +123,7 @@ xrep_newbt_init_inode(
if (!ifp)
return -ENOMEM;
- xrep_newbt_init_ag(xnr, sc, oinfo,
- XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino),
+ xrep_newbt_init_ag(xnr, sc, oinfo, XFS_INODE_TO_FSB(sc->ip),
XFS_AG_RESV_NONE);
xnr->ifake.if_fork = ifp;
xnr->ifake.if_fork_size = xfs_inode_fork_size(sc->ip, whichfork);
@@ -160,8 +159,7 @@ xrep_newbt_init_metadir_inode(
* as if they were regular file blocks. This exposes us to a higher
* risk of the repair being cancelled due to ENOSPC.
*/
- xrep_newbt_init_ag(xnr, sc, &oinfo,
- XFS_INO_TO_FSB(sc->mp, sc->ip->i_ino),
+ xrep_newbt_init_ag(xnr, sc, &oinfo, XFS_INODE_TO_FSB(sc->ip),
XFS_AG_RESV_NONE);
xnr->ifake.if_fork = ifp;
xnr->ifake.if_fork_size = xfs_inode_fork_size(sc->ip, XFS_DATA_FORK);
diff --git a/fs/xfs/scrub/trace.c b/fs/xfs/scrub/trace.c
index 70d353287993..e5efc680651f 100644
--- a/fs/xfs/scrub/trace.c
+++ b/fs/xfs/scrub/trace.c
@@ -48,7 +48,7 @@ xchk_btree_cur_fsbno(
if (level == cur->bc_nlevels - 1 &&
cur->bc_ops->type == XFS_BTREE_TYPE_INODE)
- return XFS_INO_TO_FSB(cur->bc_mp, cur->bc_ino.ip->i_ino);
+ return XFS_INODE_TO_FSB(cur->bc_ino.ip);
return NULLFSBLOCK;
}
--
2.53.0
next prev parent reply other threads:[~2026-05-15 13:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 13:50 remove struct xfs_inode.i_ino Christoph Hellwig
2026-05-15 13:50 ` [PATCH 1/9] xfs: add a XFS_INODE_TO_AGNO helper Christoph Hellwig
2026-05-15 13:50 ` [PATCH 2/9] xfs: add a XFS_INODE_TO_AGINO helper Christoph Hellwig
2026-05-15 13:50 ` Christoph Hellwig [this message]
2026-05-15 13:50 ` [PATCH 4/9] xfs: add a xfs_rmap_inode_bmbt_owner Christoph Hellwig
2026-05-15 13:50 ` [PATCH 5/9] xfs: add a xfs_rmap_inode_owner helper Christoph Hellwig
2026-05-15 13:50 ` [PATCH 6/9] xfs: add a xchk_ip_set_corrupt helper Christoph Hellwig
2026-05-15 13:50 ` [PATCH 7/9] xfs: convert xchk_inode_xref_set_corrupt to xchk_ip_xref_set_corrupt Christoph Hellwig
2026-05-15 13:50 ` [PATCH 8/9] xfs: remove xfs_setup_existing_inode Christoph Hellwig
2026-05-15 13:50 ` [PATCH 9/9] xfs: remove the i_ino field in struct xfs_inode Christoph Hellwig
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=20260515135103.4042407-4-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