]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: collapse trivial file scrub helpers
authorDarrick J. Wong <djwong@kernel.org>
Wed, 18 May 2022 02:48:13 +0000 (22:48 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Wed, 18 May 2022 02:48:13 +0000 (22:48 -0400)
Remove all these trivial file scrub helper functions since they make
tracing code paths difficult and will become annoying in the patches
that follow.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/phase3.c
scrub/scrub.c
scrub/scrub.h

index c7ce0ada6fd7dad3fd67f0358ca410bf2d95fe47..868f444d593e3af8dd8a8144a6b8e93715923811 100644 (file)
 
 /* Phase 3: Scan all inodes. */
 
-/*
- * Run a per-file metadata scanner.  We use the ino/gen interface to
- * ensure that the inode we're checking matches what the inode scan
- * told us to look at.
- */
-static int
-scrub_fd(
-       struct scrub_ctx        *ctx,
-       int                     (*fn)(struct scrub_ctx *ctx, uint64_t ino,
-                                     uint32_t gen, struct action_list *a),
-       struct xfs_bulkstat     *bs,
-       struct action_list      *alist)
-{
-       return fn(ctx, bs->bs_ino, bs->bs_gen, alist);
-}
-
 struct scrub_inode_ctx {
        struct ptcounter        *icount;
        bool                    aborted;
@@ -84,7 +68,7 @@ scrub_inode(
        }
 
        /* Scrub the inode. */
-       error = scrub_fd(ctx, scrub_inode_fields, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_INODE, &alist);
        if (error)
                goto out;
 
@@ -93,13 +77,13 @@ scrub_inode(
                goto out;
 
        /* Scrub all block mappings. */
-       error = scrub_fd(ctx, scrub_data_fork, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTD, &alist);
        if (error)
                goto out;
-       error = scrub_fd(ctx, scrub_attr_fork, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTA, &alist);
        if (error)
                goto out;
-       error = scrub_fd(ctx, scrub_cow_fork, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_BMBTC, &alist);
        if (error)
                goto out;
 
@@ -109,22 +93,21 @@ scrub_inode(
 
        if (S_ISLNK(bstat->bs_mode)) {
                /* Check symlink contents. */
-               error = scrub_symlink(ctx, bstat->bs_ino, bstat->bs_gen,
-                               &alist);
+               error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_SYMLINK, &alist);
        } else if (S_ISDIR(bstat->bs_mode)) {
                /* Check the directory entries. */
-               error = scrub_fd(ctx, scrub_dir, bstat, &alist);
+               error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_DIR, &alist);
        }
        if (error)
                goto out;
 
        /* Check all the extended attributes. */
-       error = scrub_fd(ctx, scrub_attr, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_XATTR, &alist);
        if (error)
                goto out;
 
        /* Check parent pointers. */
-       error = scrub_fd(ctx, scrub_parent, bstat, &alist);
+       error = scrub_file(ctx, bstat, XFS_SCRUB_TYPE_PARENT, &alist);
        if (error)
                goto out;
 
index 4ef19656dcdb08210ab77e98eb26f78493c9d31e..0034f11dd9a388d03eee48decd2ef4748cf81d78 100644 (file)
@@ -446,14 +446,13 @@ scrub_estimate_ag_work(
 }
 
 /*
- * Scrub inode metadata.  If errors occur, this function will log them and
- * return nonzero.
+ * Scrub file metadata of some sort.  If errors occur, this function will log
+ * them and return nonzero.
  */
-static int
-__scrub_file(
+int
+scrub_file(
        struct scrub_ctx                *ctx,
-       uint64_t                        ino,
-       uint32_t                        gen,
+       const struct xfs_bulkstat       *bstat,
        unsigned int                    type,
        struct action_list              *alist)
 {
@@ -464,8 +463,8 @@ __scrub_file(
        assert(xfrog_scrubbers[type].type == XFROG_SCRUB_TYPE_INODE);
 
        meta.sm_type = type;
-       meta.sm_ino = ino;
-       meta.sm_gen = gen;
+       meta.sm_ino = bstat->bs_ino;
+       meta.sm_gen = bstat->bs_gen;
 
        /* Scrub the piece of metadata. */
        fix = xfs_check_metadata(ctx, &meta, true);
@@ -477,86 +476,6 @@ __scrub_file(
        return scrub_save_repair(ctx, alist, &meta);
 }
 
-int
-scrub_inode_fields(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_INODE, alist);
-}
-
-int
-scrub_data_fork(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTD, alist);
-}
-
-int
-scrub_attr_fork(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTA, alist);
-}
-
-int
-scrub_cow_fork(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_BMBTC, alist);
-}
-
-int
-scrub_dir(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_DIR, alist);
-}
-
-int
-scrub_attr(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_XATTR, alist);
-}
-
-int
-scrub_symlink(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_SYMLINK, alist);
-}
-
-int
-scrub_parent(
-       struct scrub_ctx        *ctx,
-       uint64_t                ino,
-       uint32_t                gen,
-       struct action_list      *alist)
-{
-       return __scrub_file(ctx, ino, gen, XFS_SCRUB_TYPE_PARENT, alist);
-}
-
 /*
  * Test the availability of a kernel scrub command.  If errors occur (or the
  * scrub ioctl is rejected) the errors will be logged and this function will
index 537a2ebe8d3b046269256af7b4d75c8a487e18e8..5b5f6b65b095608d35626696c6aa1b0552554940 100644 (file)
@@ -34,22 +34,8 @@ bool can_scrub_symlink(struct scrub_ctx *ctx);
 bool can_scrub_parent(struct scrub_ctx *ctx);
 bool xfs_can_repair(struct scrub_ctx *ctx);
 
-int scrub_inode_fields(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_data_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_attr_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_cow_fork(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_dir(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_attr(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_symlink(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
-int scrub_parent(struct scrub_ctx *ctx, uint64_t ino, uint32_t gen,
-               struct action_list *alist);
+int scrub_file(struct scrub_ctx *ctx, const struct xfs_bulkstat *bstat,
+               unsigned int type, struct action_list *alist);
 
 /* Repair parameters are the scrub inputs and retry count. */
 struct action_item {