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 10/23] xfs: cleanup xfs_imap
Date: Thu, 3 Sep 2026 13:39:52 +0200 [thread overview]
Message-ID: <20260903114022.570210-11-aalbersh@kernel.org> (raw)
In-Reply-To: <20260903114022.570210-1-aalbersh@kernel.org>
From: Christoph Hellwig <hch@lst.de>
Source kernel commit: 41397e7ca8a06507ae6f52f68cd27b0812e9a561
Reshuffle the code a bit so that the imap_lookup and filling out of the
xfs_imap structure aren't duplicated.
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>
---
libxfs/xfs_ialloc.c | 62 ++++++++++++++++++++-------------------------
1 file changed, 28 insertions(+), 34 deletions(-)
diff --git a/libxfs/xfs_ialloc.c b/libxfs/xfs_ialloc.c
index 64f0376a1050..8c42c045924d 100644
--- a/libxfs/xfs_ialloc.c
+++ b/libxfs/xfs_ialloc.c
@@ -2506,43 +2506,37 @@ xfs_imap(
* inodes in stale state on disk. Hence we have to do a btree lookup
* in all cases where an untrusted inode number is passed.
*/
- if (flags & XFS_IGET_UNTRUSTED) {
- error = xfs_imap_lookup(pag, tp, agino, agbno,
- &chunk_agbno, &offset_agbno, flags);
- if (error)
- return error;
- goto out_map;
- }
+ if (!(flags & XFS_IGET_UNTRUSTED)) {
+ /*
+ * If the inode cluster size is the same or smaller than the
+ * blocksize, get to the buffer by simple arithmetics.
+ */
+ if (M_IGEO(mp)->blocks_per_cluster == 1) {
+ cluster_agbno = agbno;
+ offset = XFS_INO_TO_OFFSET(mp, ino);
+ ASSERT(offset < mp->m_sb.sb_inopblock);
+ goto out;
+ }
- /*
- * If the inode cluster size is the same as the blocksize or
- * smaller we get to the buffer by simple arithmetics.
- */
- if (M_IGEO(mp)->blocks_per_cluster == 1) {
- offset = XFS_INO_TO_OFFSET(mp, ino);
- ASSERT(offset < mp->m_sb.sb_inopblock);
+ /*
+ * If the inode chunks are aligned, use simple maths to find the
+ * location.
+ */
+ if (M_IGEO(mp)->inoalign_mask) {
+ offset_agbno = agbno & M_IGEO(mp)->inoalign_mask;
+ chunk_agbno = agbno - offset_agbno;
+ goto out_map;
+ }
- imap->im_blkno = xfs_agbno_to_daddr(pag, agbno);
- imap->im_len = XFS_FSB_TO_BB(mp, 1);
- imap->im_boffset = (unsigned short)(offset <<
- mp->m_sb.sb_inodelog);
- return 0;
+ /*
+ * Otherwise we have to do a btree lookup to find the location.
+ */
}
- /*
- * If the inode chunks are aligned then use simple maths to
- * find the location. Otherwise we have to do a btree
- * lookup to find the location.
- */
- if (M_IGEO(mp)->inoalign_mask) {
- offset_agbno = agbno & M_IGEO(mp)->inoalign_mask;
- chunk_agbno = agbno - offset_agbno;
- } else {
- error = xfs_imap_lookup(pag, tp, agino, agbno,
- &chunk_agbno, &offset_agbno, flags);
- if (error)
- return error;
- }
+ error = xfs_imap_lookup(pag, tp, agino, agbno, &chunk_agbno,
+ &offset_agbno, flags);
+ if (error)
+ return error;
out_map:
ASSERT(agbno >= chunk_agbno);
@@ -2551,7 +2545,7 @@ out_map:
M_IGEO(mp)->blocks_per_cluster);
offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
XFS_INO_TO_OFFSET(mp, ino);
-
+out:
imap->im_blkno = xfs_agbno_to_daddr(pag, cluster_agbno);
imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
--
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 ` [PATCH v2 04/23] xfs: add a XFS_INODE_TO_AGNO helper Andrey Albershteyn
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 ` Andrey Albershteyn [this message]
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-11-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.