Skip to content

Commit 98c24e9

Browse files
committed
ZIO: Optimize zio_flush()
- Generalize vdev_nowritecache handling by traversing through the VDEV tree and skipping children ZIOs where not supported. - Remove intermediate zio_null() in case of several VDEV children. - Remove children handling from zio_ioctl(). There are no other use cases for this code beside DKIOCFLUSHWRITECACHED, and would there be, I doubt they would so straightforward apply to all VDEV children. Comparing to removed previous optimization this should improve cases of redundant ZILs/SLOGs. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: George Wilson <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#15515
1 parent 27224c2 commit 98c24e9

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

module/zfs/zil.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ zil_lwb_write_done(zio_t *zio)
16221622

16231623
while ((zv = avl_destroy_nodes(t, &cookie)) != NULL) {
16241624
vdev_t *vd = vdev_lookup_top(spa, zv->zv_vdev);
1625-
if (vd != NULL && !vd->vdev_nowritecache) {
1625+
if (vd != NULL) {
16261626
/*
16271627
* The "ZIO_FLAG_DONT_PROPAGATE" is currently
16281628
* always used within "zio_flush". This means,

module/zfs/zio.c

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,23 +1435,10 @@ zio_t *
14351435
zio_ioctl(zio_t *pio, spa_t *spa, vdev_t *vd, int cmd,
14361436
zio_done_func_t *done, void *private, zio_flag_t flags)
14371437
{
1438-
zio_t *zio;
1439-
int c;
1440-
1441-
if (vd->vdev_children == 0) {
1442-
zio = zio_create(pio, spa, 0, NULL, NULL, 0, 0, done, private,
1443-
ZIO_TYPE_IOCTL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL,
1444-
ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE);
1445-
1446-
zio->io_cmd = cmd;
1447-
} else {
1448-
zio = zio_null(pio, spa, NULL, NULL, NULL, flags);
1449-
1450-
for (c = 0; c < vd->vdev_children; c++)
1451-
zio_nowait(zio_ioctl(zio, spa, vd->vdev_child[c], cmd,
1452-
done, private, flags));
1453-
}
1454-
1438+
zio_t *zio = zio_create(pio, spa, 0, NULL, NULL, 0, 0, done, private,
1439+
ZIO_TYPE_IOCTL, ZIO_PRIORITY_NOW, flags, vd, 0, NULL,
1440+
ZIO_STAGE_OPEN, ZIO_IOCTL_PIPELINE);
1441+
zio->io_cmd = cmd;
14551442
return (zio);
14561443
}
14571444

@@ -1622,11 +1609,18 @@ zio_vdev_delegated_io(vdev_t *vd, uint64_t offset, abd_t *data, uint64_t size,
16221609
}
16231610

16241611
void
1625-
zio_flush(zio_t *zio, vdev_t *vd)
1612+
zio_flush(zio_t *pio, vdev_t *vd)
16261613
{
1627-
zio_nowait(zio_ioctl(zio, zio->io_spa, vd, DKIOCFLUSHWRITECACHE,
1628-
NULL, NULL,
1629-
ZIO_FLAG_CANFAIL | ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY));
1614+
if (vd->vdev_nowritecache)
1615+
return;
1616+
if (vd->vdev_children == 0) {
1617+
zio_nowait(zio_ioctl(pio, vd->vdev_spa, vd,
1618+
DKIOCFLUSHWRITECACHE, NULL, NULL, ZIO_FLAG_CANFAIL |
1619+
ZIO_FLAG_DONT_PROPAGATE | ZIO_FLAG_DONT_RETRY));
1620+
} else {
1621+
for (uint64_t c = 0; c < vd->vdev_children; c++)
1622+
zio_flush(pio, vd->vdev_child[c]);
1623+
}
16301624
}
16311625

16321626
void

0 commit comments

Comments
 (0)