diff options
author | Brian Behlendorf <[email protected]> | 2017-03-07 09:51:59 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2017-03-07 09:51:59 -0800 |
commit | 3ec3bc2167352df525c10c99cf24cb24952c2786 (patch) | |
tree | d38388851ea8b16bc4b5bc29839282a15491e139 /module/zfs/dsl_dataset.c | |
parent | e2fcb562759f32d3ca6f3764914222132ce2cfd9 (diff) |
OpenZFS 7793 - ztest fails assertion in dmu_tx_willuse_space
Reviewed by: Steve Gonczi <[email protected]>
Reviewed by: George Wilson <[email protected]>
Reviewed by: Pavel Zakharov <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
Background information: This assertion about tx_space_* verifies that we
are not dirtying more stuff than we thought we would. We “need” to know
how much we will dirty so that we can check if we should fail this
transaction with ENOSPC/EDQUOT, in dmu_tx_assign(). While the
transaction is open (i.e. between dmu_tx_assign() and dmu_tx_commit() —
typically less than a millisecond), we call dbuf_dirty() on the exact
blocks that will be modified. Once this happens, the temporary
accounting in tx_space_* is unnecessary, because we know exactly what
blocks are newly dirtied; we call dnode_willuse_space() to track this
more exact accounting.
The fundamental problem causing this bug is that dmu_tx_hold_*() relies
on the current state in the DMU (e.g. dn_nlevels) to predict how much
will be dirtied by this transaction, but this state can change before we
actually perform the transaction (i.e. call dbuf_dirty()).
This bug will be fixed by removing the assertion that the tx_space_*
accounting is perfectly accurate (i.e. we never dirty more than was
predicted by dmu_tx_hold_*()). By removing the requirement that this
accounting be perfectly accurate, we can also vastly simplify it, e.g.
removing most of the logic in dmu_tx_count_*().
The new tx space accounting will be very approximate, and may be more or
less than what is actually dirtied. It will still be used to determine
if this transaction will put us over quota. Transactions that are marked
by dmu_tx_mark_netfree() will be excepted from this check. We won’t make
an attempt to determine how much space will be freed by the transaction
— this was rarely accurate enough to determine if a transaction should
be permitted when we are over quota, which is why dmu_tx_mark_netfree()
was introduced in 2014.
We also won’t attempt to give “credit” when overwriting existing blocks,
if those blocks may be freed. This allows us to remove the
do_free_accounting logic in dbuf_dirty(), and associated routines. This
logic attempted to predict what will be on disk when this txg syncs, to
know if the overwritten block will be freed (i.e. exists, and has no
snapshots).
OpenZFS-issue: https://www.illumos.org/issues/7793
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/3704e0a
Upstream bugs: DLPX-32883a
Closes #5804
Porting notes:
- DNODE_SIZE replaced with DNODE_MIN_SIZE in dmu_tx_count_dnode(),
Using the default dnode size would be slightly better.
- DEBUG_DMU_TX wrappers and configure option removed.
- Resolved _by_dnode() conflicts these changes have not yet been
applied to OpenZFS.
Diffstat (limited to 'module/zfs/dsl_dataset.c')
-rw-r--r-- | module/zfs/dsl_dataset.c | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index c91c2e991..f83da16e5 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -242,42 +242,6 @@ dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx, return (used); } -uint64_t -dsl_dataset_prev_snap_txg(dsl_dataset_t *ds) -{ - uint64_t trysnap = 0; - - if (ds == NULL) - return (0); - /* - * The snapshot creation could fail, but that would cause an - * incorrect FALSE return, which would only result in an - * overestimation of the amount of space that an operation would - * consume, which is OK. - * - * There's also a small window where we could miss a pending - * snapshot, because we could set the sync task in the quiescing - * phase. So this should only be used as a guess. - */ - if (ds->ds_trysnap_txg > - spa_last_synced_txg(ds->ds_dir->dd_pool->dp_spa)) - trysnap = ds->ds_trysnap_txg; - return (MAX(dsl_dataset_phys(ds)->ds_prev_snap_txg, trysnap)); -} - -boolean_t -dsl_dataset_block_freeable(dsl_dataset_t *ds, const blkptr_t *bp, - uint64_t blk_birth) -{ - if (blk_birth <= dsl_dataset_prev_snap_txg(ds) || - (bp != NULL && BP_IS_HOLE(bp))) - return (B_FALSE); - - ddt_prefetch(dsl_dataset_get_spa(ds), bp); - - return (B_TRUE); -} - /* * We have to release the fsid syncronously or we risk that a subsequent * mount of the same dataset will fail to unique_insert the fsid. This @@ -3731,8 +3695,6 @@ EXPORT_SYMBOL(dsl_dataset_space_wouldfree); EXPORT_SYMBOL(dsl_dataset_sync); EXPORT_SYMBOL(dsl_dataset_block_born); EXPORT_SYMBOL(dsl_dataset_block_kill); -EXPORT_SYMBOL(dsl_dataset_block_freeable); -EXPORT_SYMBOL(dsl_dataset_prev_snap_txg); EXPORT_SYMBOL(dsl_dataset_dirty); EXPORT_SYMBOL(dsl_dataset_stats); EXPORT_SYMBOL(dsl_dataset_fast_stat); |