Disabled resilver_defer feature leads to looping resilvers

When a disk is replaced with another on a pool with the resilver_defer
feature present, but not enabled the resilver activity restarts during
each spa_sync. This patch checks to make sure that the resilver_defer
feature is first enabled before requesting a deferred resilver.

This was originally fixed in illumos-joyent as OS-7982.

Reviewed-by: Chris Dunlop <chris@onthe.net.au>
Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Tom Caputi <tcaputi@datto.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Signed-off-by: Kody A Kantor <kody@kkantor.com>
External-issue: illumos-joyent OS-7982
Closes #9299
Closes #9338
This commit is contained in:
Kody A Kantor 2019-09-22 17:25:39 -05:00 committed by Tony Hutter
parent 12a78fbb4f
commit c37fa0d5a8
1 changed files with 11 additions and 8 deletions

View File

@ -23,7 +23,7 @@
* Copyright (c) 2011, 2017 by Delphix. All rights reserved. * Copyright (c) 2011, 2017 by Delphix. All rights reserved.
* Copyright 2016 Gary Mills * Copyright 2016 Gary Mills
* Copyright (c) 2017 Datto Inc. * Copyright (c) 2017 Datto Inc.
* Copyright 2017 Joyent, Inc. * Copyright 2019 Joyent, Inc.
*/ */
#include <sys/dsl_scan.h> #include <sys/dsl_scan.h>
@ -952,15 +952,18 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
* will find the drives that need to be resilvered * will find the drives that need to be resilvered
* when the machine reboots and start the resilver then. * when the machine reboots and start the resilver then.
*/ */
if (spa_feature_is_enabled(spa, SPA_FEATURE_RESILVER_DEFER)) {
boolean_t resilver_needed = boolean_t resilver_needed =
dsl_scan_clear_deferred(spa->spa_root_vdev, tx); dsl_scan_clear_deferred(spa->spa_root_vdev, tx);
if (resilver_needed) { if (resilver_needed) {
spa_history_log_internal(spa, spa_history_log_internal(spa,
"starting deferred resilver", tx, "starting deferred resilver", tx,
"errors=%llu", spa_get_errlog_size(spa)); "errors=%llu",
(u_longlong_t)spa_get_errlog_size(spa));
spa_async_request(spa, SPA_ASYNC_RESILVER); spa_async_request(spa, SPA_ASYNC_RESILVER);
} }
} }
}
scn->scn_phys.scn_end_time = gethrestime_sec(); scn->scn_phys.scn_end_time = gethrestime_sec();