]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - scrub/phase7.c
xfs_scrub: retry scrub (and repair) of items that are ok except for XFAIL
[thirdparty/xfsprogs-dev.git] / scrub / phase7.c
index 57794d0f609f7beec001911f1f7f37be0eeb3427..84546b1cb5cc2b29047f151cf892ef5b5e8038f0 100644 (file)
@@ -7,6 +7,7 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <sys/statvfs.h>
+#include <linux/fsmap.h>
 #include "libfrog/paths.h"
 #include "libfrog/ptvar.h"
 #include "list.h"
@@ -39,8 +40,8 @@ count_block_summary(
 
        counts = ptvar_get((struct ptvar *)arg, &ret);
        if (ret) {
-               str_liberror(ctx, ret, _("retrieving summary counts"));
-               return ret;
+               str_liberror(ctx, -ret, _("retrieving summary counts"));
+               return -ret;
        }
        if (fsmap->fmr_device == ctx->fsinfo.fs_logdev)
                return 0;
@@ -73,7 +74,7 @@ count_block_summary(
 
 /* Add all the summaries in the per-thread counter */
 static int
-xfs_add_summaries(
+add_summaries(
        struct ptvar            *ptv,
        void                    *data,
        void                    *arg)
@@ -93,12 +94,12 @@ xfs_add_summaries(
  * filesystem we'll be content if the summary counts are within 10% of
  * what we observed.
  */
-bool
-xfs_scan_summary(
+int
+phase7_func(
        struct scrub_ctx        *ctx)
 {
        struct summary_counts   totalcount = {0};
-       struct xfs_action_list  alist;
+       struct action_list      alist;
        struct ptvar            *ptvar;
        unsigned long long      used_data;
        unsigned long long      used_rt;
@@ -111,44 +112,39 @@ xfs_scan_summary(
        unsigned long long      d_bfree;
        unsigned long long      r_blocks;
        unsigned long long      r_bfree;
-       unsigned long long      f_files;
-       unsigned long long      f_free;
-       bool                    moveon;
        bool                    complain;
        int                     ip;
        int                     error;
 
        /* Check and fix the fs summary counters. */
-       xfs_action_list_init(&alist);
-       error = xfs_scrub_fs_summary(ctx, &alist);
+       action_list_init(&alist);
+       error = scrub_fs_summary(ctx, &alist);
        if (error)
-               return false;
-       moveon = xfs_action_list_process(ctx, ctx->mnt.fd, &alist,
+               return error;
+       error = action_list_process(ctx, ctx->mnt.fd, &alist,
                        ALP_COMPLAIN_IF_UNFIXED | ALP_NOPROGRESS);
-       if (!moveon)
-               return moveon;
+       if (error)
+               return error;
 
        /* Flush everything out to disk before we start counting. */
        error = syncfs(ctx->mnt.fd);
        if (error) {
                str_errno(ctx, ctx->mntpoint);
-               return false;
+               return error;
        }
 
-       error = ptvar_alloc(scrub_nproc(ctx), sizeof(struct summary_counts),
+       error = -ptvar_alloc(scrub_nproc(ctx), sizeof(struct summary_counts),
                        &ptvar);
        if (error) {
                str_liberror(ctx, error, _("setting up block counter"));
-               return false;
+               return error;
        }
 
        /* Use fsmap to count blocks. */
        error = scrub_scan_all_spacemaps(ctx, count_block_summary, ptvar);
-       if (error) {
-               moveon = false;
+       if (error)
                goto out_free;
-       }
-       error = ptvar_foreach(ptvar, xfs_add_summaries, &totalcount);
+       error = -ptvar_foreach(ptvar, add_summaries, &totalcount);
        if (error) {
                str_liberror(ctx, error, _("counting blocks"));
                goto out_free;
@@ -159,15 +155,14 @@ xfs_scan_summary(
        error = scrub_count_all_inodes(ctx, &counted_inodes);
        if (error) {
                str_liberror(ctx, error, _("counting inodes"));
-               moveon = false;
-               goto out;
+               return error;
        }
 
        error = scrub_scan_estimate_blocks(ctx, &d_blocks, &d_bfree, &r_blocks,
-                       &r_bfree, &f_files, &f_free);
+                       &r_bfree, &used_files);
        if (error) {
                str_liberror(ctx, error, _("estimating verify work"));
-               return false;
+               return error;
        }
 
        /*
@@ -181,7 +176,6 @@ xfs_scan_summary(
        /* Report on what we found. */
        used_data = cvt_off_fsb_to_b(&ctx->mnt, d_blocks - d_bfree);
        used_rt = cvt_off_fsb_to_b(&ctx->mnt, r_blocks - r_bfree);
-       used_files = f_files - f_free;
        stat_data = totalcount.dbytes;
        stat_rt = totalcount.rbytes;
 
@@ -269,11 +263,8 @@ _("%.1f%s data counted; %.1f%s data verified.\n"),
                fflush(stdout);
        }
 
-       moveon = true;
-
-out:
-       return moveon;
+       return 0;
 out_free:
        ptvar_free(ptvar);
-       return moveon;
+       return error;
 }