- written = dp->dp_space_towrite[txg & TXG_MASK];
- dp->dp_space_towrite[txg & TXG_MASK] = 0;
- ASSERT(dp->dp_tempreserved[txg & TXG_MASK] == 0);
-
- /*
- * If the write limit max has not been explicitly set, set it
- * to a fraction of available phisical memory (default 1/8th).
- * Note that we must inflate the limit because the spa
- * inflates write sizes to account for data replication.
- * Check this each sync phase to catch changing memory size.
- */
- if (zfs_write_limit_inflated == 0 ||
- (zfs_write_limit_shift && zfs_write_limit_max !=
- physmem * PAGESIZE >> zfs_write_limit_shift)) {
- zfs_write_limit_max =
- physmem * PAGESIZE >> zfs_write_limit_shift;
- zfs_write_limit_inflated =
- spa_get_asize(dp->dp_spa, zfs_write_limit_max);
- if (zfs_write_limit_min > zfs_write_limit_inflated)
- zfs_write_limit_inflated = zfs_write_limit_min;
- }
-
- /*
- * Attempt to keep the sync time consistant by adjusting the
- * amount of write traffic allowed into each transaction group.
- */
- target = zfs_txg_synctime * hz;
- if (delta > target) {
- uint64_t old = MIN(dp->dp_write_limit, written);
-
- dp->dp_write_limit = MAX(zfs_write_limit_min,
- old * target / delta);
- } else if (written >= dp->dp_write_limit &&
- delta >> 3 < target >> 3) {
- uint64_t rescale =
- MIN((100 * target) / delta, 200);
-
- dp->dp_write_limit = MIN(zfs_write_limit_inflated,
- written * rescale / 100);
- }
-