Skip to content

Commit

Permalink
Code optimization and performance tweaking"
Browse files Browse the repository at this point in the history
Modified dsl_pool_wrlog_delay().Signed-off-by: jxdking <lostking2008@hotmail.com>
  • Loading branch information
jxdking committed Apr 13, 2021
1 parent 6003160 commit 8cd5a3d
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions module/zfs/dsl_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,10 +612,15 @@ dsl_pool_dirty_delta(dsl_pool_t *dp, int64_t delta)
void
dsl_pool_wrlog_delay(int64_t size, dsl_pool_t *dp, uint64_t txg)
{
ASSERT3S(size, >=, 0);
ASSERT3U(txg, >=, TXG_INITIAL);

uint64_t last_total;
uint64_t txg_total;

mutex_enter(&dp->dp_wrlog_lock);
last_total = dp->dp_wrlog_total;
txg_total = dp->dp_wrlog_pertxg[txg & TXG_MASK];
dp->dp_wrlog_total += size;
dp->dp_wrlog_pertxg[txg & TXG_MASK] += size;
mutex_exit(&dp->dp_wrlog_lock);
Expand All @@ -625,18 +630,26 @@ dsl_pool_wrlog_delay(int64_t size, dsl_pool_t *dp, uint64_t txg)
"dp_wrlog_total: %llu", last_total);

/*
* Current txg need to stay open to process current
* write transaction. We only can wait until txg - 1
* is synced.
* Current txg needs to stay open to process current
* write transaction. Under heavy load, persumably txg - 2
* is one syncing. Wait on it.
*/
if (txg > 2) {
txg_wait_synced(dp, txg - 1);
}
txg_wait_synced(dp, txg - 2);
}

if (last_total >=
zfs_wrlog_data_sync_percent * zfs_wrlog_data_max / 100) {
txg_kick(dp);
if (txg_total == last_total) {
// All data is in current txg, push it out
txg_kick(dp);
} else if (txg_total >= zfs_wrlog_data_max / 3) {
/*
* There is some data in previous txgs that are
* not synced yet. Hold it until current txg
* is 1/3 full as zfs_wrlog_data_max.
*/
txg_kick(dp);
}
}
}

Expand All @@ -649,7 +662,7 @@ dsl_pool_wrlog_clear(dsl_pool_t *dp, uint64_t txg)
mutex_exit(&dp->dp_wrlog_lock);

dprintf("write log total cleared for txg: %llu, "
"dp_wrlog_total: %llu", txg, dp->dp_wrlog_total);
"remaining dp_wrlog_total: %llu", txg, dp->dp_wrlog_total);
}

#ifdef ZFS_DEBUG
Expand Down

0 comments on commit 8cd5a3d

Please sign in to comment.