xfs: scrub should set preen if attr leaf has holes
authorDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:54:46 +0000 (14:54 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Mon, 15 Apr 2024 21:58:54 +0000 (14:58 -0700)
If an attr block indicates that it could use compaction, set the preen
flag to have the attr fork rebuilt, since the attr fork rebuilder can
take care of that for us.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
fs/xfs/scrub/attr.c
fs/xfs/scrub/dabtree.c
fs/xfs/scrub/dabtree.h
fs/xfs/scrub/trace.h

index 7621e548d73013447264ba643e7d9e4c2e03729a..ba06be86ac7d47e9334c4821884a504bba92e93f 100644 (file)
@@ -428,6 +428,8 @@ xchk_xattr_block(
                xchk_da_set_corrupt(ds, level);
        if (!xchk_xattr_set_map(ds->sc, ab->usedmap, 0, hdrsize))
                xchk_da_set_corrupt(ds, level);
+       if (leafhdr.holes)
+               xchk_da_set_preen(ds, level);
 
        if (ds->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
                goto out;
index c71254088dffe23a73cf4a31d827e347858052b1..056de4819f866d65992d54251ee0b832ac0dd08e 100644 (file)
@@ -78,6 +78,22 @@ xchk_da_set_corrupt(
                        __return_address);
 }
 
+/* Flag a da btree node in need of optimization. */
+void
+xchk_da_set_preen(
+       struct xchk_da_btree    *ds,
+       int                     level)
+{
+       struct xfs_scrub        *sc = ds->sc;
+
+       sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN;
+       trace_xchk_fblock_preen(sc, ds->dargs.whichfork,
+                       xfs_dir2_da_to_db(ds->dargs.geo,
+                               ds->state->path.blk[level].blkno),
+                       __return_address);
+}
+
+/* Find an entry at a certain level in a da btree. */
 static struct xfs_da_node_entry *
 xchk_da_btree_node_entry(
        struct xchk_da_btree            *ds,
index 4f8c2138a1ec66d1de9bfea438bde66efa38fbe3..d654c125feb4d8d7a4d5c4050446ef8fd97a494d 100644 (file)
@@ -35,6 +35,7 @@ bool xchk_da_process_error(struct xchk_da_btree *ds, int level, int *error);
 
 /* Check for da btree corruption. */
 void xchk_da_set_corrupt(struct xchk_da_btree *ds, int level);
+void xchk_da_set_preen(struct xchk_da_btree *ds, int level);
 
 int xchk_da_btree_hash(struct xchk_da_btree *ds, int level, __be32 *hashp);
 int xchk_da_btree(struct xfs_scrub *sc, int whichfork,
index 026813205b4704fe7e11431aa7f933d4b91516c3..ffaff7722bf23383c4665a223730612cf5a1195b 100644 (file)
@@ -365,6 +365,7 @@ DEFINE_EVENT(xchk_fblock_error_class, name, \
 
 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_error);
 DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_warning);
+DEFINE_SCRUB_FBLOCK_ERROR_EVENT(xchk_fblock_preen);
 
 #ifdef CONFIG_XFS_QUOTA
 DECLARE_EVENT_CLASS(xchk_dqiter_class,