mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Yuto Ohnuki <ytohnuki@amazon.com>
Cc: Carlos Maiolino <cem@kernel.org>, Dave Chinner <dgc@kernel.org>,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/3] xfs: check directory data block header padding in scrub
Date: Mon, 13 Apr 2026 11:00:38 -0700	[thread overview]
Message-ID: <20260413180038.GN1048989@frogsfrogsfrogs> (raw)
In-Reply-To: <20260411142411.72194-8-ytohnuki@amazon.com>

On Sat, Apr 11, 2026 at 03:24:15PM +0100, Yuto Ohnuki wrote:
> Add the missing scrub check for the pad field in directory data block
> headers. Old kernels may have written non-zero padding without issue,
> and the write path now self-heals stale padding on modification. Flag
> non-zero padding as an optimization opportunity (preen) rather than
> corruption.
> 
> Add xchk_fblock_set_preen helper for reporting file fork block issues
> that could be optimized. The trace event xchk_fblock_preen already
> exists.
> 
> Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
> ---
>  fs/xfs/scrub/common.c | 11 +++++++++++
>  fs/xfs/scrub/common.h |  2 ++
>  fs/xfs/scrub/dir.c    |  7 ++++++-
>  3 files changed, 19 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/scrub/common.c b/fs/xfs/scrub/common.c
> index 20e63069088b..3d40cb0b2496 100644
> --- a/fs/xfs/scrub/common.c
> +++ b/fs/xfs/scrub/common.c
> @@ -251,6 +251,17 @@ xchk_ino_set_preen(
>  	trace_xchk_ino_preen(sc, ino, __return_address);
>  }
>  
> +/* Record a block indexed by a file fork that could be optimized. */
> +void
> +xchk_fblock_set_preen(
> +	struct xfs_scrub        *sc,
> +	int                     whichfork,
> +	xfs_fileoff_t           offset)
> +{
> +	sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
> +	trace_xchk_fblock_preen(sc, whichfork, offset, __return_address);
> +}
> +
>  /* Record something being wrong with the filesystem primary superblock. */
>  void
>  xchk_set_corrupt(
> diff --git a/fs/xfs/scrub/common.h b/fs/xfs/scrub/common.h
> index f2ecc68538f0..b494d747c008 100644
> --- a/fs/xfs/scrub/common.h
> +++ b/fs/xfs/scrub/common.h
> @@ -25,6 +25,8 @@ bool xchk_fblock_xref_process_error(struct xfs_scrub *sc,
>  void xchk_block_set_preen(struct xfs_scrub *sc,
>  		struct xfs_buf *bp);
>  void xchk_ino_set_preen(struct xfs_scrub *sc, xfs_ino_t ino);
> +void xchk_fblock_set_preen(struct xfs_scrub *sc,
> +		int whichfork, xfs_fileoff_t offset);
>  
>  void xchk_set_corrupt(struct xfs_scrub *sc);
>  void xchk_block_set_corrupt(struct xfs_scrub *sc,
> diff --git a/fs/xfs/scrub/dir.c b/fs/xfs/scrub/dir.c
> index e09724cd3725..09715a4aa154 100644
> --- a/fs/xfs/scrub/dir.c
> +++ b/fs/xfs/scrub/dir.c
> @@ -492,7 +492,12 @@ xchk_directory_data_bestfree(
>  		goto out;
>  	xchk_buffer_recheck(sc, bp);
>  
> -	/* XXX: Check xfs_dir3_data_hdr.pad is zero once we start setting it. */
> +	if (xfs_has_crc(sc->mp)) {
> +		struct xfs_dir3_data_hdr    *hdr3 = bp->b_addr;
> +
> +		if (hdr3->pad)
> +			xchk_fblock_set_preen(sc, XFS_DATA_FORK, lblk);

Looks good!  Thanks for patching this hole :)

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

--D

> +	}
>  
>  	if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
>  		goto out_buf;
> -- 
> 2.50.1
> 
> 
> 
> 
> Amazon Web Services EMEA SARL, 38 avenue John F. Kennedy, L-1855 Luxembourg, R.C.S. Luxembourg B186284
> 
> Amazon Web Services EMEA SARL, Irish Branch, One Burlington Plaza, Burlington Road, Dublin 4, Ireland, branch registration number 908705
> 
> 
> 
> 

  reply	other threads:[~2026-04-13 18:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-11 14:24 [PATCH v3 0/3] xfs: clean up directory data block header padding Yuto Ohnuki
2026-04-11 14:24 ` [PATCH v3 1/3] xfs: zero entire directory data block header region at init Yuto Ohnuki
2026-04-13 17:56   ` Darrick J. Wong
2026-04-11 14:24 ` [PATCH v3 2/3] xfs: zero directory data block padding on write verification Yuto Ohnuki
2026-04-13 17:59   ` Darrick J. Wong
2026-04-14  0:39     ` Dave Chinner
2026-04-14  1:01       ` Darrick J. Wong
2026-04-11 14:24 ` [PATCH v3 3/3] xfs: check directory data block header padding in scrub Yuto Ohnuki
2026-04-13 18:00   ` Darrick J. Wong [this message]
2026-04-27 13:26 ` [PATCH v3 0/3] xfs: clean up directory data block header padding 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=20260413180038.GN1048989@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=cem@kernel.org \
    --cc=dgc@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=ytohnuki@amazon.com \
    /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

all inboxes | Powered by JetHome®