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 3/9] xfs: add a xfs_rtblock_payload helper
Date: Thu, 24 Sep 2026 13:13:29 -0700 [thread overview]
Message-ID: <20260924201329.GS2705364@frogsfrogsfrogs> (raw)
In-Reply-To: <20260924095740.2732474-4-hch@lst.de>
On Thu, Sep 24, 2026 at 11:57:04AM +0200, Christoph Hellwig wrote:
> Add a helper to calculate the rtblock payload start with or without the
> self-describing metadata header.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
Nice refactoring!
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/libxfs/xfs_rtbitmap.c | 9 ++-------
> fs/xfs/libxfs/xfs_rtbitmap.h | 27 ++++++++++++---------------
> 2 files changed, 14 insertions(+), 22 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.c b/fs/xfs/libxfs/xfs_rtbitmap.c
> index 5cadde81b5da..01536f4fb386 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.c
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.c
> @@ -1411,7 +1411,6 @@ xfs_rtfile_initialize_block(
> struct xfs_inode *ip = rtg->rtg_inodes[type];
> struct xfs_trans *tp;
> struct xfs_buf *bp;
> - void *bufdata;
> const size_t copylen = mp->m_blockwsize << XFS_WORDLOG;
> int error;
>
> @@ -1427,16 +1426,12 @@ xfs_rtfile_initialize_block(
> xfs_trans_cancel(tp);
> return error;
> }
> - bufdata = bp->b_addr;
>
> xfs_rtfile_initialize_buf(rtg, type, bp, tp);
> -
> - if (xfs_has_rtgroups(mp))
> - bufdata += sizeof(struct xfs_rtbuf_blkinfo);
> if (data)
> - memcpy(bufdata, data, copylen);
> + memcpy(xfs_rtblock_payload(bp), data, copylen);
> else
> - memset(bufdata, 0, copylen);
> + memset(xfs_rtblock_payload(bp), 0, copylen);
> xfs_trans_log_buf(tp, bp, 0, mp->m_sb.sb_blocksize - 1);
> return xfs_trans_commit(tp);
> }
> diff --git a/fs/xfs/libxfs/xfs_rtbitmap.h b/fs/xfs/libxfs/xfs_rtbitmap.h
> index 4a87e1fd3e99..750d74fbf4ed 100644
> --- a/fs/xfs/libxfs/xfs_rtbitmap.h
> +++ b/fs/xfs/libxfs/xfs_rtbitmap.h
> @@ -20,6 +20,16 @@ struct xfs_rtalloc_args {
> xfs_fileoff_t sumoff; /* summary block number */
> };
>
> +/* Return the payload of the buffer after the optional header. */
> +static inline void *
> +xfs_rtblock_payload(
> + struct xfs_buf *bp)
> +{
> + if (!xfs_has_rtgroups(bp->b_mount))
> + return bp->b_addr;
> + return bp->b_addr + sizeof(struct xfs_rtbuf_blkinfo);
> +}
> +
> static inline xfs_rtblock_t
> xfs_rtx_to_rtb(
> struct xfs_rtgroup *rtg,
> @@ -221,14 +231,7 @@ xfs_rbmblock_wordptr(
> struct xfs_rtalloc_args *args,
> unsigned int index)
> {
> - struct xfs_mount *mp = args->mp;
> - union xfs_rtword_raw *words;
> - struct xfs_rtbuf_blkinfo *hdr = args->rbmbp->b_addr;
> -
> - if (xfs_has_rtgroups(mp))
> - words = (union xfs_rtword_raw *)(hdr + 1);
> - else
> - words = args->rbmbp->b_addr;
> + union xfs_rtword_raw *words = xfs_rtblock_payload(args->rbmbp);
>
> return words + index;
> }
> @@ -312,13 +315,7 @@ xfs_rsumblock_infoptr(
> struct xfs_rtalloc_args *args,
> unsigned int index)
> {
> - union xfs_suminfo_raw *info;
> - struct xfs_rtbuf_blkinfo *hdr = args->sumbp->b_addr;
> -
> - if (xfs_has_rtgroups(args->mp))
> - info = (union xfs_suminfo_raw *)(hdr + 1);
> - else
> - info = args->sumbp->b_addr;
> + union xfs_suminfo_raw *info = xfs_rtblock_payload(args->sumbp);
>
> return info + index;
> }
> --
> 2.53.0
>
>
next prev parent reply other threads:[~2026-09-24 20:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 9:57 misc cleanups Christoph Hellwig
2026-09-24 9:57 ` [PATCH 1/9] xfs: centralize setting of buf_ops/buf_type/magic for rtblocks Christoph Hellwig
2026-09-24 19:01 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 2/9] xfs: factor out a xfs_rtfile_initialize_buf helper Christoph Hellwig
2026-09-24 19:02 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 3/9] xfs: add a xfs_rtblock_payload helper Christoph Hellwig
2026-09-24 20:13 ` Darrick J. Wong [this message]
2026-09-24 9:57 ` [PATCH 4/9] xfs: cleanup xfs_verify_media_error Christoph Hellwig
2026-09-24 20:14 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 5/9] xfs: use bdev_rw_virt in xfs_verify_media Christoph Hellwig
2026-09-24 20:18 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 6/9] xfs: lift setting the NOFS context to xfs_end_io Christoph Hellwig
2026-09-24 20:18 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 7/9] xfs: split xfs_end_ioend_write Christoph Hellwig
2026-09-24 20:26 ` Darrick J. Wong
2026-09-25 5:46 ` Christoph Hellwig
2026-09-24 9:57 ` [PATCH 8/9] xfs: factor out a xfs_zoned_fill_srcmap helper Christoph Hellwig
2026-09-24 20:27 ` Darrick J. Wong
2026-09-24 9:57 ` [PATCH 9/9] xfs: calculate end_fsb later in xfs_zoned_fill_srcmap Christoph Hellwig
2026-09-24 20:29 ` Darrick J. Wong
2026-10-05 18:06 ` misc cleanups 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=20260924201329.GS2705364@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