summaryrefslogtreecommitdiffstats
path: root/module/zfs/dsl_dataset.c
diff options
context:
space:
mode:
authorMatthew Ahrens <[email protected]>2012-12-14 16:13:40 -0800
committerBrian Behlendorf <[email protected]>2013-01-08 10:35:43 -0800
commit29809a6cbae9869ca6ee026337981b2c9771650a (patch)
tree230751bd7e6530be1826d59a0d0d4438856ea410 /module/zfs/dsl_dataset.c
parentb9b24bb4ca45f2d903efadba44d10dfd182f62ac (diff)
Illumos #3086: unnecessarily setting DS_FLAG_INCONSISTENT on async
3086 unnecessarily setting DS_FLAG_INCONSISTENT on async destroyed datasets Reviewed by: Christopher Siden <[email protected]> Approved by: Eric Schrock <[email protected]> References: illumos/illumos-gate@ce636f8b38e8c9ff484e880d9abb27251a882860 illumos changeset: 13776:cd512c80fd75 https://www.illumos.org/issues/3086 Ported-by: Brian Behlendorf <[email protected]>
Diffstat (limited to 'module/zfs/dsl_dataset.c')
-rw-r--r--module/zfs/dsl_dataset.c108
1 files changed, 47 insertions, 61 deletions
diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c
index 872d44afb..c5b84a26c 100644
--- a/module/zfs/dsl_dataset.c
+++ b/module/zfs/dsl_dataset.c
@@ -105,14 +105,8 @@ dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx)
ASSERT(BP_GET_TYPE(bp) != DMU_OT_NONE);
ASSERT(DMU_OT_IS_VALID(BP_GET_TYPE(bp)));
if (ds == NULL) {
- /*
- * Account for the meta-objset space in its placeholder
- * dsl_dir.
- */
- ASSERT3U(compressed, ==, uncompressed); /* it's all metadata */
- dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, DD_USED_HEAD,
- used, compressed, uncompressed, tx);
- dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx);
+ dsl_pool_mos_diduse_space(tx->tx_pool,
+ used, compressed, uncompressed);
return;
}
dmu_buf_will_dirty(ds->ds_dbuf, tx);
@@ -150,15 +144,9 @@ dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
ASSERT(used > 0);
if (ds == NULL) {
- /*
- * Account for the meta-objset space in its placeholder
- * dataset.
- */
dsl_free(tx->tx_pool, tx->tx_txg, bp);
-
- dsl_dir_diduse_space(tx->tx_pool->dp_mos_dir, DD_USED_HEAD,
- -used, -compressed, -uncompressed, tx);
- dsl_dir_dirty(tx->tx_pool->dp_mos_dir, tx);
+ dsl_pool_mos_diduse_space(tx->tx_pool,
+ -used, -compressed, -uncompressed);
return (used);
}
ASSERT3P(tx->tx_pool, ==, ds->ds_dir->dd_pool);
@@ -1074,26 +1062,26 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
dummy_ds->ds_dir = dd;
dummy_ds->ds_object = ds->ds_object;
- /*
- * Check for errors and mark this ds as inconsistent, in
- * case we crash while freeing the objects.
- */
- err = dsl_sync_task_do(dd->dd_pool, dsl_dataset_destroy_begin_check,
- dsl_dataset_destroy_begin_sync, ds, NULL, 0);
- if (err)
- goto out_free;
-
- err = dmu_objset_from_ds(ds, &os);
- if (err)
- goto out_free;
-
- /*
- * If async destruction is not enabled try to remove all objects
- * while in the open context so that there is less work to do in
- * the syncing context.
- */
if (!spa_feature_is_enabled(dsl_dataset_get_spa(ds),
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ /*
+ * Check for errors and mark this ds as inconsistent, in
+ * case we crash while freeing the objects.
+ */
+ err = dsl_sync_task_do(dd->dd_pool,
+ dsl_dataset_destroy_begin_check,
+ dsl_dataset_destroy_begin_sync, ds, NULL, 0);
+ if (err)
+ goto out_free;
+
+ err = dmu_objset_from_ds(ds, &os);
+ if (err)
+ goto out_free;
+
+ /*
+ * Remove all objects while in the open context so that
+ * there is less work to do in the syncing context.
+ */
for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE,
ds->ds_phys->ds_prev_snap_txg)) {
/*
@@ -1104,29 +1092,25 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
}
if (err != ESRCH)
goto out_free;
- }
- /*
- * Only the ZIL knows how to free log blocks.
- */
- zil_destroy(dmu_objset_zil(os), B_FALSE);
-
- /*
- * Sync out all in-flight IO.
- */
- txg_wait_synced(dd->dd_pool, 0);
+ /*
+ * Sync out all in-flight IO.
+ */
+ txg_wait_synced(dd->dd_pool, 0);
- /*
- * If we managed to free all the objects in open
- * context, the user space accounting should be zero.
- */
- if (ds->ds_phys->ds_bp.blk_fill == 0 &&
- dmu_objset_userused_enabled(os)) {
- ASSERTV(uint64_t count);
- ASSERT(zap_count(os, DMU_USERUSED_OBJECT, &count) != 0 ||
- count == 0);
- ASSERT(zap_count(os, DMU_GROUPUSED_OBJECT, &count) != 0 ||
- count == 0);
+ /*
+ * If we managed to free all the objects in open
+ * context, the user space accounting should be zero.
+ */
+ if (ds->ds_phys->ds_bp.blk_fill == 0 &&
+ dmu_objset_userused_enabled(os)) {
+ ASSERTV(uint64_t count);
+
+ ASSERT(zap_count(os, DMU_USERUSED_OBJECT,
+ &count) != 0 || count == 0);
+ ASSERT(zap_count(os, DMU_GROUPUSED_OBJECT,
+ &count) != 0 || count == 0);
+ }
}
rw_enter(&dd->dd_pool->dp_config_rwlock, RW_READER);
@@ -1878,6 +1862,7 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
} else {
zfeature_info_t *async_destroy =
&spa_feature_table[SPA_FEATURE_ASYNC_DESTROY];
+ objset_t *os;
/*
* There's no next snapshot, so this is a head dataset.
@@ -1889,6 +1874,8 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx);
ds->ds_phys->ds_deadlist_obj = 0;
+ VERIFY3U(0, ==, dmu_objset_from_ds(ds, &os));
+
if (!spa_feature_is_enabled(dp->dp_spa, async_destroy)) {
err = old_synchronous_dataset_destroy(ds, tx);
} else {
@@ -1898,12 +1885,12 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
*/
uint64_t used, comp, uncomp;
- ASSERT(err == 0 || err == EBUSY);
+ zil_destroy_sync(dmu_objset_zil(os), tx);
+
if (!spa_feature_is_active(dp->dp_spa, async_destroy)) {
spa_feature_incr(dp->dp_spa, async_destroy, tx);
- dp->dp_bptree_obj = bptree_alloc(
- dp->dp_meta_objset, tx);
- VERIFY(zap_add(dp->dp_meta_objset,
+ dp->dp_bptree_obj = bptree_alloc(mos, tx);
+ VERIFY(zap_add(mos,
DMU_POOL_DIRECTORY_OBJECT,
DMU_POOL_BPTREE_OBJ, sizeof (uint64_t), 1,
&dp->dp_bptree_obj, tx) == 0);
@@ -1916,7 +1903,7 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) ||
ds->ds_phys->ds_unique_bytes == used);
- bptree_add(dp->dp_meta_objset, dp->dp_bptree_obj,
+ bptree_add(mos, dp->dp_bptree_obj,
&ds->ds_phys->ds_bp, ds->ds_phys->ds_prev_snap_txg,
used, comp, uncomp, tx);
dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
@@ -2203,7 +2190,6 @@ dsl_dataset_sync(dsl_dataset_t *ds, zio_t *zio, dmu_tx_t *tx)
dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_fsid_guid = ds->ds_fsid_guid;
- dsl_dir_dirty(ds->ds_dir, tx);
dmu_objset_sync(ds->ds_objset, zio, tx);
}