btrfs-progs/cmds
Qu Wenruo c88ac0170b 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>
2023-06-15 12:24:48 +02:00
..
balance.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
commands.h btrfs-progs: add new group reflink and command 2022-12-07 01:43:30 +01:00
device.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
filesystem-du.c btrfs-progs: introduce UASSERT() for purely userspace code 2023-05-26 18:02:28 +02:00
filesystem-usage.c btrfs-progs: introduce UASSERT() for purely userspace code 2023-05-26 18:02:28 +02:00
filesystem-usage.h btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
filesystem.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
inspect-dump-super.c btrfs-progs: inspect-internal: convert help text to option formatter 2023-02-28 20:11:24 +01:00
inspect-dump-tree.c btrfs-progs: dump-tree: skip tree-checker when dumpping tree blocks 2023-05-26 18:02:32 +02:00
inspect-tree-stats.c btrfs-progs: update read_tree_block to match the kernel definition 2023-05-26 18:02:30 +02:00
inspect.c btrfs-progs: inspect: fix warnings reported by -Wmissing-prototypes 2023-05-26 18:02:31 +02:00
property.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
props.h btrfs-progs: prop set: add force parameter 2021-10-07 18:40:24 +02:00
qgroup.c btrfs-progs: qgroup show: fix formatting of limit values in json output 2023-05-26 18:02:33 +02:00
qgroup.h btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
quota.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
receive-dump.c btrfs-progs: receive: add support for fs-verity 2022-10-11 09:08:08 +02:00
receive-dump.h btrfs-progs: cmds: update include lists 2022-10-11 09:07:59 +02:00
receive.c btrfs-progs: receive: output the parent subvolume uuid if it cannot be found 2023-05-26 18:02:31 +02:00
reflink.c btrfs-progs: fix -Wmissing-prototypes warnings 2023-05-26 18:02:31 +02:00
replace.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
rescue-chunk-recover.c btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block 2023-05-26 18:02:29 +02:00
rescue-super-recover.c btrfs-progs: cmds: update include lists 2022-10-11 09:07:59 +02:00
rescue.c btrfs-progs: pass root_id for btrfs_free_tree_block 2023-05-26 18:02:30 +02:00
rescue.h btrfs-progs: unify GPL header comments 2021-09-07 13:58:44 +02:00
restore.c btrfs-progs: make reada_for_search static 2023-05-26 18:02:30 +02:00
scrub.c btrfs-progs: scrub: unify the output numbers for "Total to scrub" 2023-06-15 12:24:48 +02:00
send.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00
subvolume-list.c btrfs-progs: fix -Wmissing-prototypes warnings 2023-05-26 18:02:31 +02:00
subvolume.c btrfs-progs: sync uapi/btrfs.h into btrfs-progs 2023-05-26 18:02:28 +02:00