diff mbox series

[2/5] xfs_scrub: fix broken realtime free blocks unit conversions

Message ID 167658437893.3590000.1698651202541264559.stgit@magnolia (mailing list archive)
State Accepted
Headers show
Series xfsprogs: random fixes for 6.2 | expand

Commit Message

Darrick J. Wong Feb. 16, 2023, 9:52 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

r_blocks is in units of fs blocks, but freertx is in units of realtime
extents.  Add the missing conversion factor so we don't end up with
bogus things like this:

Pretend that sda and sdb are both 100T volumes.

# mkfs.xfs -f /dev/sda -b -r rtdev=/dev/sdb,extsize=2m
# mount /dev/sda /mnt -o rtdev=/dev/sdb
# xfs_scrub -dTvn /mnt
<snip>
Phase 7: Check summary counters.
3.5TiB data used;  99.8TiB realtime data used;  55 inodes used.
2.0GiB data found; 50.0MiB realtime data found; 55 inodes found.
55 inodes counted; 0 inodes checked.

We just created the filesystem, the realtime volume should be empty.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 scrub/fscounters.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Carlos Maiolino Feb. 22, 2023, 8:44 a.m. UTC | #1
On Thu, Feb 16, 2023 at 01:52:58PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> r_blocks is in units of fs blocks, but freertx is in units of realtime
> extents.  Add the missing conversion factor so we don't end up with
> bogus things like this:
> 
> Pretend that sda and sdb are both 100T volumes.
> 
> # mkfs.xfs -f /dev/sda -b -r rtdev=/dev/sdb,extsize=2m
> # mount /dev/sda /mnt -o rtdev=/dev/sdb
> # xfs_scrub -dTvn /mnt
> <snip>
> Phase 7: Check summary counters.
> 3.5TiB data used;  99.8TiB realtime data used;  55 inodes used.
> 2.0GiB data found; 50.0MiB realtime data found; 55 inodes found.
> 55 inodes counted; 0 inodes checked.
> 
> We just created the filesystem, the realtime volume should be empty.
> 
> Signed-off-by: Darrick J. Wong <djwong@kernel.org>

Reviewed-by: Carlos Maiolino <cmaiolino@redhat.com>

> ---
>  scrub/fscounters.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 
> diff --git a/scrub/fscounters.c b/scrub/fscounters.c
> index f21b24e0935..3ceae3715dc 100644
> --- a/scrub/fscounters.c
> +++ b/scrub/fscounters.c
> @@ -138,7 +138,7 @@ scrub_scan_estimate_blocks(
>  	*d_blocks = ctx->mnt.fsgeom.datablocks;
>  	*d_bfree = fc.freedata;
>  	*r_blocks = ctx->mnt.fsgeom.rtblocks;
> -	*r_bfree = fc.freertx;
> +	*r_bfree = fc.freertx * ctx->mnt.fsgeom.rtextsize;
>  	*f_files_used = fc.allocino - fc.freeino;
> 
>  	return 0;
>
diff mbox series

Patch

diff --git a/scrub/fscounters.c b/scrub/fscounters.c
index f21b24e0935..3ceae3715dc 100644
--- a/scrub/fscounters.c
+++ b/scrub/fscounters.c
@@ -138,7 +138,7 @@  scrub_scan_estimate_blocks(
 	*d_blocks = ctx->mnt.fsgeom.datablocks;
 	*d_bfree = fc.freedata;
 	*r_blocks = ctx->mnt.fsgeom.rtblocks;
-	*r_bfree = fc.freertx;
+	*r_bfree = fc.freertx * ctx->mnt.fsgeom.rtextsize;
 	*f_files_used = fc.allocino - fc.freeino;
 
 	return 0;