Skip to contentSkip to conversation

xfs_scrub: don't use statvfs to collect data volume block counts

PATCH Superseded Darrick J. Wong 2 participants 2 messages Oct 2, 2020 – Oct 4, 2020

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xfs_scrub: don't use statvfs to collect data volume block counts

From: Darrick J. Wong <[email protected]>

The function scrub_scan_estimate_blocks naïvely uses the statvfs counts to estimate the size and free blocks on the data volume. Unfortunately, it fails to account for the fact that statvfs can return the size and free counts for the realtime volume if the root directory has the rtinherit flag set, which leads to phase 7 reporting totally absurd quantities.

The XFS_IOC_FSCOUNTS ioctl returns the size and free block count of both volumes correctly, so use that instead.

Fixes 604dd3345f35 ("xfs_scrub: filesystem counter collection functions")
---
 scrub/fscounters.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
scrub/fscounters.c +2 -4
index f9d64f8c008f..a2ca0b3f018c 100644
@@ -154,10 +154,8 @@ scrub_scan_estimate_blocks(
 
 	sfs.f_bfree += rb.resblks_avail;
 
-	*d_blocks = sfs.f_blocks;
-	if (ctx->mnt.fsgeom.logstart > 0)
-		*d_blocks += ctx->mnt.fsgeom.logblocks;
-	*d_bfree = sfs.f_bfree;
+	*d_blocks = ctx->mnt.fsgeom.datablocks;
+	*d_bfree = fc.freedata;
 	*r_blocks = ctx->mnt.fsgeom.rtblocks;
 	*r_bfree = fc.freertx;
 	*f_files = sfs.f_files;
#1 lore raw
Quoted 26 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

The function scrub_scan_estimate_blocks naïvely uses the statvfs counts to estimate the size and free blocks on the data volume. Unfortunately, it fails to account for the fact that statvfs can return the size and free counts for the realtime volume if the root directory has the rtinherit flag set, which leads to phase 7 reporting totally absurd quantities.

The XFS_IOC_FSCOUNTS ioctl returns the size and free block count of both volumes correctly, so use that instead.

Fixes 604dd3345f35 ("xfs_scrub: filesystem counter collection functions")
---
 scrub/fscounters.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
scrub/fscounters.c +0 -0
index f9d64f8c008f..a2ca0b3f018c 100644
@@ -154,10 +154,8 @@ scrub_scan_estimate_blocks(
 
 	sfs.f_bfree += rb.resblks_avail;

scrub/fscounters.c scrub_scan_estimate_blocks( · line 161

Quoted 10 lines
scrub/fscounters.c +2 -4
 
-	*d_blocks = sfs.f_blocks;
-	if (ctx->mnt.fsgeom.logstart > 0)
-		*d_blocks += ctx->mnt.fsgeom.logblocks;
-	*d_bfree = sfs.f_bfree;
+	*d_blocks = ctx->mnt.fsgeom.datablocks;
+	*d_bfree = fc.freedata;
 	*r_blocks = ctx->mnt.fsgeom.rtblocks;
 	*r_bfree = fc.freertx;
 	*f_files = sfs.f_files;

could this just use fc.freeino/fc.allocino too and drop statvfrsr altogether? (or did I lose track of differences between the counters on the 2 interfaces...)

-Eric