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 <rob.norris@klarasystems.com>
(cherry picked from commit 6d0deb8a5a0c3d6bbc69d9625d55fc776bb98ea3)
This commit is contained in:
Rob Norris 2023-05-10 16:41:53 +10:00 committed by Geoff Amey
parent 589cea17a9
commit 8ec175d7e1
4 changed files with 8 additions and 8 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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));
}

View File

@ -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