From: Andrey Albershteyn <aalbersh@kernel.org>
To: linux-xfs@vger.kernel.org, aalbersh@kernel.org
Cc: bestswngs@gmail.com, brauner@kernel.org, cem@kernel.org,
chuck.lever@oracle.com, cmaiolino@redhat.com,
dawei.feng@seu.edu.cn, djwong@kernel.org,
gaoyingjie@uniontech.com, hch@lst.de, jiapenglin@tencent.com,
roland.mainz@nrubsig.org, xmei5@asu.edu
Subject: [PATCH v2 04/23] xfs: add a XFS_INODE_TO_AGNO helper
Date: Thu, 3 Sep 2026 13:39:46 +0200 [thread overview]
Message-ID: <20260903114022.570210-5-aalbersh@kernel.org> (raw)
In-Reply-To: <20260903114022.570210-1-aalbersh@kernel.org>
From: Christoph Hellwig <hch@lst.de>
Source kernel commit: a22166add624818a6c43b807d37f99483ba268a6
Add a shortcut for the common XFS_INO_TO_AGNO(mp, ip->i_ino) pattern.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
---
db/iunlink.c | 4 ++--
libxfs/inode.c | 2 +-
libxfs/xfs_dir2.c | 4 ++--
libxfs/xfs_format.h | 2 ++
libxfs/xfs_ialloc.c | 2 +-
libxfs/xfs_inode_util.c | 2 +-
repair/pptr.c | 2 +-
7 files changed, 10 insertions(+), 8 deletions(-)
diff --git a/db/iunlink.c b/db/iunlink.c
index c73f818242b9..20946c967f54 100644
--- a/db/iunlink.c
+++ b/db/iunlink.c
@@ -22,7 +22,7 @@ count_rtblocks(
if (error) {
dbprintf(
_("could not read AG %u agino %u extents, err=%d\n"),
- XFS_INO_TO_AGNO(ip->i_mount, ip->i_ino),
+ XFS_INODE_TO_AGNO(ip),
XFS_INO_TO_AGINO(ip->i_mount, ip->i_ino),
error);
return 0;
@@ -247,7 +247,7 @@ create_unlinked(
dbprintf(_("Created unlinked inode %llu in agno %u\n"),
(unsigned long long)ip->i_ino,
- XFS_INO_TO_AGNO(mp, ip->i_ino));
+ XFS_INODE_TO_AGNO(ip));
libxfs_irele(ip);
return error;
out_rele:
diff --git a/libxfs/inode.c b/libxfs/inode.c
index dc7e227e8ee9..83741b971171 100644
--- a/libxfs/inode.c
+++ b/libxfs/inode.c
@@ -159,7 +159,7 @@ libxfs_iget(
ip->i_prev_unlinked = NULLAGINO;
spin_lock_init(&VFS_I(ip)->i_lock);
- pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
+ pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip));
error = xfs_imap(pag, tp, ip->i_ino, &ip->i_imap, 0);
xfs_perag_put(pag);
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index 1a13fec25e15..562d617254b2 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -918,7 +918,7 @@ xfs_dir_add_child(
if (VFS_I(ip)->i_nlink == 0) {
struct xfs_perag *pag;
- pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
+ pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip));
error = xfs_iunlink_remove(tp, pag, ip);
xfs_perag_put(pag);
if (error)
@@ -1245,7 +1245,7 @@ xfs_dir_rename_children(
ASSERT(VFS_I(du_wip->ip)->i_nlink == 0);
- pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, du_wip->ip->i_ino));
+ pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(du_wip->ip));
error = xfs_iunlink_remove(tp, pag, du_wip->ip);
xfs_perag_put(pag);
if (error)
diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h
index 779dac59b1f3..36a00c174f1e 100644
--- a/libxfs/xfs_format.h
+++ b/libxfs/xfs_format.h
@@ -1276,6 +1276,8 @@ static inline bool xfs_dinode_is_metadir(const struct xfs_dinode *dip)
XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
#define XFS_INO_TO_AGNO(mp,i) \
((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp)))
+#define XFS_INODE_TO_AGNO(ip) \
+ XFS_INO_TO_AGNO((ip)->i_mount, (ip)->i_ino)
#define XFS_INO_TO_AGINO(mp,i) \
((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp)))
#define XFS_INO_TO_AGBNO(mp,i) \
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 31c818f9870f..abfba2bfabaf 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -1865,7 +1865,7 @@ xfs_dialloc_pick_ag(
if (S_ISDIR(mode))
return (atomic_inc_return(&mp->m_agirotor) - 1) % mp->m_maxagi;
- start_agno = XFS_INO_TO_AGNO(mp, dp->i_ino);
+ start_agno = XFS_INODE_TO_AGNO(dp);
if (start_agno >= mp->m_maxagi)
start_agno = 0;
diff --git a/libxfs/xfs_inode_util.c b/libxfs/xfs_inode_util.c
index fd8441bf9b83..8e439dc2f4fa 100644
--- a/libxfs/xfs_inode_util.c
+++ b/libxfs/xfs_inode_util.c
@@ -528,7 +528,7 @@ xfs_iunlink(
ASSERT(VFS_I(ip)->i_mode != 0);
trace_xfs_iunlink(ip);
- pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
+ pag = xfs_perag_get(mp, XFS_INODE_TO_AGNO(ip));
/* Get the agi buffer first. It ensures lock ordering on the list. */
error = xfs_read_agi(pag, tp, 0, &agibp);
diff --git a/repair/pptr.c b/repair/pptr.c
index 6a9e072b360d..dc1ea2288eac 100644
--- a/repair/pptr.c
+++ b/repair/pptr.c
@@ -1050,7 +1050,7 @@ crosscheck_file_parent_ptrs(
struct ag_pptr *ag_pptr, *prev_ag_pptr = NULL;
struct file_pptr *file_pptr;
struct xfs_mount *mp = ip->i_mount;
- xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, ip->i_ino);
+ xfs_agnumber_t agno = XFS_INODE_TO_AGNO(ip);
xfs_agino_t agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
int error;
--
2.55.0
next prev parent reply other threads:[~2026-09-03 11:41 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 11:39 [PATCH v2 00/23] xfsprogs: libxfs sync for v7.2 Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 01/23] libxfs: convert diff_items helpers to cmp_int Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 02/23] xfs: Report case sensitivity in fileattr_get Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 03/23] xfs: fix exchmaps reservation limit check Andrey Albershteyn
2026-09-03 11:39 ` Andrey Albershteyn [this message]
2026-09-03 11:39 ` [PATCH v2 05/23] xfs: add a XFS_INODE_TO_AGINO helper Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 06/23] xfs: add a XFS_INO_TO_FSB helper Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 07/23] xfs: add a xfs_rmap_inode_bmbt_owner Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 08/23] xfs: add a xfs_rmap_inode_owner helper Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 09/23] xfs: remove the i_ino field in struct xfs_inode Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 10/23] xfs: cleanup xfs_imap Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 11/23] xfs: remove im_len field in struct xfs_imap Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 12/23] xfs: massage xfs_imap_to_bp into xfs_read_icluster Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 13/23] xfs: store an agbno in struct xfs_imap Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 14/23] xfs: mark struct xfs_imap as __packed Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 15/23] xfs: fix pointer arithmetic error on 32-bit systems Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 16/23] xfs: pass back updated nb from xfs_growfs_compute_deltas Andrey Albershteyn
2026-09-03 11:39 ` [PATCH v2 17/23] xfs: cleanup xfs_growfs_compute_deltas Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 18/23] xfs: move XFS_LSN_CMP to xfs_log_format.h Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 19/23] xfs: fix memory leak in xfs_dqinode_metadir_create() Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 20/23] xfs: fix null pointer dereference in tracepoint Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 21/23] xfs: fix off-by-one in rtrefcount btree root level validation Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 22/23] xfs: fix exchange-range reflink flag clearing issue with INO1_WRITTEN Andrey Albershteyn
2026-09-03 11:40 ` [PATCH v2 23/23] xfs: check v5 superblock features early Andrey Albershteyn
2026-09-07 5:52 ` [PATCH v2 00/23] xfsprogs: libxfs sync for v7.2 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=20260903114022.570210-5-aalbersh@kernel.org \
--to=aalbersh@kernel.org \
--cc=bestswngs@gmail.com \
--cc=brauner@kernel.org \
--cc=cem@kernel.org \
--cc=chuck.lever@oracle.com \
--cc=cmaiolino@redhat.com \
--cc=dawei.feng@seu.edu.cn \
--cc=djwong@kernel.org \
--cc=gaoyingjie@uniontech.com \
--cc=hch@lst.de \
--cc=jiapenglin@tencent.com \
--cc=linux-xfs@vger.kernel.org \
--cc=roland.mainz@nrubsig.org \
--cc=xmei5@asu.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.