Skip to content

Commit

Permalink
flush: don't report flush error when disabling flush support
Browse files Browse the repository at this point in the history
The first time a device returns ENOTSUP in repsonse to a flush request,
we set vdev_nowritecache so we don't issue flushes in the future and
instead just pretend the succeeded. However, we still return an error
for the initial flush, even though we just decided such errors are
meaningless!

So, when setting vdev_nowritecache in response to a flush error, also
reset the error code to assume success.

Along the way, it seems there's no good reason for vdev_disk & vdev_geom
to explicitly detect no support for flush and set vdev_nowritecache;
just letting the error through to zio_vdev_io_assess() will cause it all
to fall out nicely. So remove those checks.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
  • Loading branch information
robn committed Jul 26, 2024
1 parent df52925 commit 5cf1291
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 20 deletions.
15 changes: 0 additions & 15 deletions module/os/freebsd/zfs/vdev_geom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1018,21 +1018,6 @@ vdev_geom_io_intr(struct bio *bp)
zio->io_error = SET_ERROR(EIO);

switch (zio->io_error) {
case ENOTSUP:
/*
* If we get ENOTSUP for BIO_FLUSH or BIO_DELETE we know
* that future attempts will never succeed. In this case
* we set a persistent flag so that we don't bother with
* requests in the future.
*/
switch (bp->bio_cmd) {
case BIO_FLUSH:
vd->vdev_nowritecache = B_TRUE;
break;
case BIO_DELETE:
break;
}
break;
case ENXIO:
if (!vd->vdev_remove_wanted) {
/*
Expand Down
3 changes: 0 additions & 3 deletions module/os/linux/zfs/vdev_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -1232,9 +1232,6 @@ BIO_END_IO_PROTO(vdev_disk_io_flush_completion, bio, error)
zio->io_error = -error;
#endif

if (zio->io_error && (zio->io_error == EOPNOTSUPP))
zio->io_vd->vdev_nowritecache = B_TRUE;

bio_put(bio);
ASSERT3S(zio->io_error, >=, 0);
if (zio->io_error)
Expand Down
7 changes: 5 additions & 2 deletions module/zfs/zio.c
Original file line number Diff line number Diff line change
Expand Up @@ -4273,11 +4273,14 @@ zio_vdev_io_assess(zio_t *zio)
/*
* If a cache flush returns ENOTSUP or ENOTTY, we know that no future
* attempts will ever succeed. In this case we set a persistent
* boolean flag so that we don't bother with it in the future.
* boolean flag so that we don't bother with it in the future, and
* then we act like the flush succeeded.
*/
if ((zio->io_error == ENOTSUP || zio->io_error == ENOTTY) &&
zio->io_type == ZIO_TYPE_FLUSH && vd != NULL)
zio->io_type == ZIO_TYPE_FLUSH && vd != NULL) {
vd->vdev_nowritecache = B_TRUE;
zio->io_error = 0;
}

if (zio->io_error)
zio->io_pipeline = ZIO_INTERLOCK_PIPELINE;
Expand Down

0 comments on commit 5cf1291

Please sign in to comment.