xfs_scrub: don't use statvfs to collect data volume block counts
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.
--- scrub/fscounters.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
scrub/fscounters.c +2 -4
@@ -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;
Quoted 26 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
The function
scrub_scan_estimate_blocksnaï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_FSCOUNTSioctl returns the size and free block count of both volumes correctly, so use that instead.Fixes 604dd3345f35 ("xfs_scrub: filesystem counter collection functions")Signed-off-by Darrick J. Wong <[email protected]>--- scrub/fscounters.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)scrub/fscounters.c +0
-0@@ -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