mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-16 03:11:11 -04:00
xfs: zero directory data block padding on write verification
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> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Signed-off-by: Carlos Maiolino <cem@kernel.org>
This commit is contained in:
committed by
Carlos Maiolino
parent
00dd8d7ec5
commit
8fbb1877df
@@ -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;
|
||||
|
||||
xfs_buf_update_cksum(bp, XFS_DIR3_DATA_CRC_OFF);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user