diff options
author | Matthew Ahrens <mahrens@delphix.com> | 2014-07-07 19:49:36 +0000 |
---|---|---|
committer | Brian Behlendorf <behlendorf1@llnl.gov> | 2016-01-22 00:59:30 +0000 |
commit | 19d55079aecb5c022c1c09e0eace4f7da7381a62 (patch) | |
tree | d22e2fb923c8d11af9429346e69729ac98701eb9 /module/zfs/dmu_tx.c | |
parent | dfe0d027344b8534c69cc902c71ae912d8759e12 (diff) | |
download | src-19d55079aecb5c022c1c09e0eace4f7da7381a62.tar.gz src-19d55079aecb5c022c1c09e0eace4f7da7381a62.zip |
Diffstat (limited to 'module/zfs/dmu_tx.c')
-rw-r--r-- | module/zfs/dmu_tx.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c index 016defe79db8..74e323dbdf65 100644 --- a/module/zfs/dmu_tx.c +++ b/module/zfs/dmu_tx.c @@ -610,6 +610,32 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, uint64_t off, uint64_t len) txh->txh_space_tounref += unref; } +/* + * This function marks the transaction as being a "net free". The end + * result is that refquotas will be disabled for this transaction, and + * this transaction will be able to use half of the pool space overhead + * (see dsl_pool_adjustedsize()). Therefore this function should only + * be called for transactions that we expect will not cause a net increase + * in the amount of space used (but it's OK if that is occasionally not true). + */ +void +dmu_tx_mark_netfree(dmu_tx_t *tx) +{ + dmu_tx_hold_t *txh; + + txh = dmu_tx_hold_object_impl(tx, tx->tx_objset, + DMU_NEW_OBJECT, THT_FREE, 0, 0); + + /* + * Pretend that this operation will free 1GB of space. This + * should be large enough to cancel out the largest write. + * We don't want to use something like UINT64_MAX, because that would + * cause overflows when doing math with these values (e.g. in + * dmu_tx_try_assign()). + */ + txh->txh_space_tofree = txh->txh_space_tounref = 1024 * 1024 * 1024; +} + void dmu_tx_hold_free(dmu_tx_t *tx, uint64_t object, uint64_t off, uint64_t len) { |