mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-25 03:37:45 +03:00
Optimize txg_kick() process (#12274)
Use dp_dirty_pertxg[] for txg_kick(), instead of dp_dirty_total in original code. Extra parameter "txg" is added for txg_kick(), thus it knows which txg to kick. Also txg_kick() call is moved from dsl_pool_need_dirty_delay() to dsl_pool_dirty_space() so that we can know the txg number assigned for txg_kick(). Some unnecessary code regarding dp_dirty_total in txg_sync_thread() is also cleaned up. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: jxdking <lostking2008@hotmail.com> Closes #12274
This commit is contained in:
+19
-6
@@ -898,18 +898,26 @@ dsl_pool_need_dirty_delay(dsl_pool_t *dp)
|
||||
{
|
||||
uint64_t delay_min_bytes =
|
||||
zfs_dirty_data_max * zfs_delay_min_dirty_percent / 100;
|
||||
uint64_t dirty_min_bytes =
|
||||
zfs_dirty_data_max * zfs_dirty_data_sync_percent / 100;
|
||||
uint64_t dirty;
|
||||
|
||||
mutex_enter(&dp->dp_lock);
|
||||
dirty = dp->dp_dirty_total;
|
||||
uint64_t dirty = dp->dp_dirty_total;
|
||||
mutex_exit(&dp->dp_lock);
|
||||
if (dirty > dirty_min_bytes)
|
||||
txg_kick(dp);
|
||||
|
||||
return (dirty > delay_min_bytes);
|
||||
}
|
||||
|
||||
static boolean_t
|
||||
dsl_pool_need_dirty_sync(dsl_pool_t *dp, uint64_t txg)
|
||||
{
|
||||
ASSERT(MUTEX_HELD(&dp->dp_lock));
|
||||
|
||||
uint64_t dirty_min_bytes =
|
||||
zfs_dirty_data_max * zfs_dirty_data_sync_percent / 100;
|
||||
uint64_t dirty = dp->dp_dirty_pertxg[txg & TXG_MASK];
|
||||
|
||||
return (dirty > dirty_min_bytes);
|
||||
}
|
||||
|
||||
void
|
||||
dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx)
|
||||
{
|
||||
@@ -917,7 +925,12 @@ dsl_pool_dirty_space(dsl_pool_t *dp, int64_t space, dmu_tx_t *tx)
|
||||
mutex_enter(&dp->dp_lock);
|
||||
dp->dp_dirty_pertxg[tx->tx_txg & TXG_MASK] += space;
|
||||
dsl_pool_dirty_delta(dp, space);
|
||||
boolean_t needsync = !dmu_tx_is_syncing(tx) &&
|
||||
dsl_pool_need_dirty_sync(dp, tx->tx_txg);
|
||||
mutex_exit(&dp->dp_lock);
|
||||
|
||||
if (needsync)
|
||||
txg_kick(dp, tx->tx_txg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user