Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
btrfs-progs: scrub: unify the output numbers for "Total to scrub"
[BUG] Command `btrfs scrub start -B` and `btrfs scrub status` are reporting very different results for "Total to scrub": $ sudo btrfs scrub start -B /mnt/btrfs/ scrub done for c107ef62-0a5d-4fd7-a119-b88f38b8e084 Scrub started: Mon Jun 5 07:54:07 2023 Status: finished Duration: 0:00:00 Total to scrub: 1.52GiB Rate: 0.00B/s Error summary: no errors found $ sudo btrfs scrub status /mnt/btrfs/ UUID: c107ef62-0a5d-4fd7-a119-b88f38b8e084 Scrub started: Mon Jun 5 07:54:07 2023 Status: finished Duration: 0:00:00 Total to scrub: 12.00MiB Rate: 0.00B/s Error summary: no errors found This can be very confusing for end users. [CAUSE] It's the function print_fs_stat() handling the "Total to scrub" output. For `btrfs scrub start` command, we use the used bytes (aka, the total used dev extents of a device) for output. This is not really accurate, as the chunks may be mostly empty just like the following: $ btrfs fi df /mnt/btrfs/ Data, single: total=1.01GiB, used=9.06MiB System, DUP: total=40.00MiB, used=64.00KiB Metadata, DUP: total=256.00MiB, used=1.38MiB GlobalReserve, single: total=22.00MiB, used=0.00B Thus we're reporting 1.5GiB to scrub (1.01GiB + 40MiB * 2 + 256MiB * 2). But in reality, we only scrubbed 12MiB (9.06MiB + 64KiB * 2 + 1.38MiB * 2). [FIX] Instead of using the used dev-extent bytes of a device, go with proper scrubbed bytes for each device. This involves print_fs_stat() and print_scrub_dev() called inside scrub_start(). Now the output should match each other. Issue: #636 Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
- Loading branch information