diff mbox series

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

Message ID 173888086259.2738568.15642483253868951064.stgit@frogsfrogsfrogs (mailing list archive)
State Not Applicable, archived
Headers show
Series [01/17] libxfs: unmap xmbuf pages to avoid disaster | expand

Commit Message

Darrick J. Wong Feb. 6, 2025, 10:34 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

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(-)

Comments

Christoph Hellwig Feb. 7, 2025, 4:43 a.m. UTC | #1
On Thu, Feb 06, 2025 at 02:34:04PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> 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.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>
diff mbox series

Patch

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