]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Use VOP_ADVISE() with POSIX_FADV_DONTNEED instead of IO_DIRECT to
authorbde <bde@FreeBSD.org>
Fri, 21 Dec 2018 08:15:31 +0000 (08:15 +0000)
committerbde <bde@FreeBSD.org>
Fri, 21 Dec 2018 08:15:31 +0000 (08:15 +0000)
commitde7f82e0773386e0171af4a2fdcb2141fd1354cc
tree402402187f33b247002f645cf699e4459e2bf0b8
parentf15290be5b50ccc58d1ac32597974f6f7207c515
Use VOP_ADVISE() with POSIX_FADV_DONTNEED instead of IO_DIRECT to
implement not double-caching for reads from vnode-backed md devices.
Use VOP_ADVISE() similarly instead of !IO_DIRECT unsimilarly for writes.
Add a "cache" option to mdconfig to allow changing the default of not
caching.

This depends on a recent commit to fix VOP_ADVISE().  A previous version
had optimizations for sequential i/o's (merge the i/o's and only uncache
for discontiguous i/o's and for full blocks), but optimizations and
knowledge of block boundaries belong in VOP_ADVISE().  Read-ahead should
also be handled better, by supporting it in md and discarding it in
VOP_ADVISE().

POSIX_FADV_DONTNEED is ignored by zfs, but so is IO_DIRECT.

POSIX_FADV_DONTNEED works better than IO_DIRECT if it is not ignored,
since it only discards from the buffer cache immediately, while
IO_DIRECT also discards from the page cache immediately.

IO_DIRECT was not used for writes since it was claimed to be too slow,
but most of the slowness for writes is from doing them synchronously by
default.  Non-synchronous writes still deadlock in many cases.

IO_DIRECT only has a special implementation for ffs reads with DIRECTIO
configured.  Otherwise, if it is not ignored than it uses the buffer and
page caches normally except for discarding everything after each i/o,
and then it has much the same overheads as POSIX_FADV_DONTNEED.  The
overheads for reading with ffs and DIRECTIO were similar in tests of md.

Reviewed by: kib
sbin/mdconfig/mdconfig.8
sbin/mdconfig/mdconfig.c
sys/dev/md/md.c
sys/sys/mdioctl.h