On 16.08.2012 16:57, Wietse Venema wrote:
[]
> * With KVM and QEMU, one would set "cache=none" to bypass the write
>   cache in the physical host and make fsync() work as expected in
>   a virtual machine.

FWIW, with QEMU (kvm is just an "accelerator" for qemu, the
device model/emulation is exactly the same), cache flushes
are supported with all cache modes except of "unsafe" (which
is names that way for exactly this reason: flushes are
ignored).  So it is okay to run virtual machines with any
cache mode (except of the obvious).

Contrary to common misunderstanding, cache=none does NOT disable
write cache.  Only the default (up to current 1.1 version)
cache=writethrough disables write caching completely.  Instead,
cache=none disables filesystem cache or pagecache on the host
(hypervisor) only -- there's a cache in devices lower the
stack (disk drives etc).  So disk flushes are still needed
and are properly implemented.

cache=none corresponds to O_DIRECT (direct i/o, bypassing
buffer cache), and cache=writethrough corresponds to O_SYNC.

(there's anothe cache mode in recent qemu, directsync, which
combines O_DIRECT and O_SYNC).

/mjt

Reply via email to