+ /*
+ * 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.
+ */