aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/zpool
diff options
context:
space:
mode:
authorAlexander Motin <[email protected]>2023-06-30 11:47:13 -0400
committerGitHub <[email protected]>2023-06-30 08:47:13 -0700
commitfa7b2390d4982412f9dd27c151bb5ec2da89dcca (patch)
tree6b87a6f3968470b1bbd4e33fffe6836a389a3beb /cmd/zpool
parent6052060c133d0caed0e1bc3ec2c057f8c33e5f7a (diff)
Do not report bytes skipped by scan as issued.
Scan process may skip blocks based on their birth time, DVA, etc. Traditionally those blocks were accounted as issued, that caused reporting of hugely over-inflated numbers, having nothing to do with actual disk I/O. This change utilizes never used field in struct dsl_scan_phys to account such skipped bytes, allowing to report how much data were actually scrubbed/resilvered and what is the actual I/O speed. While formally it is an on-disk format change, it should be compatible both ways, so should not need a feature flag. This should partially address the same issue as c85ac731a0e, but from a different perspective, complementing it. Reviewed-by: Tony Hutter <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Akash B <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15007
Diffstat (limited to 'cmd/zpool')
-rw-r--r--cmd/zpool/zpool_main.c94
1 files changed, 55 insertions, 39 deletions
diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
index 013dd4a23..10a3b5b14 100644
--- a/cmd/zpool/zpool_main.c
+++ b/cmd/zpool/zpool_main.c
@@ -7662,11 +7662,11 @@ static void
print_scan_scrub_resilver_status(pool_scan_stat_t *ps)
{
time_t start, end, pause;
- uint64_t pass_scanned, scanned, pass_issued, issued, total;
+ uint64_t pass_scanned, scanned, pass_issued, issued, total_s, total_i;
uint64_t elapsed, scan_rate, issue_rate;
double fraction_done;
- char processed_buf[7], scanned_buf[7], issued_buf[7], total_buf[7];
- char srate_buf[7], irate_buf[7], time_buf[32];
+ char processed_buf[7], scanned_buf[7], issued_buf[7], total_s_buf[7];
+ char total_i_buf[7], srate_buf[7], irate_buf[7], time_buf[32];
printf(" ");
printf_color(ANSI_BOLD, gettext("scan:"));
@@ -7738,10 +7738,11 @@ print_scan_scrub_resilver_status(pool_scan_stat_t *ps)
pass_scanned = ps->pss_pass_exam;
issued = ps->pss_issued;
pass_issued = ps->pss_pass_issued;
- total = ps->pss_to_examine;
+ total_s = ps->pss_to_examine;
+ total_i = ps->pss_to_examine - ps->pss_skipped;
/* we are only done with a block once we have issued the IO for it */
- fraction_done = (double)issued / total;
+ fraction_done = (double)issued / total_i;
/* elapsed time for this pass, rounding up to 1 if it's 0 */
elapsed = time(NULL) - ps->pss_pass_start;
@@ -7750,26 +7751,25 @@ print_scan_scrub_resilver_status(pool_scan_stat_t *ps)
scan_rate = pass_scanned / elapsed;
issue_rate = pass_issued / elapsed;
- uint64_t total_secs_left = (issue_rate != 0 && total >= issued) ?
- ((total - issued) / issue_rate) : UINT64_MAX;
- secs_to_dhms(total_secs_left, time_buf);
/* format all of the numbers we will be reporting */
zfs_nicebytes(scanned, scanned_buf, sizeof (scanned_buf));
zfs_nicebytes(issued, issued_buf, sizeof (issued_buf));
- zfs_nicebytes(total, total_buf, sizeof (total_buf));
- zfs_nicebytes(scan_rate, srate_buf, sizeof (srate_buf));
- zfs_nicebytes(issue_rate, irate_buf, sizeof (irate_buf));
+ zfs_nicebytes(total_s, total_s_buf, sizeof (total_s_buf));
+ zfs_nicebytes(total_i, total_i_buf, sizeof (total_i_buf));
/* do not print estimated time if we have a paused scrub */
- if (pause == 0) {
- (void) printf(gettext("\t%s scanned at %s/s, "
- "%s issued at %s/s, %s total\n"),
- scanned_buf, srate_buf, issued_buf, irate_buf, total_buf);
- } else {
- (void) printf(gettext("\t%s scanned, %s issued, %s total\n"),
- scanned_buf, issued_buf, total_buf);
+ (void) printf(gettext("\t%s / %s scanned"), scanned_buf, total_s_buf);
+ if (pause == 0 && scan_rate > 0) {
+ zfs_nicebytes(scan_rate, srate_buf, sizeof (srate_buf));
+ (void) printf(gettext(" at %s/s"), srate_buf);
}
+ (void) printf(gettext(", %s / %s issued"), issued_buf, total_i_buf);
+ if (pause == 0 && issue_rate > 0) {
+ zfs_nicebytes(issue_rate, irate_buf, sizeof (irate_buf));
+ (void) printf(gettext(" at %s/s"), irate_buf);
+ }
+ (void) printf(gettext("\n"));
if (is_resilver) {
(void) printf(gettext("\t%s resilvered, %.2f%% done"),
@@ -7782,16 +7782,16 @@ print_scan_scrub_resilver_status(pool_scan_stat_t *ps)
if (pause == 0) {
/*
* Only provide an estimate iff:
- * 1) the time remaining is valid, and
+ * 1) we haven't yet issued all we expected, and
* 2) the issue rate exceeds 10 MB/s, and
* 3) it's either:
* a) a resilver which has started repairs, or
* b) a scrub which has entered the issue phase.
*/
- if (total_secs_left != UINT64_MAX &&
- issue_rate >= 10 * 1024 * 1024 &&
+ if (total_i >= issued && issue_rate >= 10 * 1024 * 1024 &&
((is_resilver && ps->pss_processed > 0) ||
(is_scrub && issued > 0))) {
+ secs_to_dhms((total_i - issued) / issue_rate, time_buf);
(void) printf(gettext(", %s to go\n"), time_buf);
} else {
(void) printf(gettext(", no estimated "
@@ -7803,7 +7803,7 @@ print_scan_scrub_resilver_status(pool_scan_stat_t *ps)
}
static void
-print_rebuild_status_impl(vdev_rebuild_stat_t *vrs, char *vdev_name)
+print_rebuild_status_impl(vdev_rebuild_stat_t *vrs, uint_t c, char *vdev_name)
{
if (vrs == NULL || vrs->vrs_state == VDEV_REBUILD_NONE)
return;
@@ -7815,17 +7815,20 @@ print_rebuild_status_impl(vdev_rebuild_stat_t *vrs, char *vdev_name)
uint64_t bytes_scanned = vrs->vrs_bytes_scanned;
uint64_t bytes_issued = vrs->vrs_bytes_issued;
uint64_t bytes_rebuilt = vrs->vrs_bytes_rebuilt;
- uint64_t bytes_est = vrs->vrs_bytes_est;
+ uint64_t bytes_est_s = vrs->vrs_bytes_est;
+ uint64_t bytes_est_i = vrs->vrs_bytes_est;
+ if (c > offsetof(vdev_rebuild_stat_t, vrs_pass_bytes_skipped) / 8)
+ bytes_est_i -= vrs->vrs_pass_bytes_skipped;
uint64_t scan_rate = (vrs->vrs_pass_bytes_scanned /
(vrs->vrs_pass_time_ms + 1)) * 1000;
uint64_t issue_rate = (vrs->vrs_pass_bytes_issued /
(vrs->vrs_pass_time_ms + 1)) * 1000;
double scan_pct = MIN((double)bytes_scanned * 100 /
- (bytes_est + 1), 100);
+ (bytes_est_s + 1), 100);
/* Format all of the numbers we will be reporting */
char bytes_scanned_buf[7], bytes_issued_buf[7];
- char bytes_rebuilt_buf[7], bytes_est_buf[7];
+ char bytes_rebuilt_buf[7], bytes_est_s_buf[7], bytes_est_i_buf[7];
char scan_rate_buf[7], issue_rate_buf[7], time_buf[32];
zfs_nicebytes(bytes_scanned, bytes_scanned_buf,
sizeof (bytes_scanned_buf));
@@ -7833,9 +7836,8 @@ print_rebuild_status_impl(vdev_rebuild_stat_t *vrs, char *vdev_name)
sizeof (bytes_issued_buf));
zfs_nicebytes(bytes_rebuilt, bytes_rebuilt_buf,
sizeof (bytes_rebuilt_buf));
- zfs_nicebytes(bytes_est, bytes_est_buf, sizeof (bytes_est_buf));
- zfs_nicebytes(scan_rate, scan_rate_buf, sizeof (scan_rate_buf));
- zfs_nicebytes(issue_rate, issue_rate_buf, sizeof (issue_rate_buf));
+ zfs_nicebytes(bytes_est_s, bytes_est_s_buf, sizeof (bytes_est_s_buf));
+ zfs_nicebytes(bytes_est_i, bytes_est_i_buf, sizeof (bytes_est_i_buf));
time_t start = vrs->vrs_start_time;
time_t end = vrs->vrs_end_time;
@@ -7858,17 +7860,29 @@ print_rebuild_status_impl(vdev_rebuild_stat_t *vrs, char *vdev_name)
assert(vrs->vrs_state == VDEV_REBUILD_ACTIVE);
- secs_to_dhms(MAX((int64_t)bytes_est - (int64_t)bytes_scanned, 0) /
- MAX(scan_rate, 1), time_buf);
+ (void) printf(gettext("\t%s / %s scanned"), bytes_scanned_buf,
+ bytes_est_s_buf);
+ if (scan_rate > 0) {
+ zfs_nicebytes(scan_rate, scan_rate_buf, sizeof (scan_rate_buf));
+ (void) printf(gettext(" at %s/s"), scan_rate_buf);
+ }
+ (void) printf(gettext(", %s / %s issued"), bytes_issued_buf,
+ bytes_est_i_buf);
+ if (issue_rate > 0) {
+ zfs_nicebytes(issue_rate, issue_rate_buf,
+ sizeof (issue_rate_buf));
+ (void) printf(gettext(" at %s/s"), issue_rate_buf);
+ }
+ (void) printf(gettext("\n"));
- (void) printf(gettext("\t%s scanned at %s/s, %s issued %s/s, "
- "%s total\n"), bytes_scanned_buf, scan_rate_buf,
- bytes_issued_buf, issue_rate_buf, bytes_est_buf);
(void) printf(gettext("\t%s resilvered, %.2f%% done"),
bytes_rebuilt_buf, scan_pct);
if (vrs->vrs_state == VDEV_REBUILD_ACTIVE) {
- if (scan_rate >= 10 * 1024 * 1024) {
+ if (bytes_est_s >= bytes_scanned &&
+ scan_rate >= 10 * 1024 * 1024) {
+ secs_to_dhms((bytes_est_s - bytes_scanned) / scan_rate,
+ time_buf);
(void) printf(gettext(", %s to go\n"), time_buf);
} else {
(void) printf(gettext(", no estimated "
@@ -7900,7 +7914,7 @@ print_rebuild_status(zpool_handle_t *zhp, nvlist_t *nvroot)
ZPOOL_CONFIG_REBUILD_STATS, (uint64_t **)&vrs, &i) == 0) {
char *name = zpool_vdev_name(g_zfs, zhp,
child[c], VDEV_NAME_TYPE_ID);
- print_rebuild_status_impl(vrs, name);
+ print_rebuild_status_impl(vrs, i, name);
free(name);
}
}
@@ -8005,13 +8019,15 @@ print_scan_status(zpool_handle_t *zhp, nvlist_t *nvroot)
active_resilver = (ps->pss_state == DSS_SCANNING);
}
-
have_resilver = (ps->pss_func == POOL_SCAN_RESILVER);
have_scrub = (ps->pss_func == POOL_SCAN_SCRUB);
scrub_start = ps->pss_start_time;
- have_errorscrub = (ps->pss_error_scrub_func ==
- POOL_SCAN_ERRORSCRUB);
- errorscrub_start = ps->pss_error_scrub_start;
+ if (c > offsetof(pool_scan_stat_t,
+ pss_pass_error_scrub_pause) / 8) {
+ have_errorscrub = (ps->pss_error_scrub_func ==
+ POOL_SCAN_ERRORSCRUB);
+ errorscrub_start = ps->pss_error_scrub_start;
+ }
}
boolean_t active_rebuild = check_rebuilding(nvroot, &rebuild_end_time);