diff --git a/include/sys/zio.h b/include/sys/zio.h index 44f1c8452e..04a11adfd6 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -563,9 +563,6 @@ extern zio_t *zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp, zio_done_func_t *done, void *priv, enum zio_flag flags); -extern zio_t *zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, - zio_done_func_t *done, void *priv, enum zio_flag flags); - extern zio_t *zio_trim(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size, zio_done_func_t *done, void *priv, zio_priority_t priority, enum zio_flag flags, enum trim_flag trim_flags); @@ -585,7 +582,7 @@ extern zio_t *zio_free_sync(zio_t *pio, spa_t *spa, uint64_t txg, extern int zio_alloc_zil(spa_t *spa, objset_t *os, uint64_t txg, blkptr_t *new_bp, uint64_t size, boolean_t *slog); -extern void zio_flush(zio_t *zio, vdev_t *vd, enum zio_flag flags); +extern void zio_flush(zio_t *zio, vdev_t *vd, boolean_t propagate); extern void zio_shrink(zio_t *zio, uint64_t size); extern int zio_wait(zio_t *zio); diff --git a/module/zfs/vdev_label.c b/module/zfs/vdev_label.c index 8b485e1fbd..7ea2f84951 100644 --- a/module/zfs/vdev_label.c +++ b/module/zfs/vdev_label.c @@ -1711,7 +1711,7 @@ vdev_uberblock_sync_list(vdev_t **svd, int svdcount, uberblock_t *ub, int flags) for (int v = 0; v < svdcount; v++) { if (vdev_writeable(svd[v])) { - zio_flush(zio, svd[v], ZIO_FLAG_DONT_PROPAGATE); + zio_flush(zio, svd[v], B_FALSE); } } @@ -1848,7 +1848,7 @@ vdev_label_sync_list(spa_t *spa, int l, uint64_t txg, int flags) zio = zio_root(spa, NULL, NULL, flags); for (vd = list_head(dl); vd != NULL; vd = list_next(dl, vd)) - zio_flush(zio, vd, ZIO_FLAG_DONT_PROPAGATE); + zio_flush(zio, vd, B_FALSE); (void) zio_wait(zio); @@ -1921,7 +1921,7 @@ retry: for (vdev_t *vd = txg_list_head(&spa->spa_vdev_txg_list, TXG_CLEAN(txg)); vd != NULL; vd = txg_list_next(&spa->spa_vdev_txg_list, vd, TXG_CLEAN(txg))) - zio_flush(zio, vd, ZIO_FLAG_DONT_PROPAGATE); + zio_flush(zio, vd, B_FALSE); (void) zio_wait(zio); diff --git a/module/zfs/zil.c b/module/zfs/zil.c index b9a1cfb24b..880912d665 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -1706,7 +1706,7 @@ zil_lwb_write_done(zio_t *zio) * that had their flushes deferred. Flush errors will * be delivered to zil_lwb_flush_vdevs_done(). */ - zio_flush(lwb->lwb_root_zio, vd, 0); + zio_flush(lwb->lwb_root_zio, vd, B_TRUE); } kmem_free(zv, sizeof (*zv)); } diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 9033316873..c83ff29e3a 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -1306,30 +1306,6 @@ zio_claim(zio_t *pio, spa_t *spa, uint64_t txg, const blkptr_t *bp, return (zio); } -zio_t * -zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd, - zio_done_func_t *done, void *private, enum zio_flag flags) -{ - zio_t *zio; - int c; - - if (vd->vdev_children == 0) { - zio = zio_create(pio, spa, 0, NULL, NULL, 0, 0, done, private, - ZIO_TYPE_IOCTL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL, - ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE); - - zio->io_cmd = cmd; - } else { - zio = zio_null(pio, spa, NULL, NULL, NULL, flags); - - for (c = 0; c < vd->vdev_children; c++) - zio_nowait(zio_ioctl(zio, spa, vd->vdev_child[c], cmd, - done, private, flags)); - } - - return (zio); -} - zio_t * zio_trim(zio_t *pio, vdev_t *vd, uint64_t offset, uint64_t size, zio_done_func_t *done, void *private, zio_priority_t priority, @@ -1501,11 +1477,36 @@ zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, abd_t *data, uint64_t size, return (zio); } +/* + * Send a flush command to the given vdev. Unlike most zio creation functions, + * the flush zios are issued immediately. You can wait on pio to pause until + * the flushes complete. + * + * Set propagate to true to have flush errors propagated to the parent. + * Otherwise, flush errors are ignored. + */ void -zio_flush(zio_t *zio, vdev_t *vd, enum zio_flag flags) +zio_flush(zio_t *pio, vdev_t *vd, boolean_t propagate) { - zio_nowait(zio_ioctl(zio, zio->io_spa, vd, DKIOCFLUSHWRITECACHE, - NULL, NULL, flags | ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_RETRY)); + const int cmd = DKIOCFLUSHWRITECACHE; + const enum zio_flag flags = + ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_RETRY | + (propagate ? 0 : ZIO_FLAG_DONT_PROPAGATE); + spa_t *spa = pio->io_spa; + zio_t *zio; + + if (vd->vdev_children == 0) { + zio = zio_create(pio, spa, 0, NULL, NULL, 0, 0, NULL, NULL, + ZIO_TYPE_IOCTL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL, + ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE); + zio->io_cmd = cmd; + } else { + zio = zio_null(pio, spa, NULL, NULL, NULL, flags); + for (int c = 0; c < vd->vdev_children; c++) + zio_flush(zio, vd->vdev_child[c], propagate); + } + + zio_nowait(zio); } void