Deleted Added
full compact
dsl_scan.c (276082) dsl_scan.c (277576)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 409 unchanged lines hidden (view full) ---

418dsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx)
419{
420 VERIFY0(zap_update(scn->scn_dp->dp_meta_objset,
421 DMU_POOL_DIRECTORY_OBJECT,
422 DMU_POOL_SCAN, sizeof (uint64_t), SCAN_PHYS_NUMINTS,
423 &scn->scn_phys, tx));
424}
425
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 409 unchanged lines hidden (view full) ---

418dsl_scan_sync_state(dsl_scan_t *scn, dmu_tx_t *tx)
419{
420 VERIFY0(zap_update(scn->scn_dp->dp_meta_objset,
421 DMU_POOL_DIRECTORY_OBJECT,
422 DMU_POOL_SCAN, sizeof (uint64_t), SCAN_PHYS_NUMINTS,
423 &scn->scn_phys, tx));
424}
425
426extern int zfs_vdev_async_write_active_min_dirty_percent;
427
426static boolean_t
427dsl_scan_check_pause(dsl_scan_t *scn, const zbookmark_phys_t *zb)
428{
428static boolean_t
429dsl_scan_check_pause(dsl_scan_t *scn, const zbookmark_phys_t *zb)
430{
429 uint64_t elapsed_nanosecs;
430 unsigned int mintime;
431
432 /* we never skip user/group accounting objects */
433 if (zb && (int64_t)zb->zb_object < 0)
434 return (B_FALSE);
435
436 if (scn->scn_pausing)
437 return (B_TRUE); /* we're already pausing */
438
439 if (!ZB_IS_ZERO(&scn->scn_phys.scn_bookmark))
440 return (B_FALSE); /* we're resuming */
441
442 /* We only know how to resume from level-0 blocks. */
443 if (zb && zb->zb_level != 0)
444 return (B_FALSE);
445
431 /* we never skip user/group accounting objects */
432 if (zb && (int64_t)zb->zb_object < 0)
433 return (B_FALSE);
434
435 if (scn->scn_pausing)
436 return (B_TRUE); /* we're already pausing */
437
438 if (!ZB_IS_ZERO(&scn->scn_phys.scn_bookmark))
439 return (B_FALSE); /* we're resuming */
440
441 /* We only know how to resume from level-0 blocks. */
442 if (zb && zb->zb_level != 0)
443 return (B_FALSE);
444
446 mintime = (scn->scn_phys.scn_func == POOL_SCAN_RESILVER) ?
445 /*
446 * We pause if:
447 * - we have scanned for the maximum time: an entire txg
448 * timeout (default 5 sec)
449 * or
450 * - we have scanned for at least the minimum time (default 1 sec
451 * for scrub, 3 sec for resilver), and either we have sufficient
452 * dirty data that we are starting to write more quickly
453 * (default 30%), or someone is explicitly waiting for this txg
454 * to complete.
455 * or
456 * - the spa is shutting down because this pool is being exported
457 * or the machine is rebooting.
458 */
459 int mintime = (scn->scn_phys.scn_func == POOL_SCAN_RESILVER) ?
447 zfs_resilver_min_time_ms : zfs_scan_min_time_ms;
460 zfs_resilver_min_time_ms : zfs_scan_min_time_ms;
448 elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time;
449 if (elapsed_nanosecs / NANOSEC > zfs_txg_timeout ||
461 uint64_t elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time;
462 int dirty_pct = scn->scn_dp->dp_dirty_total * 100 / zfs_dirty_data_max;
463 if (elapsed_nanosecs / NANOSEC >= zfs_txg_timeout ||
450 (NSEC2MSEC(elapsed_nanosecs) > mintime &&
464 (NSEC2MSEC(elapsed_nanosecs) > mintime &&
451 txg_sync_waiting(scn->scn_dp)) ||
465 (txg_sync_waiting(scn->scn_dp) ||
466 dirty_pct >= zfs_vdev_async_write_active_min_dirty_percent)) ||
452 spa_shutting_down(scn->scn_dp->dp_spa)) {
453 if (zb) {
454 dprintf("pausing at bookmark %llx/%llx/%llx/%llx\n",
455 (longlong_t)zb->zb_objset,
456 (longlong_t)zb->zb_object,
457 (longlong_t)zb->zb_level,
458 (longlong_t)zb->zb_blkid);
459 scn->scn_phys.scn_bookmark = *zb;

--- 1362 unchanged lines hidden ---
467 spa_shutting_down(scn->scn_dp->dp_spa)) {
468 if (zb) {
469 dprintf("pausing at bookmark %llx/%llx/%llx/%llx\n",
470 (longlong_t)zb->zb_objset,
471 (longlong_t)zb->zb_object,
472 (longlong_t)zb->zb_level,
473 (longlong_t)zb->zb_blkid);
474 scn->scn_phys.scn_bookmark = *zb;

--- 1362 unchanged lines hidden ---