]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs_scrub: fix broken realtime free blocks unit conversions
authorDarrick J. Wong <djwong@kernel.org>
Thu, 16 Feb 2023 21:52:58 +0000 (13:52 -0800)
committerCarlos Maiolino <cem@kernel.org>
Thu, 23 Feb 2023 08:54:27 +0000 (09:54 +0100)
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>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
scrub/fscounters.c

index f21b24e0935c8f60ac3048cbb12964866e20b34f..3ceae3715dca6d4f7abd73a97d058842c4f9cf38 100644 (file)
@@ -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;