]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xfs: check directory data block header padding in scrub
authorYuto Ohnuki <ytohnuki@amazon.com>
Sat, 11 Apr 2026 14:24:15 +0000 (15:24 +0100)
committerCarlos Maiolino <cem@kernel.org>
Mon, 27 Apr 2026 08:36:36 +0000 (10:36 +0200)
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>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
fs/xfs/scrub/common.c
fs/xfs/scrub/common.h
fs/xfs/scrub/dir.c

index 20e63069088b397ab04127d15f21ae85a7a8a6d0..3d40cb0b2496c4118890d59c4ad99868f40d7270 100644 (file)
@@ -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(
index f2ecc68538f0c380ea45ca528bc91dc9dd71e7b4..b494d747c0084a0d3d1dd79338f3519572bcb43a 100644 (file)
@@ -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,
index e09724cd3725535584176cb766b07c2494e0652f..09715a4aa154bfccaae1e94e57072dc46ec0f7b3 100644 (file)
@@ -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);
+       }
 
        if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
                goto out_buf;