From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/5] xfs: cleanup xfs_imap
Date: Mon, 1 Jun 2026 21:50:00 -0700 [thread overview]
Message-ID: <20260602045000.GS6078@frogsfrogsfrogs> (raw)
In-Reply-To: <20260601124410.3508980-2-hch@lst.de>
On Mon, Jun 01, 2026 at 02:43:47PM +0200, Christoph Hellwig wrote:
> 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>
This is pretty straightforward so
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/libxfs/xfs_ialloc.c | 64 +++++++++++++++++---------------------
> 1 file changed, 29 insertions(+), 35 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
> index 8d6a4fe4228c..a3fe4e5b1cdd 100644
> --- a/fs/xfs/libxfs/xfs_ialloc.c
> +++ b/fs/xfs/libxfs/xfs_ialloc.c
> @@ -2511,44 +2511,38 @@ 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);
> -
> - 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;
> - }
> + /*
> + * 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;
> + }
>
> - /*
> - * 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;
> + /*
> + * Otherwise we have to do a btree lookup to find the location.
> + */
> }
>
> + error = xfs_imap_lookup(pag, tp, agino, agbno, &chunk_agbno,
> + &offset_agbno, flags);
> + if (error)
> + return error;
> +
> out_map:
> ASSERT(agbno >= chunk_agbno);
> cluster_agbno = chunk_agbno +
> @@ -2556,7 +2550,7 @@ xfs_imap(
> 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.53.0
>
>
next prev parent reply other threads:[~2026-06-02 4:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-01 12:43 shrink struct xfs_imap Christoph Hellwig
2026-06-01 12:43 ` [PATCH 1/5] xfs: cleanup xfs_imap Christoph Hellwig
2026-06-02 4:50 ` Darrick J. Wong [this message]
2026-06-01 12:43 ` [PATCH 2/5] xfs: remove im_len field in struct xfs_imap Christoph Hellwig
2026-06-02 4:43 ` Darrick J. Wong
2026-06-01 12:43 ` [PATCH 3/5] xfs: massage xfs_imap_to_bp into xfs_read_icluster Christoph Hellwig
2026-06-02 4:47 ` Darrick J. Wong
2026-06-02 5:37 ` Christoph Hellwig
2026-06-01 12:43 ` [PATCH 4/5] xfs: store an agbno in struct xfs_imap Christoph Hellwig
2026-06-02 4:49 ` Darrick J. Wong
2026-06-01 12:43 ` [PATCH 5/5] xfs: mark struct xfs_imap as __packed Christoph Hellwig
2026-06-02 4:49 ` Darrick J. Wong
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=20260602045000.GS6078@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=cem@kernel.org \
--cc=hch@lst.de \
--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