Skip to content

Commit

Permalink
Fix estimated scrub completion time
Browse files Browse the repository at this point in the history
Currently, it is possible for the 'zpool scrub' command to
progress slightly beyond 100% due to concurrent changes
happening on the live pool. This behavior is expected, but
the userspace code for 'zpool status' would subtract the
expected amount of data from the amount of data already
scrubbed, resulting in a negative integer being casted to a
large positive one. This number was then used to calculate
the estimated completion time, resulting in wildly wrong
results. This code changes the behavior so that 'zpool status'
does not attempt to report an estimate during this period.

Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Igor Kozhukhov <igor@dilos.org>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Signed-off-by: Tom Caputi <tcaputi@datto.com>
Closes openzfs#8611 
Closes openzfs#8687
  • Loading branch information
Tom Caputi authored and allanjude committed Jun 15, 2019
1 parent 5832d99 commit 4159602
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -7016,7 +7016,7 @@ print_scan_status(pool_scan_stat_t *ps)

scan_rate = pass_scanned / elapsed;
issue_rate = pass_issued / elapsed;
total_secs_left = (issue_rate != 0) ?
total_secs_left = (issue_rate != 0 && total >= issued) ?
((total - issued) / issue_rate) : UINT64_MAX;

days_left = total_secs_left / 60 / 60 / 24;
Expand Down Expand Up @@ -7050,7 +7050,8 @@ print_scan_status(pool_scan_stat_t *ps)
}

if (pause == 0) {
if (issue_rate >= 10 * 1024 * 1024) {
if (total_secs_left != UINT64_MAX &&
issue_rate >= 10 * 1024 * 1024) {
(void) printf(gettext(", %llu days "
"%02llu:%02llu:%02llu to go\n"),
(u_longlong_t)days_left, (u_longlong_t)hours_left,
Expand Down
4 changes: 4 additions & 0 deletions man/man8/zpool.8
Original file line number Diff line number Diff line change
Expand Up @@ -2189,6 +2189,10 @@ If a scrub is paused, the
resumes it.
If a resilver is in progress, ZFS does not allow a scrub to be started until the
resilver completes.
.Pp
Note that, due to changes in pool data on a live system, it is possible for
scrubs to progress slightly beyond 100% completion. During this period, no
completion time estimate will be provided.
.Bl -tag -width Ds
.It Fl s
Stop scrubbing.
Expand Down

0 comments on commit 4159602

Please sign in to comment.