From: Darrick J. Wong Date: Fri, 1 Nov 2019 20:55:28 +0000 (-0400) Subject: xfs_scrub: refactor xfs_iterate_inodes_range_check X-Git-Tag: v5.3.0-rc2~41 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3724c8b82a3206284c16b26d3676aaa1b5f7528;p=thirdparty%2Fxfsprogs-dev.git xfs_scrub: refactor xfs_iterate_inodes_range_check Move all the bulkstat action into a single helper function. This gets rid of the awkward name and increases cohesion. Signed-off-by: Darrick J. Wong Reviewed-by: Eric Sandeen Signed-off-by: Eric Sandeen --- diff --git a/scrub/inodes.c b/scrub/inodes.c index 7aa61ebec..7c04d7f6c 100644 --- a/scrub/inodes.c +++ b/scrub/inodes.c @@ -43,19 +43,37 @@ */ /* - * Did we get exactly the inodes we expected? If not, load them one at a - * time (or fake it) into the bulkstat data. + * Run bulkstat on an entire inode allocation group, then check that we got + * exactly the inodes we expected. If not, load them one at a time (or fake + * it) into the bulkstat data. */ static void -xfs_iterate_inodes_range_check( +bulkstat_for_inumbers( struct scrub_ctx *ctx, - struct xfs_inumbers *inumbers, - struct xfs_bulkstat *bstat) + const char *descr, + const struct xfs_inumbers *inumbers, + struct xfs_bulkstat_req *breq) { + struct xfs_bulkstat *bstat = breq->bulkstat; struct xfs_bulkstat *bs; int i; int error; + /* First we try regular bulkstat, for speed. */ + breq->hdr.ino = inumbers->xi_startino; + breq->hdr.icount = inumbers->xi_alloccount; + error = xfrog_bulkstat(&ctx->mnt, breq); + if (error) { + char errbuf[DESCR_BUFSZ]; + + str_info(ctx, descr, "%s", + strerror_r(error, errbuf, DESCR_BUFSZ)); + } + + /* + * Check each of the stats we got back to make sure we got the inodes + * we asked for. + */ for (i = 0, bs = bstat; i < XFS_INODES_PER_CHUNK; i++) { if (!(inumbers->xi_allocmask & (1ULL << i))) continue; @@ -131,17 +149,7 @@ xfs_iterate_inodes_ag( if (inumbers->xi_alloccount == 0) goto igrp_retry; - breq->hdr.ino = inumbers->xi_startino; - breq->hdr.icount = inumbers->xi_alloccount; - error = xfrog_bulkstat(&ctx->mnt, breq); - if (error) { - char errbuf[DESCR_BUFSZ]; - - str_info(ctx, descr, "%s", strerror_r(error, - errbuf, DESCR_BUFSZ)); - } - - xfs_iterate_inodes_range_check(ctx, inumbers, breq->bulkstat); + bulkstat_for_inumbers(ctx, descr, inumbers, breq); /* Iterate all the inodes. */ for (i = 0, bs = breq->bulkstat;