Illumos #3006
[zfs.git] / module / zfs / spa.c
index e022c32..ba376fb 100644 (file)
@@ -926,6 +926,31 @@ spa_taskq_dispatch_ent(spa_t *spa, zio_type_t t, zio_taskq_type_t q,
        taskq_dispatch_ent(tq, func, arg, flags, ent);
 }
 
+/*
+ * Same as spa_taskq_dispatch_ent() but block on the task until completion.
+ */
+void
+spa_taskq_dispatch_sync(spa_t *spa, zio_type_t t, zio_taskq_type_t q,
+    task_func_t *func, void *arg, uint_t flags)
+{
+       spa_taskqs_t *tqs = &spa->spa_zio_taskq[t][q];
+       taskq_t *tq;
+       taskqid_t id;
+
+       ASSERT3P(tqs->stqs_taskq, !=, NULL);
+       ASSERT3U(tqs->stqs_count, !=, 0);
+
+       if (tqs->stqs_count == 1) {
+               tq = tqs->stqs_taskq[0];
+       } else {
+               tq = tqs->stqs_taskq[gethrtime() % tqs->stqs_count];
+       }
+
+       id = taskq_dispatch(tq, func, arg, flags);
+       if (id)
+               taskq_wait_id(tq, id);
+}
+
 static void
 spa_create_zio_taskqs(spa_t *spa)
 {
@@ -5137,7 +5162,7 @@ spa_vdev_remove_evacuate(spa_t *spa, vdev_t *vd)
         * The evacuation succeeded.  Remove any remaining MOS metadata
         * associated with this vdev, and wait for these changes to sync.
         */
-       ASSERT3U(vd->vdev_stat.vs_alloc, ==, 0);
+       ASSERT0(vd->vdev_stat.vs_alloc);
        txg = spa_vdev_config_enter(spa);
        vd->vdev_removing = B_TRUE;
        vdev_dirty(vd, 0, NULL, txg);
@@ -6138,7 +6163,7 @@ spa_sync(spa_t *spa, uint64_t txg)
                zio_t *zio = zio_root(spa, NULL, NULL, 0);
                VERIFY3U(bpobj_iterate(defer_bpo,
                    spa_free_sync_cb, zio, tx), ==, 0);
-               VERIFY3U(zio_wait(zio), ==, 0);
+               VERIFY0(zio_wait(zio));
        }
 
        /*