Skip to content

Commit

Permalink
txg visibility code should not execute under tc_open_lock
Browse files Browse the repository at this point in the history
The memory allocation and locking in `spa_txg_history_*()` can
potentially block txg_hold_open for arbitrarily long periods of time.

Signed-off-by: Richard Yao <[email protected]>
  • Loading branch information
ryao committed Feb 17, 2016
1 parent 1902f42 commit 70d70fe
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions module/zfs/txg.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ txg_quiesce(dsl_pool_t *dp, uint64_t txg)
tx_state_t *tx = &dp->dp_tx;
int g = txg & TXG_MASK;
int c;
uint64_t tx_open_time;

/*
* Grab all tc_open_locks so nobody else can get into this txg.
Expand All @@ -372,10 +373,7 @@ txg_quiesce(dsl_pool_t *dp, uint64_t txg)

ASSERT(txg == tx->tx_open_txg);
tx->tx_open_txg++;
tx->tx_open_time = gethrtime();

spa_txg_history_set(dp->dp_spa, txg, TXG_STATE_OPEN, tx->tx_open_time);
spa_txg_history_add(dp->dp_spa, tx->tx_open_txg, tx->tx_open_time);
tx->tx_open_time = tx_open_time = gethrtime();

DTRACE_PROBE2(txg__quiescing, dsl_pool_t *, dp, uint64_t, txg);
DTRACE_PROBE2(txg__opened, dsl_pool_t *, dp, uint64_t, tx->tx_open_txg);
Expand All @@ -387,6 +385,9 @@ txg_quiesce(dsl_pool_t *dp, uint64_t txg)
for (c = 0; c < max_ncpus; c++)
mutex_exit(&tx->tx_cpu[c].tc_open_lock);

spa_txg_history_set(dp->dp_spa, txg, TXG_STATE_OPEN, tx_open_time);
spa_txg_history_add(dp->dp_spa, txg + 1, tx_open_time);

/*
* Quiesce the transaction group by waiting for everyone to txg_exit().
*/
Expand Down

0 comments on commit 70d70fe

Please sign in to comment.