openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.25k stars 1.7k forks source link

vdev_disk: disable flushes if device does not support it #16148

Closed robn closed 1 month ago

robn commented 1 month ago

Motivation and Context

If the underlying device doesn't have a write-back cache, the kernel will just return a successful response. This doesn't hurt anything, but it's extra work on the IO taskqs that are unnecessary.

Description

When opening the device, check its "has a write cache" flag, and set the vdev_nowritecache from it. On older kernels, we just assume a write cache to start, as we always have.

How Has This Been Tested?

Full test suite run against 6.1.76 passed, not that it really exercises any of this. Some by-hand testing with loop devices changing /sys/block/loopX/queue/write_cache seems to show vdev_nowritecache being initialised properly. I'd apprecate a test from someone with actual devices with no write cache.

Types of changes

Checklist: