All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: Christoph Hellwig <hch@lst.de>
Cc: Carlos Maiolino <cem@kernel.org>, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/2] xfs: track the number of blocks in each buftarg
Date: Thu, 18 Sep 2025 07:26:41 +1000	[thread overview]
Message-ID: <aMsnkZwrMTDJdfEc@dread.disaster.area> (raw)
In-Reply-To: <20250916135235.218084-2-hch@lst.de>

On Tue, Sep 16, 2025 at 06:52:31AM -0700, Christoph Hellwig wrote:
> Add a bt_nr_blocks to track the number of blocks in each buftarg, and
> replace the check that hard codes sb_dblock in xfs_buf_map_verify with
> this new value so that it is correct for non-ddev buftargs.  The
> RT buftarg only has a superblock in the first block, so it is unlikely
> to trigger this, or are we likely to ever have enough blocks in the
> in-memory buftargs, but we might as well get the check right.
> 
> Fixes: 10616b806d1d ("xfs: fix _xfs_buf_find oops on blocks beyond the filesystem end")
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_buf.c              | 38 +++++++++++++++++++----------------
>  fs/xfs/xfs_buf.h              |  4 +++-
>  fs/xfs/xfs_buf_item_recover.c |  7 +++++++
>  fs/xfs/xfs_super.c            |  7 ++++---
>  fs/xfs/xfs_trans.c            | 21 +++++++++----------
>  5 files changed, 45 insertions(+), 32 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index f9ef3b2a332a..b9b89f1243a0 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -397,7 +397,7 @@ xfs_buf_map_verify(
>  	 * Corrupted block numbers can get through to here, unfortunately, so we
>  	 * have to check that the buffer falls within the filesystem bounds.
>  	 */
> -	eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks);
> +	eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_nr_blocks);

Why store the number of blocks in filesystem block units? The
buffer cache/buftarg uses daddr addressing, and this is the only
place in the whole buffer cache where we've needed to do filesystem
block to daddr unit conversion.

IMO it should be stored in daddr units to be consistent with all
other buffer cache addresses and length, with the conversion to
daddr units being done by the xfs_configure_buftarg() caller. This
gets rid of this unit conversion in the lookup fast path in addition
to removing to pointer chase through the mount to the superblock.

This means the only remaining fast path references to the xfs_mount
in the lookup path is the stats update code.  If the stats then got
moved to the buftarg, then we don't access the xfs_mount at all in
the buffer cache lookup path except when an error occurs...

Other than that, the code looks fine.

-Dave.
-- 
Dave Chinner
david@fromorbit.com

  reply	other threads:[~2025-09-17 21:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-16 13:52 store the buftarg size in the buftarg v3 Christoph Hellwig
2025-09-16 13:52 ` [PATCH 1/2] xfs: track the number of blocks in each buftarg Christoph Hellwig
2025-09-17 21:26   ` Dave Chinner [this message]
2025-09-16 13:52 ` [PATCH 2/2] xfs: use bt_nr_blocks in xfs_dax_translate_range Christoph Hellwig
2025-09-17 21:29   ` Dave Chinner
  -- strict thread matches above, loose matches on Subject: below --
2025-09-19 13:12 store the buftarg size in the buftarg v4 Christoph Hellwig
2025-09-19 13:12 ` [PATCH 1/2] xfs: track the number of blocks in each buftarg Christoph Hellwig
2025-09-19 17:52   ` Darrick J. Wong
2025-10-13  5:46     ` Darrick J. Wong
2025-10-13  6:29       ` Christoph Hellwig
2025-10-13 14:54         ` Darrick J. Wong
2025-08-25 11:19 store the buftarg size in the buftarg v2 Christoph Hellwig
2025-08-25 11:19 ` [PATCH 1/2] xfs: track the number of blocks in each buftarg Christoph Hellwig
2025-08-25 15:26   ` Darrick J. Wong
2025-08-26 13:28     ` Christoph Hellwig
2025-08-26  5:42   ` Dave Chinner
2025-08-26 13:29     ` Christoph Hellwig
2025-08-18  5:11 store the buftarg size in the buftarg Christoph Hellwig
2025-08-18  5:11 ` [PATCH 1/2] xfs: track the number of blocks in each buftarg Christoph Hellwig
2025-08-18 20:48   ` Darrick J. Wong
2025-08-19  8:06     ` 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=aMsnkZwrMTDJdfEc@dread.disaster.area \
    --to=david@fromorbit.com \
    --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 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.