-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent unnecessary resilver restarts
If a device is participating in an active resilver, then it will have a non-empty DTL. Operations like vdev_{open,reopen,probe}() can cause the resilver to be restarted (or deferred to be restarted later), which is unnecessary if the DTL is still covered by the current scan range. This is similar to the logic in vdev_dtl_should_excise() where the DTL can only be excised if it's max txg is in the resilvered range. Signed-off-by: John Poduska <[email protected]>
- Loading branch information
Showing
14 changed files
with
409 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
* Copyright 2016 Toomas Soome <[email protected]> | ||
* Copyright (c) 2016 Actifio, Inc. All rights reserved. | ||
* Copyright 2018 Joyent, Inc. | ||
* Copyright (c) 2017 Datto Inc. | ||
* Copyright (c) 2017, 2019, Datto Inc. All rights reserved. | ||
* Copyright 2017 Joyent, Inc. | ||
* Copyright (c) 2017, Intel Corporation. | ||
*/ | ||
|
@@ -6718,9 +6718,9 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing) | |
*/ | ||
if (dsl_scan_resilvering(spa_get_dsl(spa)) && | ||
spa_feature_is_enabled(spa, SPA_FEATURE_RESILVER_DEFER)) | ||
vdev_set_deferred_resilver(spa, newvd); | ||
vdev_defer_resilver(newvd); | ||
else | ||
dsl_resilver_restart(spa->spa_dsl_pool, dtl_max_txg); | ||
dsl_scan_restart_resilver(spa->spa_dsl_pool, dtl_max_txg); | ||
|
||
if (spa->spa_bootfs) | ||
spa_event_notify(spa, newvd, NULL, ESC_ZFS_BOOTFS_VDEV_ATTACH); | ||
|
@@ -7957,7 +7957,7 @@ spa_async_thread(void *arg) | |
if (tasks & SPA_ASYNC_RESILVER && | ||
(!dsl_scan_resilvering(dp) || | ||
!spa_feature_is_enabled(dp->dp_spa, SPA_FEATURE_RESILVER_DEFER))) | ||
dsl_resilver_restart(dp, 0); | ||
dsl_scan_restart_resilver(dp, 0); | ||
|
||
if (tasks & SPA_ASYNC_INITIALIZE_RESTART) { | ||
mutex_enter(&spa_namespace_lock); | ||
|
@@ -8088,6 +8088,12 @@ spa_async_request(spa_t *spa, int task) | |
mutex_exit(&spa->spa_async_lock); | ||
} | ||
|
||
int | ||
spa_async_tasks(spa_t *spa) | ||
{ | ||
return (spa->spa_async_tasks); | ||
} | ||
|
||
/* | ||
* ========================================================================== | ||
* SPA syncing routines | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
* Copyright 2016 Toomas Soome <[email protected]> | ||
* Copyright 2017 Joyent, Inc. | ||
* Copyright (c) 2017, Intel Corporation. | ||
* Copyright (c) 2019, Datto Inc. All rights reserved. | ||
*/ | ||
|
||
#include <sys/zfs_context.h> | ||
|
@@ -835,7 +836,7 @@ vdev_alloc(spa_t *spa, vdev_t **vdp, nvlist_t *nv, vdev_t *parent, uint_t id, | |
&vd->vdev_resilver_txg); | ||
|
||
if (nvlist_exists(nv, ZPOOL_CONFIG_RESILVER_DEFER)) | ||
vdev_set_deferred_resilver(spa, vd); | ||
vdev_defer_resilver(vd); | ||
|
||
/* | ||
* In general, when importing a pool we want to ignore the | ||
|
@@ -1873,18 +1874,12 @@ vdev_open(vdev_t *vd) | |
} | ||
|
||
/* | ||
* If a leaf vdev has a DTL, and seems healthy, then kick off a | ||
* resilver. But don't do this if we are doing a reopen for a scrub, | ||
* since this would just restart the scrub we are already doing. | ||
* If this is a leaf vdev, assess whether a resilver is needed. | ||
* But don't do this if we are doing a reopen for a scrub, since | ||
* this would just restart the scrub we are already doing. | ||
*/ | ||
if (vd->vdev_ops->vdev_op_leaf && !spa->spa_scrub_reopen && | ||
vdev_resilver_needed(vd, NULL, NULL)) { | ||
if (dsl_scan_resilvering(spa->spa_dsl_pool) && | ||
spa_feature_is_enabled(spa, SPA_FEATURE_RESILVER_DEFER)) | ||
vdev_set_deferred_resilver(spa, vd); | ||
else | ||
spa_async_request(spa, SPA_ASYNC_RESILVER); | ||
} | ||
if (vd->vdev_ops->vdev_op_leaf && !spa->spa_scrub_reopen) | ||
dsl_scan_assess_vdev(spa->spa_dsl_pool, vd); | ||
|
||
return (0); | ||
} | ||
|
@@ -3703,14 +3698,11 @@ vdev_clear(spa_t *spa, vdev_t *vd) | |
if (vd != rvd && vdev_writeable(vd->vdev_top)) | ||
vdev_state_dirty(vd->vdev_top); | ||
|
||
if (vd->vdev_aux == NULL && !vdev_is_dead(vd)) { | ||
if (dsl_scan_resilvering(spa->spa_dsl_pool) && | ||
spa_feature_is_enabled(spa, | ||
SPA_FEATURE_RESILVER_DEFER)) | ||
vdev_set_deferred_resilver(spa, vd); | ||
else | ||
spa_async_request(spa, SPA_ASYNC_RESILVER); | ||
} | ||
/* If a resilver isn't required, check if vdevs can be culled */ | ||
if (vd->vdev_aux == NULL && !vdev_is_dead(vd) && | ||
!dsl_scan_resilvering(spa->spa_dsl_pool) && | ||
!dsl_scan_resilver_scheduled(spa->spa_dsl_pool)) | ||
spa_async_request(spa, SPA_ASYNC_RESILVER_DONE); | ||
|
||
spa_event_notify(spa, vd, NULL, ESC_ZFS_VDEV_CLEAR); | ||
} | ||
|
@@ -4703,18 +4695,46 @@ vdev_deadman(vdev_t *vd, char *tag) | |
} | ||
|
||
void | ||
vdev_set_deferred_resilver(spa_t *spa, vdev_t *vd) | ||
vdev_defer_resilver(vdev_t *vd) | ||
{ | ||
for (uint64_t i = 0; i < vd->vdev_children; i++) | ||
vdev_set_deferred_resilver(spa, vd->vdev_child[i]); | ||
ASSERT(vd->vdev_ops->vdev_op_leaf); | ||
|
||
if (!vd->vdev_ops->vdev_op_leaf || !vdev_writeable(vd) || | ||
range_tree_is_empty(vd->vdev_dtl[DTL_MISSING])) { | ||
return; | ||
vd->vdev_resilver_deferred = B_TRUE; | ||
vd->vdev_spa->spa_resilver_deferred = B_TRUE; | ||
} | ||
|
||
/* | ||
* Clears the resilver deferred flag on all leaf devs under vd. Returns | ||
* B_TRUE if we have devices that need to be resilvered and are available to | ||
* accept resilver I/Os. | ||
*/ | ||
boolean_t | ||
vdev_clear_resilver_deferred(vdev_t *vd, dmu_tx_t *tx) | ||
{ | ||
boolean_t resilver_needed = B_FALSE; | ||
spa_t *spa = vd->vdev_spa; | ||
|
||
for (int c = 0; c < vd->vdev_children; c++) { | ||
vdev_t *cvd = vd->vdev_child[c]; | ||
resilver_needed |= vdev_clear_resilver_deferred(cvd, tx); | ||
} | ||
|
||
vd->vdev_resilver_deferred = B_TRUE; | ||
spa->spa_resilver_deferred = B_TRUE; | ||
if (vd == spa->spa_root_vdev && | ||
spa_feature_is_active(spa, SPA_FEATURE_RESILVER_DEFER)) { | ||
spa_feature_decr(spa, SPA_FEATURE_RESILVER_DEFER, tx); | ||
vdev_config_dirty(vd); | ||
spa->spa_resilver_deferred = B_FALSE; | ||
return (resilver_needed); | ||
} | ||
|
||
if (!vdev_is_concrete(vd) || vd->vdev_aux || | ||
!vd->vdev_ops->vdev_op_leaf) | ||
return (resilver_needed); | ||
|
||
vd->vdev_resilver_deferred = B_FALSE; | ||
|
||
return (!vdev_is_dead(vd) && !vd->vdev_offline && | ||
vdev_resilver_needed(vd, NULL, NULL)); | ||
} | ||
|
||
/* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,6 +61,7 @@ SUBDIRS = \ | |
rename_dirs \ | ||
replacement \ | ||
reservation \ | ||
resilver \ | ||
rootpool \ | ||
rsend \ | ||
scrub_mirror \ | ||
|
Oops, something went wrong.