]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: remove action lists from phaseX code
authorDarrick J. Wong <djwong@kernel.org>
Mon, 29 Jul 2024 23:23:05 +0000 (16:23 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 30 Jul 2024 00:01:07 +0000 (17:01 -0700)
Now that we track repair schedules by filesystem object (and not
individual repairs) we can get rid of all the onstack list heads and
whatnot in the phaseX code.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
scrub/phase1.c
scrub/phase2.c
scrub/phase3.c
scrub/phase4.c
scrub/phase5.c
scrub/phase7.c
scrub/scrub.c
scrub/scrub.h

index b1bbc694e6425ef0a9e47be294251bbf9580e1dc..1e56f9fb1ee48564fb2e978ccc732c549d79d382 100644 (file)
@@ -53,7 +53,6 @@ report_to_kernel(
        struct scrub_ctx        *ctx)
 {
        struct scrub_item       sri;
-       struct action_list      alist;
        int                     ret;
 
        if (!ctx->scrub_setup_succeeded || ctx->corruptions_found ||
@@ -62,8 +61,7 @@ report_to_kernel(
                return 0;
 
        scrub_item_init_fs(&sri);
-       action_list_init(&alist);
-       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_HEALTHY, 0, &alist, &sri);
+       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_HEALTHY, &sri);
        if (ret)
                return ret;
 
@@ -74,7 +72,6 @@ report_to_kernel(
        if (repair_item_count_needsrepair(&sri) != 0 &&
            !debug_tweak_on("XFS_SCRUB_FORCE_REPAIR")) {
                str_info(ctx, _("Couldn't upload clean bill of health."), NULL);
-               action_list_discard(&alist);
        }
 
        return 0;
index 26ce5818030529c244355ad45b03ebf4500a68d4..4d4552d8477b5bce8673c55192469199d29cef13 100644 (file)
@@ -61,8 +61,6 @@ scan_ag_metadata(
        struct scrub_item               fix_now;
        struct scrub_ctx                *ctx = (struct scrub_ctx *)wq->wq_ctx;
        struct scan_ctl                 *sctl = arg;
-       struct action_list              alist;
-       struct action_list              immediate_alist;
        char                            descr[DESCR_BUFSZ];
        unsigned int                    difficulty;
        int                             ret;
@@ -71,15 +69,13 @@ scan_ag_metadata(
                return;
 
        scrub_item_init_ag(&sri, agno);
-       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.
         */
-       ret = scrub_ag_headers(ctx, agno, &alist, &sri);
+       ret = scrub_ag_headers(ctx, &sri);
        if (ret)
                goto err;
 
@@ -89,7 +85,7 @@ scan_ag_metadata(
                goto err;
 
        /* Now scrub the AG btrees. */
-       ret = scrub_ag_metadata(ctx, agno, &alist, &sri);
+       ret = scrub_ag_metadata(ctx, &sri);
        if (ret)
                goto err;
 
@@ -126,7 +122,6 @@ scan_fs_metadata(
        void                    *arg)
 {
        struct scrub_item       sri;
-       struct action_list      alist;
        struct scrub_ctx        *ctx = (struct scrub_ctx *)wq->wq_ctx;
        struct scan_ctl         *sctl = arg;
        unsigned int            difficulty;
@@ -136,8 +131,7 @@ scan_fs_metadata(
                goto out;
 
        scrub_item_init_fs(&sri);
-       action_list_init(&alist);
-       ret = scrub_fs_metadata(ctx, type, &alist, &sri);
+       ret = scrub_fs_metadata(ctx, type, &sri);
        if (ret) {
                sctl->aborted = true;
                goto out;
@@ -172,7 +166,6 @@ phase2_func(
                .aborted        = false,
                .rbm_done       = false,
        };
-       struct action_list      alist;
        struct scrub_item       sri;
        const struct xfrog_scrub_descr *sc = xfrog_scrubbers;
        xfs_agnumber_t          agno;
@@ -196,8 +189,7 @@ phase2_func(
         * If errors occur, this function will log them and return nonzero.
         */
        scrub_item_init_ag(&sri, 0);
-       action_list_init(&alist);
-       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_SB, 0, &alist, &sri);
+       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_SB, &sri);
        if (ret)
                goto out_wq;
        ret = repair_item_completely(ctx, &sri);
index e602d8c7ec4d6a19cad8250db063b16cff978d99..fa2eef4dea190ac0ec2df1c446d13f4d83f8cf38 100644 (file)
@@ -107,7 +107,6 @@ scrub_inode(
        struct xfs_bulkstat     *bstat,
        void                    *arg)
 {
-       struct action_list      alist;
        struct scrub_item       sri;
        struct scrub_inode_ctx  *ictx = arg;
        struct ptcounter        *icount = ictx->icount;
@@ -115,7 +114,6 @@ scrub_inode(
        int                     error;
 
        scrub_item_init_file(&sri, bstat);
-       action_list_init(&alist);
        background_sleep();
 
        /*
@@ -146,7 +144,7 @@ scrub_inode(
                fd = scrub_open_handle(handle);
 
        /* Scrub the inode. */
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_INODE, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_INODE, &sri);
        if (error)
                goto out;
 
@@ -155,13 +153,13 @@ scrub_inode(
                goto out;
 
        /* Scrub all block mappings. */
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTD, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTD, &sri);
        if (error)
                goto out;
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTA, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTA, &sri);
        if (error)
                goto out;
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTC, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_BMBTC, &sri);
        if (error)
                goto out;
 
@@ -182,25 +180,24 @@ scrub_inode(
        if (S_ISLNK(bstat->bs_mode) || !bstat->bs_mode) {
                /* Check symlink contents. */
                error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_SYMLINK,
-                               &alist, &sri);
+                               &sri);
                if (error)
                        goto out;
        }
        if (S_ISDIR(bstat->bs_mode) || !bstat->bs_mode) {
                /* Check the directory entries. */
-               error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_DIR, &alist,
-                               &sri);
+               error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_DIR, &sri);
                if (error)
                        goto out;
        }
 
        /* Check all the extended attributes. */
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_XATTR, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_XATTR, &sri);
        if (error)
                goto out;
 
        /* Check parent pointers. */
-       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_PARENT, &alist, &sri);
+       error = scrub_file(ctx, fd, bstat, XFS_SCRUB_TYPE_PARENT, &sri);
        if (error)
                goto out;
 
index 98518635b2b386dae2ea66f76a30e5c4c0e8b48b..230c559f07f3939545bd793bd498100a1baeba49 100644 (file)
@@ -129,7 +129,6 @@ phase4_func(
        struct scrub_ctx        *ctx)
 {
        struct xfs_fsop_geom    fsgeom;
-       struct action_list      alist;
        struct scrub_item       sri;
        int                     ret;
 
@@ -144,8 +143,7 @@ phase4_func(
         * metadata.  If repairs fails, we'll come back during phase 7.
         */
        scrub_item_init_fs(&sri);
-       action_list_init(&alist);
-       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_FSCOUNTERS, 0, &alist, &sri);
+       ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_FSCOUNTERS, &sri);
        if (ret)
                return ret;
 
@@ -160,8 +158,7 @@ phase4_func(
                return ret;
 
        if (fsgeom.sick & XFS_FSOP_GEOM_SICK_QUOTACHECK) {
-               ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_QUOTACHECK, 0,
-                               &alist, &sri);
+               ret = scrub_meta_type(ctx, XFS_SCRUB_TYPE_QUOTACHECK, &sri);
                if (ret)
                        return ret;
        }
@@ -170,7 +167,6 @@ phase4_func(
        ret = repair_item_corruption(ctx, &sri);
        if (ret)
                return ret;
-       action_list_discard(&alist);
 
        ret = repair_everything(ctx);
        if (ret)
index 79bfea8f6b566a623f31f36f9f3e5852a956a77f..6c9a518db4d70286485d58039d9e3c60933f8041 100644 (file)
@@ -386,7 +386,6 @@ out:
 
 struct fs_scan_item {
        struct scrub_item       sri;
-       struct action_list      alist;
        bool                    *abortedp;
        unsigned int            scrub_type;
 };
@@ -413,16 +412,14 @@ fs_scan_worker(
                nanosleep(&tv, NULL);
        }
 
-       ret = scrub_meta_type(ctx, item->scrub_type, 0, &item->alist,
-                       &item->sri);
+       ret = scrub_meta_type(ctx, item->scrub_type, &item->sri);
        if (ret) {
                str_liberror(ctx, ret, _("checking fs scan metadata"));
                *item->abortedp = true;
                goto out;
        }
 
-       ret = action_list_process(ctx, &item->alist,
-                       XRM_FINAL_WARNING | XRM_NOPROGRESS);
+       ret = repair_item_completely(ctx, &item->sri);
        if (ret) {
                str_liberror(ctx, ret, _("repairing fs scan metadata"));
                *item->abortedp = true;
@@ -453,7 +450,6 @@ queue_fs_scan(
                return ret;
        }
        scrub_item_init_fs(&item->sri);
-       action_list_init(&item->alist);
        item->scrub_type = scrub_type;
        item->abortedp = abortedp;
 
index 404bfb822430b253a3ce08c8bd848048e94701aa..02da6b42beb730e5f1890749f39ddfe46bab6102 100644 (file)
@@ -100,7 +100,6 @@ phase7_func(
 {
        struct summary_counts   totalcount = {0};
        struct scrub_item       sri;
-       struct action_list      alist;
        struct ptvar            *ptvar;
        unsigned long long      used_data;
        unsigned long long      used_rt;
@@ -119,8 +118,7 @@ phase7_func(
 
        /* Check and fix the summary metadata. */
        scrub_item_init_fs(&sri);
-       action_list_init(&alist);
-       error = scrub_summary_metadata(ctx, &alist, &sri);
+       error = scrub_summary_metadata(ctx, &sri);
        if (error)
                return error;
        error = repair_item_completely(ctx, &sri);
index 54f397fb92ae1f6e700c493e83e3c51b6bc47727..ca3eea42eceda39b41ad1d9b3f98168c934c368e 100644 (file)
@@ -219,6 +219,7 @@ _("Optimizations of %s are possible."), _(xfrog_scrubbers[i].descr));
 
 /*
  * Scrub a single XFS_SCRUB_TYPE_*, saving corruption reports for later.
+ * Do not call this function to repair file metadata.
  *
  * Returns 0 for success.  If errors occur, this function will log them and
  * return a positive error code.
@@ -227,18 +228,29 @@ int
 scrub_meta_type(
        struct scrub_ctx                *ctx,
        unsigned int                    type,
-       xfs_agnumber_t                  agno,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
        struct xfs_scrub_metadata       meta = {
                .sm_type                = type,
-               .sm_agno                = agno,
        };
        enum check_outcome              fix;
 
        background_sleep();
 
+       switch (xfrog_scrubbers[type].group) {
+       case XFROG_SCRUB_GROUP_AGHEADER:
+       case XFROG_SCRUB_GROUP_PERAG:
+               meta.sm_agno = sri->sri_agno;
+               break;
+       case XFROG_SCRUB_GROUP_FS:
+       case XFROG_SCRUB_GROUP_SUMMARY:
+       case XFROG_SCRUB_GROUP_NONE:
+               break;
+       default:
+               assert(0);
+               break;
+       }
+
        /* Check the item. */
        fix = xfs_check_metadata(ctx, &ctx->mnt, &meta, false);
        progress_add(1);
@@ -267,8 +279,6 @@ static bool
 scrub_group(
        struct scrub_ctx                *ctx,
        enum xfrog_scrub_group          group,
-       xfs_agnumber_t                  agno,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
        const struct xfrog_scrub_descr  *sc;
@@ -281,7 +291,7 @@ scrub_group(
                if (sc->group != group)
                        continue;
 
-               ret = scrub_meta_type(ctx, type, agno, alist, sri);
+               ret = scrub_meta_type(ctx, type, sri);
                if (ret)
                        return ret;
        }
@@ -293,22 +303,18 @@ scrub_group(
 int
 scrub_ag_headers(
        struct scrub_ctx                *ctx,
-       xfs_agnumber_t                  agno,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
-       return scrub_group(ctx, XFROG_SCRUB_GROUP_AGHEADER, agno, alist, sri);
+       return scrub_group(ctx, XFROG_SCRUB_GROUP_AGHEADER, sri);
 }
 
 /* Scrub each AG's metadata btrees. */
 int
 scrub_ag_metadata(
        struct scrub_ctx                *ctx,
-       xfs_agnumber_t                  agno,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
-       return scrub_group(ctx, XFROG_SCRUB_GROUP_PERAG, agno, alist, sri);
+       return scrub_group(ctx, XFROG_SCRUB_GROUP_PERAG, sri);
 }
 
 /* Scrub whole-filesystem metadata. */
@@ -316,22 +322,20 @@ int
 scrub_fs_metadata(
        struct scrub_ctx                *ctx,
        unsigned int                    type,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
        ASSERT(xfrog_scrubbers[type].group == XFROG_SCRUB_GROUP_FS);
 
-       return scrub_meta_type(ctx, type, 0, alist, sri);
+       return scrub_meta_type(ctx, type, sri);
 }
 
 /* Scrub all FS summary metadata. */
 int
 scrub_summary_metadata(
        struct scrub_ctx                *ctx,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
-       return scrub_group(ctx, XFROG_SCRUB_GROUP_SUMMARY, 0, alist, sri);
+       return scrub_group(ctx, XFROG_SCRUB_GROUP_SUMMARY, sri);
 }
 
 /* How many items do we have to check? */
@@ -393,7 +397,6 @@ scrub_file(
        int                             fd,
        const struct xfs_bulkstat       *bstat,
        unsigned int                    type,
-       struct action_list              *alist,
        struct scrub_item               *sri)
 {
        struct xfs_scrub_metadata       meta = {0};
index 0d6825a5a95e9317af98f0034a18a385cb0e1f31..b2e91efac704dbb5004780d2c3eeb761e490cfdb 100644 (file)
@@ -80,18 +80,13 @@ void scrub_item_dump(struct scrub_item *sri, unsigned int group_mask,
                const char *tag);
 
 void scrub_report_preen_triggers(struct scrub_ctx *ctx);
-int scrub_ag_headers(struct scrub_ctx *ctx, xfs_agnumber_t agno,
-               struct action_list *alist, struct scrub_item *sri);
-int scrub_ag_metadata(struct scrub_ctx *ctx, xfs_agnumber_t agno,
-               struct action_list *alist, struct scrub_item *sri);
+int scrub_ag_headers(struct scrub_ctx *ctx, struct scrub_item *sri);
+int scrub_ag_metadata(struct scrub_ctx *ctx, struct scrub_item *sri);
 int scrub_fs_metadata(struct scrub_ctx *ctx, unsigned int scrub_type,
-               struct action_list *alist, struct scrub_item *sri);
-int scrub_iscan_metadata(struct scrub_ctx *ctx, struct action_list *alist,
-               struct scrub_item *sri);
-int scrub_summary_metadata(struct scrub_ctx *ctx, struct action_list *alist,
                struct scrub_item *sri);
+int scrub_iscan_metadata(struct scrub_ctx *ctx, struct scrub_item *sri);
+int scrub_summary_metadata(struct scrub_ctx *ctx, struct scrub_item *sri);
 int scrub_meta_type(struct scrub_ctx *ctx, unsigned int type,
-               xfs_agnumber_t agno, struct action_list *alist,
                struct scrub_item *sri);
 
 bool can_scrub_fs_metadata(struct scrub_ctx *ctx);
@@ -105,7 +100,6 @@ bool can_repair(struct scrub_ctx *ctx);
 bool can_force_rebuild(struct scrub_ctx *ctx);
 
 int scrub_file(struct scrub_ctx *ctx, int fd, const struct xfs_bulkstat *bstat,
-               unsigned int type, struct action_list *alist,
-               struct scrub_item *sri);
+               unsigned int type, struct scrub_item *sri);
 
 #endif /* XFS_SCRUB_SCRUB_H_ */