]> git.apps.os.sepia.ceph.com Git - xfsprogs-dev.git/commitdiff
xfs_scrub: fix the work estimation for phase 8
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:12 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:09 +0000 (17:01 -0700)
If there are latent errors on the filesystem, we aren't going to do any
work during phase 8 and it makes no sense to add that into the work
estimate for the progress bar.

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

index e577260a93dda1477bba7d5ae7cf20cb728ea088..dfe62e8d97be6d46fbbe2985690a9df8d8977931 100644 (file)
 
 /* Phase 8: Trim filesystem. */
 
-/* Trim the filesystem, if desired. */
-int
-phase8_func(
+static inline bool
+fstrim_ok(
        struct scrub_ctx        *ctx)
 {
-       if (action_list_empty(ctx->fs_repair_list) &&
-           action_list_empty(ctx->file_repair_list))
-               goto maybe_trim;
-
        /*
         * If errors remain on the filesystem, do not trim anything.  We don't
         * have any threads running, so it's ok to skip the ctx lock here.
         */
-       if (ctx->corruptions_found || ctx->unfixable_errors != 0)
+       if (!action_list_empty(ctx->fs_repair_list))
+               return false;
+       if (!action_list_empty(ctx->file_repair_list))
+               return false;
+
+       if (ctx->corruptions_found != 0)
+               return false;
+       if (ctx->unfixable_errors != 0)
+               return false;
+
+       return true;
+}
+
+/* Trim the filesystem, if desired. */
+int
+phase8_func(
+       struct scrub_ctx        *ctx)
+{
+       if (!fstrim_ok(ctx))
                return 0;
 
-maybe_trim:
        fstrim(ctx);
        progress_add(1);
        return 0;
@@ -51,7 +63,11 @@ phase8_estimate(
        unsigned int            *nr_threads,
        int                     *rshift)
 {
-       *items = 1;
+       *items = 0;
+
+       if (fstrim_ok(ctx))
+               *items = 1;
+
        *nr_threads = 1;
        *rshift = 0;
        return 0;