int subprocess_flush_io (struct subprocess *p) { zio_flush (p->zio_in); while (zio_read (p->zio_out) > 0) {}; while (zio_read (p->zio_err) > 0) {}; return (0); }
int zio_read (zio_t *zio) { int n; assert ((zio != NULL) && (zio->magic == ZIO_MAGIC)); if ((n = cbuf_write_from_fd (zio->buf, zio->srcfd, -1, NULL)) < 0) return (-1); zio_debug (zio, "zio_read: read = %d\n", n); if (n == 0) { zio_set_eof (zio); zio_debug (zio, "zio_read_cb: Got eof\n"); } zio_flush (zio); return (n); }
void zil_flush_vdevs(zilog_t *zilog) { spa_t *spa = zilog->zl_spa; avl_tree_t *t = &zilog->zl_vdev_tree; void *cookie = NULL; zil_vdev_node_t *zv; zio_t *zio; ASSERT(zilog->zl_writer); /* * We don't need zl_vdev_lock here because we're the zl_writer, * and all zl_get_data() callbacks are done. */ if (avl_numnodes(t) == 0) return; spa_config_enter(spa, SCL_STATE, FTAG, RW_READER); zio = zio_root(spa, NULL, NULL, ZIO_FLAG_CANFAIL); while ((zv = avl_destroy_nodes(t, &cookie)) != NULL) { vdev_t *vd = vdev_lookup_top(spa, zv->zv_vdev); if (vd != NULL) zio_flush(zio, vd); kmem_free(zv, sizeof (*zv)); } /* * Wait for all the flushes to complete. Not all devices actually * support the DKIOCFLUSHWRITECACHE ioctl, so it's OK if it fails. */ (void) zio_wait(zio); spa_config_exit(spa, SCL_STATE, FTAG); }