From 8ec175d7e13a68f1e9384a32889a29588fcf7f1d Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Wed, 10 May 2023 16:41:53 +1000 Subject: [PATCH] zio_flush: require caller to decide if errors should propagate Ignoring flush errors makes it possible for callers to never know that their writes didn't succeed, and allows writes to be lost if the pool fails. This commit gives zio_flush() a flag argument, and updates the call sites to pass ZIO_FLAG_DONT_PROPAGATE to it. Thus, this commit does not change any behaviour, but opens the floor for further changes to allow those callers to handle flush failures sensibly. Signed-off-by: Rob Norris (cherry picked from commit 6d0deb8a5a0c3d6bbc69d9625d55fc776bb98ea3) --- include/sys/zio.h | 2 +- module/zfs/vdev_label.c | 6 +++--- module/zfs/zil.c | 3 ++- module/zfs/zio.c | 5 ++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/sys/zio.h b/include/sys/zio.h index 4898fafcb7..44f1c8452e 100644 --- a/include/sys/zio.h +++ b/include/sys/zio.h @@ -585,7 +585,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); +extern void zio_flush(zio_t *zio, vdev_t *vd, enum zio_flag flags); 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 88a19292eb..8b485e1fbd 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_flush(zio, svd[v], ZIO_FLAG_DONT_PROPAGATE); } } @@ -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_flush(zio, vd, ZIO_FLAG_DONT_PROPAGATE); (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_flush(zio, vd, ZIO_FLAG_DONT_PROPAGATE); (void) zio_wait(zio); diff --git a/module/zfs/zil.c b/module/zfs/zil.c index fbf61f87b5..48a3e8fc40 100644 --- a/module/zfs/zil.c +++ b/module/zfs/zil.c @@ -1322,7 +1322,8 @@ zil_lwb_write_done(zio_t *zio) * since these "zio_flush" errors will not be * propagated up to "zil_lwb_flush_vdevs_done". */ - zio_flush(lwb->lwb_root_zio, vd); + zio_flush(lwb->lwb_root_zio, vd, + ZIO_FLAG_DONT_PROPAGATE); } kmem_free(zv, sizeof (*zv)); } diff --git a/module/zfs/zio.c b/module/zfs/zio.c index 45397d89bb..9033316873 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -1502,11 +1502,10 @@ zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, abd_t *data, uint64_t size, } void -zio_flush(zio_t *zio, vdev_t *vd) +zio_flush(zio_t *zio, vdev_t *vd, enum zio_flag flags) { zio_nowait(zio_ioctl(zio, zio->io_spa, vd, DKIOCFLUSHWRITECACHE, - NULL, NULL, - ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY)); + NULL, NULL, flags | ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_RETRY)); } void