Linux XFS filesystem development
 help / color / mirror / Atom feed
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 03/12] xfs: split out a lower-level xfs_buf_get_map helper from xfs_find_get_buf
Date: Fri, 24 Jul 2026 09:44:27 -0700	[thread overview]
Message-ID: <20260724164427.GQ2901224@frogsfrogsfrogs> (raw)
In-Reply-To: <20260715145147.95654-4-hch@lst.de>

On Wed, Jul 15, 2026 at 04:50:56PM +0200, Christoph Hellwig wrote:
> xfs_buf_get_map is currently reused to implement xfs_buf_read_map and
> xfs_buf_readahead_map.  This causes double accounting of buf_get stat
> and leads to some ugly overload of the flags.
> 
> Split out a slightly lower-level xfs_find_get_buf helper and use that to
> implement xfs_buf_get_map, xfs_buf_read_map and xfs_buf_readahead_map.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_buf.c | 41 +++++++++++++++++++++++++++++------------
>  1 file changed, 29 insertions(+), 12 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index e56d4b8b0771..2cf359b4c446 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -514,8 +514,8 @@ xfs_buf_find_insert(
>   * cache hits, as metadata intensive workloads will see 3 orders of magnitude
>   * more hits than misses.
>   */
> -int
> -xfs_buf_get_map(
> +static int
> +xfs_find_get_buf(

I like the idea of factoring this out, but I can't tell from the names
what's the difference between xfs_find_get_buf and xfs_buf_get_map.

I might have called the inner function __xfs_buf_get or something.
Dunno, don't care to bikeshed this.

Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

>  	struct xfs_buftarg	*btp,
>  	struct xfs_buf_map	*map,
>  	int			nmaps,
> @@ -552,16 +552,33 @@ xfs_buf_get_map(
>  		return error;
>  	}
>  
> +	*bpp = bp;
> +	return 0;
> +}
> +
> +int
> +xfs_buf_get_map(
> +	struct xfs_buftarg	*btp,
> +	struct xfs_buf_map	*map,
> +	int			nmaps,
> +	xfs_buf_flags_t		flags,
> +	struct xfs_buf		**bpp)
> +{
> +	int			error;
> +
> +	ASSERT(!(flags & ~(XBF_TRYLOCK | XBF_INCORE | XBF_LIVESCAN)));
> +	ASSERT(!(flags & XBF_LIVESCAN) || (flags & XBF_INCORE));
> +
>  	/*
> -	 * Clear b_error if this is a lookup from a caller that doesn't expect
> -	 * valid data to be found in the buffer.
> +	 * Zero the buffer and clear b_error as xfs_buf_get_map callers don't
> +	 * expect valid data to be found in the buffer.
>  	 */
> -	if (!(flags & XBF_READ))
> -		xfs_buf_ioerror(bp, 0);
> -
> +	error = xfs_find_get_buf(btp, map, nmaps, flags, bpp);
> +	if (error)
> +		return error;
>  	XFS_STATS_INC(btp->bt_mount, xb_get);
> -	trace_xfs_buf_get(bp, flags, _RET_IP_);
> -	*bpp = bp;
> +	trace_xfs_buf_get(*bpp, flags, _RET_IP_);
> +	xfs_buf_ioerror(*bpp, 0);
>  	return 0;
>  }
>  
> @@ -625,12 +642,12 @@ xfs_buf_read_map(
>  	struct xfs_buf		*bp;
>  	int			error;
>  
> -	ASSERT(!(flags & (XBF_WRITE | XBF_ASYNC | XBF_READ_AHEAD)));
> +	ASSERT(!(flags & ~XBF_TRYLOCK));
>  
>  	flags |= XBF_READ;
>  	*bpp = NULL;
>  
> -	error = xfs_buf_get_map(target, map, nmaps, flags, &bp);
> +	error = xfs_find_get_buf(target, map, nmaps, flags, &bp);
>  	if (error)
>  		return error;
>  
> @@ -706,7 +723,7 @@ xfs_buf_readahead_map(
>  	if (xfs_buftarg_is_mem(target))
>  		return;
>  
> -	if (xfs_buf_get_map(target, map, nmaps, flags | XBF_TRYLOCK, &bp))
> +	if (xfs_find_get_buf(target, map, nmaps, flags | XBF_TRYLOCK, &bp))
>  		return;
>  	trace_xfs_buf_readahead(bp, 0, _RET_IP_);
>  
> -- 
> 2.53.0
> 
> 

  reply	other threads:[~2026-07-24 16:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-15 14:50 misc buffer cache improvements Christoph Hellwig
2026-07-15 14:50 ` [PATCH 01/12] xfs: don't get a pag reference in xfs_buf_get_map Christoph Hellwig
2026-07-24 16:32   ` Darrick J. Wong
2026-07-15 14:50 ` [PATCH 02/12] xfs: consolidate buffer locking " Christoph Hellwig
2026-07-16 13:12   ` Brian Foster
2026-07-17  8:59     ` Christoph Hellwig
2026-07-17 14:13       ` Brian Foster
2026-07-20  7:59         ` Christoph Hellwig
2026-07-24 16:42           ` Darrick J. Wong
2026-07-28  4:38             ` Christoph Hellwig
2026-07-15 14:50 ` [PATCH 03/12] xfs: split out a lower-level xfs_buf_get_map helper from xfs_find_get_buf Christoph Hellwig
2026-07-24 16:44   ` Darrick J. Wong [this message]
2026-07-28  4:39     ` Christoph Hellwig
2026-07-15 14:50 ` [PATCH 04/12] xfs: remove spurious XBF_DONE clearing on readahead validation failure Christoph Hellwig
2026-07-24 16:45   ` Darrick J. Wong
2026-07-15 14:50 ` [PATCH 05/12] xfs: remove _XBF_LOGRECOVERY Christoph Hellwig
2026-07-24 16:49   ` Darrick J. Wong
2026-07-28  4:39     ` Christoph Hellwig
2026-07-15 14:50 ` [PATCH 06/12] xfs: hide b_flags manipulation from code outside of xfs_buf.c Christoph Hellwig
2026-07-24 16:49   ` Darrick J. Wong
2026-07-15 14:51 ` [PATCH 07/12] xfs: use WRITE_ONCE to update b_flags Christoph Hellwig
2026-07-24 16:53   ` Darrick J. Wong
2026-07-28  4:40     ` Christoph Hellwig
2026-07-15 14:51 ` [PATCH 08/12] xfs: don't reverify buffers in xfs_buf_readahead_map Christoph Hellwig
2026-07-24 16:56   ` Darrick J. Wong
2026-07-15 14:51 ` [PATCH 09/12] xfs: use goto based error unwinding in xfs_buf_read_map Christoph Hellwig
2026-07-24 16:57   ` Darrick J. Wong
2026-07-15 14:51 ` [PATCH 10/12] xfs: merge xfs_buf_reverify into xfs_buf_read_map Christoph Hellwig
2026-07-17 14:13   ` Brian Foster
2026-07-24 16:58   ` Darrick J. Wong
2026-07-15 14:51 ` [PATCH 11/12] xfs: move buffer locking out of xfs_find_get_buf Christoph Hellwig
2026-07-24 16:59   ` Darrick J. Wong
2026-07-15 14:51 ` [PATCH 12/12] xfs: add lockless xfs_buf_readahead_map fast path Christoph Hellwig
2026-07-24 17:03   ` Darrick J. Wong
2026-07-28  4:41     ` Christoph Hellwig
2026-08-10 11:55 ` misc buffer cache improvements Carlos Maiolino
  -- strict thread matches above, loose matches on Subject: below --
2026-07-28  8:11 misc buffer cache improvements v2 Christoph Hellwig
2026-07-28  8:11 ` [PATCH 03/12] xfs: split out a lower-level xfs_buf_get_map helper from xfs_find_get_buf 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=20260724164427.GQ2901224@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