Skip to content

Commit 10400bf

Browse files
ahrensbehlendorf
authored andcommitted
Illumos 5351, 5352 - scrub pauses
5351 scrub goes for an extra second each txg 5352 scrub should pause when there is some dirty data Author: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Alex Reece <alex.reece@delphix.com> Reviewed by: Christopher Siden <christopher.siden@delphix.com> Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Richard Elling <richard.elling@richardelling.com> Approved by: Dan McDonald <danmcd@omniti.com> References: https://www.illumos.org/issues/5351 illumos/illumos-gate@6f6a76a Ported-by: Chris Dunlop <chris@onthe.net.au> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #3383
1 parent 08dc1b2 commit 10400bf

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

module/zfs/dsl_scan.c

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,14 @@ dsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx)
429429
&scn->scn_phys, tx));
430430
}
431431

432+
extern int zfs_vdev_async_write_active_min_dirty_percent;
433+
432434
static boolean_t
433435
dsl_scan_check_pause(dsl_scan_t *scn, const zbookmark_phys_t *zb)
434436
{
435437
uint64_t elapsed_nanosecs;
436438
int mintime;
439+
int dirty_pct;
437440

438441
/* we never skip user/group accounting objects */
439442
if (zb && (int64_t)zb->zb_object < 0)
@@ -449,12 +452,28 @@ dsl_scan_check_pause(dsl_scan_t *scn, const zbookmark_phys_t *zb)
449452
if (zb && zb->zb_level != 0)
450453
return (B_FALSE);
451454

455+
/*
456+
* We pause if:
457+
* - we have scanned for the maximum time: an entire txg
458+
* timeout (default 5 sec)
459+
* or
460+
* - we have scanned for at least the minimum time (default 1 sec
461+
* for scrub, 3 sec for resilver), and either we have sufficient
462+
* dirty data that we are starting to write more quickly
463+
* (default 30%), or someone is explicitly waiting for this txg
464+
* to complete.
465+
* or
466+
* - the spa is shutting down because this pool is being exported
467+
* or the machine is rebooting.
468+
*/
452469
mintime = (scn->scn_phys.scn_func == POOL_SCAN_RESILVER) ?
453470
zfs_resilver_min_time_ms : zfs_scan_min_time_ms;
454471
elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time;
455-
if (elapsed_nanosecs / NANOSEC > zfs_txg_timeout ||
472+
dirty_pct = scn->scn_dp->dp_dirty_total * 100 / zfs_dirty_data_max;
473+
if (elapsed_nanosecs / NANOSEC >= zfs_txg_timeout ||
456474
(NSEC2MSEC(elapsed_nanosecs) > mintime &&
457-
txg_sync_waiting(scn->scn_dp)) ||
475+
(txg_sync_waiting(scn->scn_dp) ||
476+
dirty_pct >= zfs_vdev_async_write_active_min_dirty_percent)) ||
458477
spa_shutting_down(scn->scn_dp->dp_spa)) {
459478
if (zb) {
460479
dprintf("pausing at bookmark %llx/%llx/%llx/%llx\n",

0 commit comments

Comments
 (0)