[PATCH 13/17] xfs_scrub: return early from bulkstat_for_inumbers if no bulkstat data

Darrick J. Wong
2025-02-06T22:34:04Z

If bulkstat doesn't return an error code or any bulkstat records, we've
hit the end of the filesystem, so return early. This can happen if the
inumbers data came from the very last inobt record in the filesystem and
every inode in that inobt record is freed immediately after INUMBERS.
There's no bug here, it's just a minor optimization.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
scrub/inodes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/scrub/inodes.c b/scrub/inodes.c
index 4d3ec07b2d9862..3b9026ce8fa2f4 100644
--- a/scrub/inodes.c
+++ b/scrub/inodes.c
@@ -65,7 +65,9 @@ bulkstat_for_inumbers(

/* First we try regular bulkstat, for speed. */
breq->hdr.ino = inumbers->xi_startino;
- xfrog_bulkstat(&ctx->mnt, breq);
+ error = -xfrog_bulkstat(&ctx->mnt, breq);
+ if (!error && !breq->hdr.ocount)
+ return;

/*
* Bulkstat might return inodes beyond xi_startino + CHUNKSIZE. Reduce