From: Darrick J. Wong <darrick.wong@xxxxxxxxxx> 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@xxxxxxxxxx> --- scrub/fscounters.c | 22 ++++++---------------- scrub/inodes.c | 20 ++++++-------------- 2 files changed, 12 insertions(+), 30 deletions(-) diff --git a/scrub/fscounters.c b/scrub/fscounters.c index 2fdf658a..a2cf8171 100644 --- a/scrub/fscounters.c +++ b/scrub/fscounters.c @@ -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; } diff --git a/scrub/inodes.c b/scrub/inodes.c index 65c404ab..c7aadae7 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -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; } inogrp = &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 < inogrp->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; }