diff mbox series

[2/2] xfs_scrub: refactor xfs_iterate_inodes_range_check

Message ID 157177012698.1460310.12927607736966109750.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfs_scrub: random fixes | expand

Commit Message

Darrick J. Wong Oct. 22, 2019, 6:48 p.m. UTC
From: Darrick J. Wong <darrick.wong@oracle.com>

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 <darrick.wong@oracle.com>
---
 scrub/inodes.c |   40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

Comments

Eric Sandeen Nov. 1, 2019, 8:51 p.m. UTC | #1
On 10/22/19 1:48 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> Move all the bulkstat action into a single helper function.  This gets
> rid of the awkward name and increases cohesion.

mmm, cohesion.

> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>

Reviewed-by: Eric Sandeen <sandeen@redhat.com>
diff mbox series

Patch

diff --git a/scrub/inodes.c b/scrub/inodes.c
index 7aa61ebe..7c04d7f6 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;