public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Dave Chinner <dgc@kernel.org>
Cc: Yuto Ohnuki <ytohnuki@amazon.com>,
	Carlos Maiolino <cem@kernel.org>,
	linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 2/3] xfs: zero directory data block padding on write verification
Date: Mon, 13 Apr 2026 18:01:00 -0700	[thread overview]
Message-ID: <20260414010100.GA150005@frogsfrogsfrogs> (raw)
In-Reply-To: <ad2M2SH6BQfY0uhH@dread>

On Tue, Apr 14, 2026 at 10:39:53AM +1000, Dave Chinner wrote:
> On Mon, Apr 13, 2026 at 10:59:21AM -0700, Darrick J. Wong wrote:
> > On Sat, Apr 11, 2026 at 03:24:14PM +0100, Yuto Ohnuki wrote:
> > > Old kernels did not zero the pad field in xfs_dir3_data_hdr when
> > > initializing directory data blocks, so existing filesystems may have
> > > non-zero padding on disk.
> > > 
> > > Zero the pad field in xfs_dir3_data_write_verify alongside the existing
> > > LSN and checksum updates. The pad field is pure alignment padding with
> > > no runtime meaning, so zeroing it during write verification is safe and
> > > has no additional I/O cost. This lets filesystems gradually self-heal
> > > stale non-zero padding as directories are modified, without requiring an
> > > explicit repair pass.
> > > 
> > > Suggested-by: Dave Chinner <dgc@kernel.org>
> > > Signed-off-by: Yuto Ohnuki <ytohnuki@amazon.com>
> > > ---
> > >  fs/xfs/libxfs/xfs_dir2_data.c | 6 ++++++
> > >  1 file changed, 6 insertions(+)
> > > 
> > > diff --git a/fs/xfs/libxfs/xfs_dir2_data.c b/fs/xfs/libxfs/xfs_dir2_data.c
> > > index 35ff119aa84b..aecbab61014c 100644
> > > --- a/fs/xfs/libxfs/xfs_dir2_data.c
> > > +++ b/fs/xfs/libxfs/xfs_dir2_data.c
> > > @@ -382,6 +382,7 @@ xfs_dir3_data_write_verify(
> > >  	struct xfs_mount	*mp = bp->b_mount;
> > >  	struct xfs_buf_log_item	*bip = bp->b_log_item;
> > >  	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;
> > > +	struct xfs_dir3_data_hdr *datahdr3 = bp->b_addr;
> > >  	xfs_failaddr_t		fa;
> > >  
> > >  	fa = xfs_dir3_data_verify(bp);
> > > @@ -396,6 +397,11 @@ xfs_dir3_data_write_verify(
> > >  	if (bip)
> > >  		hdr3->lsn = cpu_to_be64(bip->bli_item.li_lsn);
> > >  
> > > +	/*
> > > +	 * Zero padding that may be stale from old kernels.
> > > +	 */
> > > +	datahdr3->pad = 0;
> > 
> > This needs to be gated on the directory block actually having a dir3
> > data header (aka xfs_has_crc()).
> 
> It already is gated correctly - this check is done 5 lines above:
> 
> 	if (!xfs_has_crc(mp))
> 		return;

So it is.  My bad;
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> 
> -Dave.
> 
> -- 
> Dave Chinner
> dgc@kernel.org
> 

  reply	other threads:[~2026-04-14  1:01 UTC|newest]

Thread overview: 9+ 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 [this message]
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

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=20260414010100.GA150005@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