Commit d21d383
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 <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>1 parent fecbcc9 commit d21d383
1 file changed
+11
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
| 330 | + | |
330 | 331 | | |
331 | 332 | | |
332 | 333 | | |
| |||
1540 | 1541 | | |
1541 | 1542 | | |
1542 | 1543 | | |
1543 | | - | |
| 1544 | + | |
1544 | 1545 | | |
1545 | 1546 | | |
1546 | 1547 | | |
1547 | 1548 | | |
| 1549 | + | |
| 1550 | + | |
| 1551 | + | |
1548 | 1552 | | |
1549 | 1553 | | |
1550 | | - | |
| 1554 | + | |
1551 | 1555 | | |
1552 | 1556 | | |
1553 | 1557 | | |
1554 | 1558 | | |
1555 | 1559 | | |
1556 | 1560 | | |
1557 | | - | |
1558 | | - | |
| 1561 | + | |
1559 | 1562 | | |
1560 | | - | |
| 1563 | + | |
| 1564 | + | |
1561 | 1565 | | |
1562 | 1566 | | |
1563 | 1567 | | |
1564 | | - | |
| 1568 | + | |
1565 | 1569 | | |
1566 | 1570 | | |
1567 | 1571 | | |
| |||
0 commit comments