Skip to content

Commit

Permalink
Improvement based on code review.
Browse files Browse the repository at this point in the history
Switch back to tx_quiesce_more_cv for txg_kick().

Signed-off-by: jxdking <[email protected]>
  • Loading branch information
jxdking committed Jun 30, 2021
1 parent dba3a01 commit cdb2869
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion module/zfs/txg.c
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,14 @@ txg_wait_callbacks(dsl_pool_t *dp)
taskq_wait_outstanding(tx->tx_commit_cb_taskq, 0);
}

static boolean_t
txg_is_syncing(dsl_pool_t *dp)
{
tx_state_t *tx = &dp->dp_tx;
ASSERT(MUTEX_HELD(&tx->tx_sync_lock));
return (tx->tx_syncing_txg != 0);
}

static boolean_t
txg_is_quiescing(dsl_pool_t *dp)
{
Expand Down Expand Up @@ -794,13 +802,26 @@ txg_kick(dsl_pool_t *dp, uint64_t txg)

ASSERT(!dsl_pool_config_held(dp));

/* Fast return path outside tx_sync_lock */
if (tx->tx_sync_txg_waiting >= txg)
return;

mutex_enter(&tx->tx_sync_lock);
if (tx->tx_sync_txg_waiting < txg) {

/*
* Always update tx_sync_txg_waiting, so that even if kick
* condition below is not applicable, this txg will be picked
* up by sync thread eventually.
*/
tx->tx_sync_txg_waiting = txg;
cv_broadcast(&tx->tx_sync_more_cv);

if (!txg_is_syncing(dp) &&
!txg_is_quiescing(dp) &&
tx->tx_quiesce_txg_waiting <= txg) {
tx->tx_quiesce_txg_waiting = txg + 1;
cv_broadcast(&tx->tx_quiesce_more_cv);
}
}
mutex_exit(&tx->tx_sync_lock);
}
Expand Down

0 comments on commit cdb2869

Please sign in to comment.