]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blobdiff - scrub/phase2.c
xfs_scrub: remove moveon from phase 3 functions
[thirdparty/xfsprogs-dev.git] / scrub / phase2.c
index a80da7fd7858f81bb605d45b4cccafa056d2f14e..7388b8e213adb495c6121d926eb5223bb8d3a585 100644 (file)
@@ -8,8 +8,8 @@
 #include <sys/types.h>
 #include <sys/statvfs.h>
 #include "list.h"
-#include "path.h"
-#include "workqueue.h"
+#include "libfrog/paths.h"
+#include "libfrog/workqueue.h"
 #include "xfs_scrub.h"
 #include "common.h"
 #include "scrub.h"
@@ -26,33 +26,33 @@ xfs_scan_ag_metadata(
 {
        struct scrub_ctx                *ctx = (struct scrub_ctx *)wq->wq_ctx;
        bool                            *pmoveon = arg;
-       struct xfs_action_list          alist;
-       struct xfs_action_list          immediate_alist;
+       struct action_list              alist;
+       struct action_list              immediate_alist;
        unsigned long long              broken_primaries;
        unsigned long long              broken_secondaries;
-       bool                            moveon;
        char                            descr[DESCR_BUFSZ];
+       int                             ret;
 
-       xfs_action_list_init(&alist);
-       xfs_action_list_init(&immediate_alist);
+       action_list_init(&alist);
+       action_list_init(&immediate_alist);
        snprintf(descr, DESCR_BUFSZ, _("AG %u"), agno);
 
        /*
         * First we scrub and fix the AG headers, because we need
         * them to work well enough to check the AG btrees.
         */
-       moveon = xfs_scrub_ag_headers(ctx, agno, &alist);
-       if (!moveon)
+       ret = xfs_scrub_ag_headers(ctx, agno, &alist);
+       if (ret)
                goto err;
 
        /* Repair header damage. */
-       moveon = xfs_action_list_process_or_defer(ctx, agno, &alist);
-       if (!moveon)
+       ret = action_list_process_or_defer(ctx, agno, &alist);
+       if (ret)
                goto err;
 
        /* Now scrub the AG btrees. */
-       moveon = xfs_scrub_ag_metadata(ctx, agno, &alist);
-       if (!moveon)
+       ret = xfs_scrub_ag_metadata(ctx, agno, &alist);
+       if (ret)
                goto err;
 
        /*
@@ -64,7 +64,7 @@ xfs_scan_ag_metadata(
         */
        broken_secondaries = 0;
        broken_primaries = 0;
-       xfs_action_list_find_mustfix(&alist, &immediate_alist,
+       action_list_find_mustfix(&alist, &immediate_alist,
                        &broken_primaries, &broken_secondaries);
        if (broken_secondaries && !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) {
                if (broken_primaries)
@@ -78,12 +78,12 @@ _("Filesystem might not be repairable."));
        }
 
        /* Repair (inode) btree damage. */
-       moveon = xfs_action_list_process_or_defer(ctx, agno, &immediate_alist);
-       if (!moveon)
+       ret = action_list_process_or_defer(ctx, agno, &immediate_alist);
+       if (ret)
                goto err;
 
        /* Everything else gets fixed during phase 4. */
-       xfs_action_list_defer(ctx, agno, &alist);
+       action_list_defer(ctx, agno, &alist);
 
        return;
 err:
@@ -99,15 +99,15 @@ xfs_scan_fs_metadata(
 {
        struct scrub_ctx                *ctx = (struct scrub_ctx *)wq->wq_ctx;
        bool                            *pmoveon = arg;
-       struct xfs_action_list          alist;
-       bool                            moveon;
+       struct action_list              alist;
+       int                             ret;
 
-       xfs_action_list_init(&alist);
-       moveon = xfs_scrub_fs_metadata(ctx, &alist);
-       if (!moveon)
+       action_list_init(&alist);
+       ret = xfs_scrub_fs_metadata(ctx, &alist);
+       if (ret)
                *pmoveon = false;
 
-       xfs_action_list_defer(ctx, agno, &alist);
+       action_list_defer(ctx, agno, &alist);
 }
 
 /* Scan all filesystem metadata. */
@@ -115,7 +115,7 @@ bool
 xfs_scan_metadata(
        struct scrub_ctx        *ctx)
 {
-       struct xfs_action_list  alist;
+       struct action_list      alist;
        struct workqueue        wq;
        xfs_agnumber_t          agno;
        bool                    moveon = true;
@@ -124,7 +124,7 @@ xfs_scan_metadata(
        ret = workqueue_create(&wq, (struct xfs_mount *)ctx,
                        scrub_nproc_workqueue(ctx));
        if (ret) {
-               str_info(ctx, ctx->mntpoint, _("Could not create workqueue."));
+               str_liberror(ctx, ret, _("creating scrub workqueue"));
                return false;
        }
 
@@ -133,20 +133,23 @@ xfs_scan_metadata(
         * upgrades (followed by a full scrub), do that before we launch
         * anything else.
         */
-       xfs_action_list_init(&alist);
-       moveon = xfs_scrub_primary_super(ctx, &alist);
-       if (!moveon)
+       action_list_init(&alist);
+       ret = xfs_scrub_primary_super(ctx, &alist);
+       if (ret) {
+               moveon = false;
                goto out;
-       moveon = xfs_action_list_process_or_defer(ctx, 0, &alist);
-       if (!moveon)
+       }
+       ret = action_list_process_or_defer(ctx, 0, &alist);
+       if (ret) {
+               moveon = false;
                goto out;
+       }
 
        for (agno = 0; moveon && agno < ctx->mnt.fsgeom.agcount; agno++) {
                ret = workqueue_add(&wq, xfs_scan_ag_metadata, agno, &moveon);
                if (ret) {
                        moveon = false;
-                       str_info(ctx, ctx->mntpoint,
-_("Could not queue AG %u scrub work."), agno);
+                       str_liberror(ctx, ret, _("queueing per-AG scrub work"));
                        goto out;
                }
        }
@@ -157,12 +160,16 @@ _("Could not queue AG %u scrub work."), agno);
        ret = workqueue_add(&wq, xfs_scan_fs_metadata, 0, &moveon);
        if (ret) {
                moveon = false;
-               str_info(ctx, ctx->mntpoint,
-_("Could not queue filesystem scrub work."));
+               str_liberror(ctx, ret, _("queueing per-FS scrub work"));
                goto out;
        }
 
 out:
+       ret = workqueue_terminate(&wq);
+       if (ret) {
+               moveon = false;
+               str_liberror(ctx, ret, _("finishing scrub work"));
+       }
        workqueue_destroy(&wq);
        return moveon;
 }
@@ -175,7 +182,7 @@ xfs_estimate_metadata_work(
        unsigned int            *nr_threads,
        int                     *rshift)
 {
-       *items = xfs_scrub_estimate_ag_work(ctx);
+       *items = scrub_estimate_ag_work(ctx);
        *nr_threads = scrub_nproc(ctx);
        *rshift = 0;
        return true;