btrfs-progs/cmds
Graham R. Cobb bb1b07848e btrfs-progs: scrub: Fix scrub cancel/resume not to skip most of the disk
When a scrub completes or is cancelled, statistics are updated for
reporting in a later btrfs scrub status command and for resuming the
scrub. Most statistics (such as bytes scrubbed) are additive so scrub
adds the statistics from the current run to the saved statistics.

However, the last_physical statistic is not additive. The value from the
current run should replace the saved value. The current code incorrectly
adds the last_physical from the current run to the previous saved value.

This bug causes the resume point to be incorrectly recorded, so large
areas of the disk are skipped when the scrub resumes. As an example,
assume a disk had 1000000 bytes and scrub was cancelled and resumed each
time 10% (100000 bytes) had been scrubbed.

Run | Start byte | bytes scrubbed | kernel last_physical | saved last_physical
  1 |          0 |         100000 |               100000 |              100000
  2 |     100000 |         100000 |               200000 |              300000
  3 |     300000 |         100000 |               400000 |              700000
  4 |     700000 |         100000 |               800000 |             1500000
  5 |    1500000 |              0 | immediately completes| completed

In this example, only 40% of the disk is actually scrubbed.

This patch changes the saved/displayed last_physical to track the last
reported value from the kernel.

Signed-off-by: Graham R. Cobb <g.btrfs@cobb.uk.net>
Signed-off-by: David Sterba <dsterba@suse.com>
2019-07-03 20:49:04 +02:00
..
balance.c btrfs-progs: move utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
commands.h btrfs-progs: help: define helper for command with flags 2019-07-03 20:49:04 +02:00
device.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
filesystem-du.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
filesystem-usage.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
filesystem-usage.h btrfs-progs: move all cmds-fi*.c to cmds/ 2019-07-03 20:49:03 +02:00
filesystem.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
inspect-dump-super.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
inspect-dump-tree.c btrfs-progs: build: drop kernel-lib from -I and update paths 2019-07-03 20:49:04 +02:00
inspect-tree-stats.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
inspect.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
property.c btrfs-progs: move utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
qgroup.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
quota.c btrfs-progs: move utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
receive.c btrfs-progs: build: drop kernel-lib from -I and update paths 2019-07-03 20:49:04 +02:00
replace.c btrfs-progs: move utils.[ch] to common/ 2019-07-03 20:49:04 +02:00
rescue-chunk-recover.c btrfs-progs: build: drop kernel-lib from -I and update paths 2019-07-03 20:49:04 +02:00
rescue-super-recover.c btrfs-progs: build: drop kernel-lib from -I and update paths 2019-07-03 20:49:04 +02:00
rescue.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
rescue.h btrfs-progs: move cmds-rescue.c to cmds/ 2019-07-03 20:49:02 +02:00
restore.c btrfs-progs: build: drop kernel-lib from -I and update paths 2019-07-03 20:49:04 +02:00
scrub.c btrfs-progs: scrub: Fix scrub cancel/resume not to skip most of the disk 2019-07-03 20:49:04 +02:00
send.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00
subvolume.c btrfs-progs: fix helpinfo formats, short and options separation 2019-07-03 20:49:04 +02:00