Re: [PATCH v2] xfs: check directory data block header padding in scrub

From: Yuto Ohnuki

Date: Fri Apr 10 2026 - 13:28:13 EST


On Thu, Apr 09, 2026 at 07:38:13AM +1000, Dave Chinner wrote:
> This seems .... a bit of a hack.
>
> For simplicity, performance and long term maintenance of the code,
> we should zero the whole directory block header region
> unconditionally. This means we don't have to change the dir3 blk header
> initialisation code (except to remove the zeroing), we can remove
> the manual bestfree zeroing loop, all the padding (implicit and
> explicit) will be zeroed, and we know that any future
> changes to the dir header structure will automatically be
> initialised to zero....
>
> i.e.
> /* initialise the whole directory header region to zero */
> memset(bp->b_addr, 0, geo->data_entry_offset);

Thank you for the valuable feedback. I'll rework this patch
along these lines.

> You don't need endian conversion on a value of 0.

Understood. I'll fix this, same as the other patch.

> Why only update scrub? Why not add code that unconditionally
> sets the padding to 0 on directory data block writes? e.g. in
> xfs_dir3_data_write_verify() alongside the writing of the LSN into
> the header?
>
> That way any directory that is modified ends up having the padding
> zeroed at runtime with no additional cost, and so filesystems will
> slowly correct themselves over time without needing to run repair...
>
> -Dave.
> --
> Dave Chinner
> dgc@xxxxxxxxxx

Good point, thanks again. I'm also looking into adding self-healing in
xfs_dir3_data_write_verify() and may split the changes into a series
for easier review.

Thanks,
Yuto



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