+ /*
+ * If we modify a dataset in the same txg that we want to destroy it,
+ * its dsl_dir's dd_dbuf will be dirty, and thus have a hold on it.
+ * dsl_dir_destroy_check() will fail if there are unexpected holds.
+ * Therefore, we want to sync the MOS (thus syncing the dd_dbuf
+ * and clearing the hold on it) before we process the sync_tasks.
+ * The MOS data dirtied by the sync_tasks will be synced on the next
+ * pass.
+ */
+ DTRACE_PROBE(pool_sync__3task);
+ if (!txg_list_empty(&dp->dp_sync_tasks, txg)) {
+ dsl_sync_task_group_t *dstg;
+ /*
+ * No more sync tasks should have been added while we
+ * were syncing.
+ */
+ ASSERT(spa_sync_pass(dp->dp_spa) == 1);
+ while ((dstg = txg_list_remove(&dp->dp_sync_tasks, txg)))
+ dsl_sync_task_group_sync(dstg, tx);
+ }
+