mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 11:18:52 +03:00
Refactor txg history kstat
It was observed that even when the txg history is disabled by setting `zfs_txg_history=0` the txg_sync thread still fetches the vdev stats unnecessarily. This patch refactors the code such that vdev_get_stats() is no longer called when `zfs_txg_history=0`. And it further reduces the differences between upstream and the ZoL txg_sync_thread() function. Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Closes #5412
This commit is contained in:
+49
-1
@@ -474,7 +474,7 @@ spa_txg_history_set(spa_t *spa, uint64_t txg, txg_state_t completed_state,
|
||||
/*
|
||||
* Set txg IO stats.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread,
|
||||
uint64_t nwritten, uint64_t reads, uint64_t writes, uint64_t ndirty)
|
||||
{
|
||||
@@ -503,6 +503,54 @@ spa_txg_history_set_io(spa_t *spa, uint64_t txg, uint64_t nread,
|
||||
return (error);
|
||||
}
|
||||
|
||||
txg_stat_t *
|
||||
spa_txg_history_init_io(spa_t *spa, uint64_t txg, dsl_pool_t *dp)
|
||||
{
|
||||
txg_stat_t *ts;
|
||||
|
||||
if (zfs_txg_history == 0)
|
||||
return (NULL);
|
||||
|
||||
ts = kmem_alloc(sizeof (txg_stat_t), KM_SLEEP);
|
||||
|
||||
spa_config_enter(spa, SCL_ALL, FTAG, RW_READER);
|
||||
vdev_get_stats(spa->spa_root_vdev, &ts->vs1);
|
||||
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||
|
||||
ts->txg = txg;
|
||||
ts->ndirty = dp->dp_dirty_pertxg[txg & TXG_MASK];
|
||||
|
||||
spa_txg_history_set(spa, txg, TXG_STATE_WAIT_FOR_SYNC, gethrtime());
|
||||
|
||||
return (ts);
|
||||
}
|
||||
|
||||
void
|
||||
spa_txg_history_fini_io(spa_t *spa, txg_stat_t *ts)
|
||||
{
|
||||
if (ts == NULL)
|
||||
return;
|
||||
|
||||
if (zfs_txg_history == 0) {
|
||||
kmem_free(ts, sizeof (txg_stat_t));
|
||||
return;
|
||||
}
|
||||
|
||||
spa_config_enter(spa, SCL_ALL, FTAG, RW_READER);
|
||||
vdev_get_stats(spa->spa_root_vdev, &ts->vs2);
|
||||
spa_config_exit(spa, SCL_ALL, FTAG);
|
||||
|
||||
spa_txg_history_set(spa, ts->txg, TXG_STATE_SYNCED, gethrtime());
|
||||
spa_txg_history_set_io(spa, ts->txg,
|
||||
ts->vs2.vs_bytes[ZIO_TYPE_READ] - ts->vs1.vs_bytes[ZIO_TYPE_READ],
|
||||
ts->vs2.vs_bytes[ZIO_TYPE_WRITE] - ts->vs1.vs_bytes[ZIO_TYPE_WRITE],
|
||||
ts->vs2.vs_ops[ZIO_TYPE_READ] - ts->vs1.vs_ops[ZIO_TYPE_READ],
|
||||
ts->vs2.vs_ops[ZIO_TYPE_WRITE] - ts->vs1.vs_ops[ZIO_TYPE_WRITE],
|
||||
ts->ndirty);
|
||||
|
||||
kmem_free(ts, sizeof (txg_stat_t));
|
||||
}
|
||||
|
||||
/*
|
||||
* ==========================================================================
|
||||
* SPA TX Assign Histogram Routines
|
||||
|
||||
Reference in New Issue
Block a user