Re: [PATCH 05/12] xfs: remove _XBF_LOGRECOVERY

"Darrick J. Wong" <[email protected]>
Newsgroups org.kernel.vger.linux-xfs
Message-ID <20260724164904.GS2901224@frogsfrogsfrogs>
On Wed, Jul 15, 2026 at 04:50:58PM +0200, Christoph Hellwig wrote:
> Adding _XBF_LOGRECOVERY to every buffer write from log recovery is error
> prone.  Instead key off the behavior on log recovery being active with
> indirecting that through a flag.
> 
> Signed-off-by: Christoph Hellwig <[email protected]>

That makes sense.  I suppose if anyone wants to capture ftrace data
they'll see the printk log stating that we're starting and ending
recovery, right?

If yes then
Reviewed-by: "Darrick J. Wong" <[email protected]>

--D

> ---
>  fs/xfs/xfs_buf.c                |  5 ++---
>  fs/xfs/xfs_buf.h                |  4 ----
>  fs/xfs/xfs_buf_item.c           | 10 ++++++----
>  fs/xfs/xfs_buf_item_recover.c   |  3 ---
>  fs/xfs/xfs_dquot_item_recover.c |  1 -
>  fs/xfs/xfs_inode_item_recover.c |  1 -
>  fs/xfs/xfs_log_recover.c        |  5 ++---
>  7 files changed, 10 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/xfs/xfs_buf.c b/fs/xfs/xfs_buf.c
> index 2cf359b4c446..d0146d4fb3d3 100644
> --- a/fs/xfs/xfs_buf.c
> +++ b/fs/xfs/xfs_buf.c
> @@ -1017,7 +1017,7 @@ xfs_buf_ioend_handle_error(
>  	 * We're not going to bother about retrying this during recovery.
>  	 * One strike!
>  	 */
> -	if (bp->b_flags & _XBF_LOGRECOVERY) {
> +	if (mp->m_log && xlog_in_recovery(mp->m_log)) {
>  		xfs_force_shutdown(mp, SHUTDOWN_META_IO_ERROR);
>  		return false;
>  	}
> @@ -1124,8 +1124,7 @@ xfs_buf_ioend(
>  			bp->b_iodone(bp);
>  	}
>  
> -	bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD |
> -			 _XBF_LOGRECOVERY);
> +	bp->b_flags &= ~(XBF_READ | XBF_WRITE | XBF_READ_AHEAD);
>  	if (async)
>  		xfs_buf_relse(bp);
>  }
> diff --git a/fs/xfs/xfs_buf.h b/fs/xfs/xfs_buf.h
> index 79cc9c3f0254..e440f97cf3e1 100644
> --- a/fs/xfs/xfs_buf.h
> +++ b/fs/xfs/xfs_buf.h
> @@ -34,9 +34,6 @@ struct xfs_buf;
>  #define XBF_STALE	 (1u << 6) /* buffer has been staled, do not find it */
>  #define XBF_WRITE_FAIL	 (1u << 7) /* async writes have failed on this buffer */
>  
> -/* buffer type flags for write callbacks */
> -#define _XBF_LOGRECOVERY (1u << 18)/* log recovery buffer */
> -
>  /* flags used only internally */
>  #define _XBF_KMEM	 (1u << 21)/* backed by heap memory */
>  #define _XBF_DELWRI_Q	 (1u << 22)/* buffer on a delwri queue */
> @@ -61,7 +58,6 @@ typedef unsigned int xfs_buf_flags_t;
>  	{ XBF_DONE,		"DONE" }, \
>  	{ XBF_STALE,		"STALE" }, \
>  	{ XBF_WRITE_FAIL,	"WRITE_FAIL" }, \
> -	{ _XBF_LOGRECOVERY,	"LOG_RECOVERY" }, \
>  	{ _XBF_KMEM,		"KMEM" }, \
>  	{ _XBF_DELWRI_Q,	"DELWRI_Q" }, \
>  	/* The following interface flags should never be set */ \
> diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
> index 1f055cd6732e..1a4ef34af8d5 100644
> --- a/fs/xfs/xfs_buf_item.c
> +++ b/fs/xfs/xfs_buf_item.c
> @@ -1066,6 +1066,8 @@ void
>  xfs_buf_item_done(
>  	struct xfs_buf		*bp)
>  {
> +	struct xfs_buf_log_item	*bip = bp->b_log_item;
> +
>  	/*
>  	 * If we are forcibly shutting down, this may well be off the AIL
>  	 * already. That's because we simulate the log-committed callbacks to
> @@ -1078,8 +1080,8 @@ xfs_buf_item_done(
>  	 * Note that log recovery writes might have buffer items that are not on
>  	 * the AIL even when the file system is not shut down.
>  	 */
> -	xfs_trans_ail_delete(&bp->b_log_item->bli_item,
> -			     (bp->b_flags & _XBF_LOGRECOVERY) ? 0 :
> -			     SHUTDOWN_CORRUPT_INCORE);
> -	xfs_buf_item_relse(bp->b_log_item);
> +	xfs_trans_ail_delete(&bip->bli_item,
> +			     xlog_in_recovery(bip->bli_item.li_log) ?
> +			     0 : SHUTDOWN_CORRUPT_INCORE);
> +	xfs_buf_item_relse(bip);
>  }
> diff --git a/fs/xfs/xfs_buf_item_recover.c b/fs/xfs/xfs_buf_item_recover.c
> index 02b95b89d1b5..0a3ab33b0e74 100644
> --- a/fs/xfs/xfs_buf_item_recover.c
> +++ b/fs/xfs/xfs_buf_item_recover.c
> @@ -448,7 +448,6 @@ xlog_recover_validate_buf_type(
>  	if (bp->b_ops) {
>  		struct xfs_buf_log_item	*bip;
>  
> -		bp->b_flags |= _XBF_LOGRECOVERY;
>  		xfs_buf_item_init(bp, mp);
>  		bip = bp->b_log_item;
>  		bip->bli_item.li_lsn = current_lsn;
> @@ -1100,7 +1099,6 @@ xlog_recover_buf_commit_pass2(
>  			xfs_buf_lock(rtsb_bp);
>  			xfs_buf_hold(rtsb_bp);
>  			xfs_update_rtsb(rtsb_bp, bp);
> -			rtsb_bp->b_flags |= _XBF_LOGRECOVERY;
>  			xfs_buf_delwri_queue(rtsb_bp, buffer_list);
>  			xfs_buf_relse(rtsb_bp);
>  		}
> @@ -1139,7 +1137,6 @@ xlog_recover_buf_commit_pass2(
>  		error = xfs_bwrite(bp);
>  	} else {
>  		ASSERT(bp->b_mount == mp);
> -		bp->b_flags |= _XBF_LOGRECOVERY;
>  		xfs_buf_delwri_queue(bp, buffer_list);
>  	}
>  
> diff --git a/fs/xfs/xfs_dquot_item_recover.c b/fs/xfs/xfs_dquot_item_recover.c
> index fe419b28de22..d4dfe1885666 100644
> --- a/fs/xfs/xfs_dquot_item_recover.c
> +++ b/fs/xfs/xfs_dquot_item_recover.c
> @@ -168,7 +168,6 @@ xlog_recover_dquot_commit_pass2(
>  
>  	ASSERT(dq_f->qlf_size == 2);
>  	ASSERT(bp->b_mount == mp);
> -	bp->b_flags |= _XBF_LOGRECOVERY;
>  	xfs_buf_delwri_queue(bp, buffer_list);
>  
>  out_release:
> diff --git a/fs/xfs/xfs_inode_item_recover.c b/fs/xfs/xfs_inode_item_recover.c
> index 169a8fe3bf0a..1d2319ad15c5 100644
> --- a/fs/xfs/xfs_inode_item_recover.c
> +++ b/fs/xfs/xfs_inode_item_recover.c
> @@ -586,7 +586,6 @@ xlog_recover_inode_commit_pass2(
>  	}
>  
>  	ASSERT(bp->b_mount == mp);
> -	bp->b_flags |= _XBF_LOGRECOVERY;
>  	xfs_buf_delwri_queue(bp, buffer_list);
>  
>  out_release:
> diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
> index fdb011e6ef60..e7e49529658b 100644
> --- a/fs/xfs/xfs_log_recover.c
> +++ b/fs/xfs/xfs_log_recover.c
> @@ -3279,9 +3279,8 @@ xlog_do_recovery_pass(
>  			 * checkpoints at this start LSN.
>  			 *
>  			 * Note: Shutting down the filesystem will result in the
> -			 * delwri submission marking all the buffers stale,
> -			 * completing them and cleaning up _XBF_LOGRECOVERY
> -			 * state without doing any IO.
> +			 * delwri submission marking all the buffers stale and
> +			 * completing them without doing any IO.
>  			 */
>  			xlog_force_shutdown(log, SHUTDOWN_LOG_IO_ERROR);
>  		}
> -- 
> 2.53.0
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.