]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: fix estimate of work items for phase 4
authorDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jun 2026 01:02:39 +0000 (18:02 -0700)
committerAndrey Albershteyn <aalbersh@kernel.org>
Tue, 30 Jun 2026 09:50:19 +0000 (11:50 +0200)
Codex complains that the number of work items computed when estimating
the amount of work for phase 4 doesn't include the FSCOUNTERS and
QUOTACHECK items.  Add them back in.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase4.c

index 6bd16c23939eb4ee4f047e9a2758d0be06394f70..95fb42f187fc778645f62abc5d198ee8423f2741 100644 (file)
@@ -254,7 +254,8 @@ phase4_func(
         * phase 7, but some of the cross-referencing requires fairly accurate
         * summary counters.  Check and try to repair them now to minimize the
         * chance that repairs of primary metadata fail due to secondary
-        * metadata.  If repairs fails, we'll come back during phase 7.
+        * metadata or ENOSPC on broken counters.  If repairs fails, we'll come
+        * back during phase 7.
         */
        scrub_item_init_fs(&sri);
        scrub_item_schedule(&sri, XFS_SCRUB_TYPE_FSCOUNTERS);
@@ -269,6 +270,10 @@ phase4_func(
        if (ret)
                return ret;
 
+       /*
+        * Try to fix the quota usage counts so that online repair doesn't
+        * fail with EDQUOT (or worse shut down the fs) due to bad counts.
+        */
        if (fsgeom.sick & XFS_FSOP_GEOM_SICK_QUOTACHECK)
                scrub_item_schedule(&sri, XFS_SCRUB_TYPE_QUOTACHECK);
 
@@ -293,10 +298,18 @@ phase4_estimate(
 {
        unsigned long long      need_fixing;
 
-       /* Everything on the repair lis. */
+       /* Everything on the repair lists. */
        need_fixing = action_list_length(ctx->fs_repair_list) +
                      action_list_length(ctx->file_repair_list);
 
+       /*
+        * fscounters and quotacheck are run directly by phase4_func
+        * independent of the repair lists, so put that in the item count.
+        * See phase4_func for why.
+        */
+       if (need_fixing)
+               need_fixing += 2;
+
        *items = need_fixing;
        *nr_threads = scrub_nproc(ctx) + 1;
        *rshift = 0;