]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: convert to per-ag inode bulkstat operations
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 30 Sep 2019 20:17:06 +0000 (16:17 -0400)
committerEric Sandeen <sandeen@sandeen.net>
Mon, 30 Sep 2019 20:17:06 +0000 (16:17 -0400)
Now that we're done reworking the xfrog bulkstat wrapper functions, we
can adapt xfs_scrub to use the per-ag iteration functionality.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
scrub/fscounters.c
scrub/inodes.c

index 2fdf658ae66c7524464f57d36136388420ed6c34..a2cf8171e2b8e0c814483a6e8bd75b58b8c4894c 100644 (file)
@@ -35,29 +35,25 @@ struct xfs_count_inodes {
  * exist in the filesystem, assuming we've already scrubbed that.
  */
 static bool
-xfs_count_inodes_range(
+xfs_count_inodes_ag(
        struct scrub_ctx        *ctx,
        const char              *descr,
-       uint64_t                first_ino,
-       uint64_t                last_ino,
+       uint32_t                agno,
        uint64_t                *count)
 {
        struct xfs_inumbers_req *ireq;
        uint64_t                nr = 0;
        int                     error;
 
-       ASSERT(!(first_ino & (XFS_INODES_PER_CHUNK - 1)));
-       ASSERT((last_ino & (XFS_INODES_PER_CHUNK - 1)));
-
-       ireq = xfrog_inumbers_alloc_req(1, first_ino);
+       ireq = xfrog_inumbers_alloc_req(1, 0);
        if (!ireq) {
                str_info(ctx, descr, _("Insufficient memory; giving up."));
                return false;
        }
+       xfrog_inumbers_set_ag(ireq, agno);
 
        while (!(error = xfrog_inumbers(&ctx->mnt, ireq))) {
-               if (ireq->hdr.ocount == 0 ||
-                   ireq->inumbers[0].xi_startino >= last_ino)
+               if (ireq->hdr.ocount == 0)
                        break;
                nr += ireq->inumbers[0].xi_alloccount;
        }
@@ -83,8 +79,6 @@ xfs_count_ag_inodes(
        struct xfs_count_inodes *ci = arg;
        struct scrub_ctx        *ctx = (struct scrub_ctx *)wq->wq_ctx;
        char                    descr[DESCR_BUFSZ];
-       uint64_t                ag_ino;
-       uint64_t                next_ag_ino;
        bool                    moveon;
 
        snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u inodes"),
@@ -92,11 +86,7 @@ xfs_count_ag_inodes(
                                minor(ctx->fsinfo.fs_datadev),
                                agno);
 
-       ag_ino = cvt_agino_to_ino(&ctx->mnt, agno, 0);
-       next_ag_ino = cvt_agino_to_ino(&ctx->mnt, agno + 1, 0);
-
-       moveon = xfs_count_inodes_range(ctx, descr, ag_ino, next_ag_ino - 1,
-                       &ci->counters[agno]);
+       moveon = xfs_count_inodes_ag(ctx, descr, agno, &ci->counters[agno]);
        if (!moveon)
                ci->moveon = false;
 }
index c50f2de6ecd452d56b7d28caa982a85a0845a7a0..dd2aa173b59bbec65b382e388d8fce81c1eaf34a 100644 (file)
@@ -82,12 +82,11 @@ xfs_iterate_inodes_range_check(
  * but we also can detect iget failures.
  */
 static bool
-xfs_iterate_inodes_range(
+xfs_iterate_inodes_ag(
        struct scrub_ctx        *ctx,
        const char              *descr,
        void                    *fshandle,
-       uint64_t                first_ino,
-       uint64_t                last_ino,
+       uint32_t                agno,
        xfs_inode_iter_fn       fn,
        void                    *arg)
 {
@@ -113,13 +112,14 @@ xfs_iterate_inodes_range(
                return false;
        }
 
-       ireq = xfrog_inumbers_alloc_req(1, first_ino);
+       ireq = xfrog_inumbers_alloc_req(1, 0);
        if (!ireq) {
                str_info(ctx, descr, _("Insufficient memory; giving up."));
                free(breq);
                return false;
        }
        inumbers = &ireq->inumbers[0];
+       xfrog_inumbers_set_ag(ireq, agno);
 
        /* Find the inode chunk & alloc mask */
        error = xfrog_inumbers(&ctx->mnt, ireq);
@@ -147,9 +147,6 @@ xfs_iterate_inodes_range(
                for (i = 0, bs = breq->bulkstat;
                     i < inumbers->xi_alloccount;
                     i++, bs++) {
-                       if (bs->bs_ino > last_ino)
-                               goto out;
-
                        handle.ha_fid.fid_ino = bs->bs_ino;
                        handle.ha_fid.fid_gen = bs->bs_gen;
                        error = fn(ctx, &handle, bs, arg);
@@ -214,8 +211,6 @@ xfs_scan_ag_inodes(
        struct xfs_scan_inodes  *si = arg;
        struct scrub_ctx        *ctx = (struct scrub_ctx *)wq->wq_ctx;
        char                    descr[DESCR_BUFSZ];
-       uint64_t                ag_ino;
-       uint64_t                next_ag_ino;
        bool                    moveon;
 
        snprintf(descr, DESCR_BUFSZ, _("dev %d:%d AG %u inodes"),
@@ -223,11 +218,8 @@ xfs_scan_ag_inodes(
                                minor(ctx->fsinfo.fs_datadev),
                                agno);
 
-       ag_ino = cvt_agino_to_ino(&ctx->mnt, agno, 0);
-       next_ag_ino = cvt_agino_to_ino(&ctx->mnt, agno + 1, 0);
-
-       moveon = xfs_iterate_inodes_range(ctx, descr, ctx->fshandle, ag_ino,
-                       next_ag_ino - 1, si->fn, si->arg);
+       moveon = xfs_iterate_inodes_ag(ctx, descr, ctx->fshandle, agno,
+                       si->fn, si->arg);
        if (!moveon)
                si->moveon = false;
 }