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 10/12] xfs: merge xfs_buf_reverify into xfs_buf_read_map
Date: Fri, 24 Jul 2026 09:58:54 -0700	[thread overview]
Message-ID: <20260724165854.GX2901224@frogsfrogsfrogs> (raw)
In-Reply-To: <20260715145147.95654-11-hch@lst.de>

On Wed, Jul 15, 2026 at 04:51:03PM +0200, Christoph Hellwig wrote:
> xfs_buf_read_map is the only caller of xfs_buf_reverify that is left.
> Merge it into that so that the comments can be moved closer to the
> logic, and redundant asserts can be removed.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
>  fs/xfs/xfs_buf.c | 79 ++++++++++++++++++++++--------------------------
>  1 file changed, 36 insertions(+), 43 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 21c21491d72e..be3b25ccbea6 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -626,41 +626,6 @@ _xfs_buf_read(
>  	return xfs_buf_iowait(bp);
>  }
>  
> -/*
> - * Reverify a buffer found in cache without an attached ->b_ops.
> - *
> - * If the caller passed an ops structure and the buffer doesn't have ops
> - * assigned, set the ops and use it to verify the contents. If verification
> - * fails, clear XBF_DONE. We assume the buffer has no recorded errors and is
> - * already in XBF_DONE state on entry.
> - *
> - * Under normal operations, every in-core buffer is verified on read I/O
> - * completion. There are two scenarios that can lead to in-core buffers without
> - * an assigned ->b_ops. The first is during log recovery of buffers on a V4
> - * filesystem, though these buffers are purged at the end of recovery. The
> - * other is online repair, which intentionally reads with a NULL buffer ops to
> - * run several verifiers across an in-core buffer in order to establish buffer
> - * type.  If repair can't establish that, the buffer will be left in memory
> - * with NULL buffer ops.
> - */
> -static int
> -xfs_buf_reverify(
> -	struct xfs_buf		*bp,
> -	const struct xfs_buf_ops *ops)
> -{
> -	ASSERT(bp->b_flags & XBF_DONE);
> -	ASSERT(bp->b_error == 0);
> -
> -	if (!ops || bp->b_ops)
> -		return 0;
> -
> -	bp->b_ops = ops;
> -	bp->b_ops->verify_read(bp);
> -	if (bp->b_error)
> -		xfs_buf_clear_flags(bp, XBF_DONE);
> -	return bp->b_error;
> -}
> -
>  int
>  xfs_buf_read_map(
>  	struct xfs_buftarg	*target,
> @@ -685,18 +650,46 @@ xfs_buf_read_map(
>  
>  	trace_xfs_buf_read(bp, flags, _RET_IP_);
>  
> -	if (!(bp->b_flags & XBF_DONE)) {
> +	if (bp->b_flags & XBF_DONE) {
> +		ASSERT(bp->b_error == 0);
> +
> +		/*
> +		 * If the caller passed an ops structure and the buffer doesn't
> +		 * have ops assigned yet, set the ops and use them to verify the
> +		 * buffer contents.
> +		 *
> +		 * Under normal operations, every in-core buffer is verified on
> +		 * read I/O completion, but there are two scenarios that can
> +		 * lead to in-core buffers without an assigned ->b_ops:
> +		 *
> +		 *   1) During log recovery of buffers on a V4 filesystem.
> +		 *	These buffers are purged at the end of recovery, though.
> +		 *   2) Oonline repair intentionally reads with a NULL buffer

s/Oonline/Online/ like bfoster said.

With that fixed,
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> +		 *	ops to run several verifiers across an in-core buffer in
> +		 *	order to establish buffer type.  If repair can't
> +		 *	establish that, the buffer will be left in memory with
> +		 *	NULL buffer ops.
> +		 */
> +		if (ops && !bp->b_ops) {
> +			bp->b_ops = ops;
> +			bp->b_ops->verify_read(bp);
> +			/*
> +			 * If verification failed, clear XBF_DONE as we assume
> +			 * that buffers have no recorded errors when in XBF_DONE
> +			 * state.
> +			 */
> +			error = bp->b_error;
> +			if (error)
> +				xfs_buf_clear_flags(bp, XBF_DONE);
> +		}
> +
> +		/* We do not want read in the flags */
> +		xfs_buf_clear_flags(bp, XBF_READ);
> +	} else {
>  		/* Initiate the buffer read and wait. */
>  		XFS_STATS_INC(target->bt_mount, xb_get_read);
>  		bp->b_ops = ops;
>  		error = _xfs_buf_read(bp);
> -	} else {
> -		/* Buffer already read; all we need to do is check it. */
> -		error = xfs_buf_reverify(bp, ops);
> -
> -		/* We do not want read in the flags */
> -		xfs_buf_clear_flags(bp, XBF_READ);
> -		ASSERT(bp->b_ops != NULL || ops == NULL);
>  	}
>  
>  	if (error)
> -- 
> 2.53.0
> 
> 

  parent reply	other threads:[~2026-07-24 16:58 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
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 [this message]
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 10/12] xfs: merge xfs_buf_reverify into xfs_buf_read_map 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=20260724165854.GX2901224@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