Am 20.02.2012 16:29, schrieb Peter Maydell: > On 20 February 2012 15:20, Kevin Wolf <kw...@redhat.com> wrote: >> Am 20.02.2012 15:18, schrieb Virtbie: >>> Qemu manpage still says cache=writeback isn't safe, but I seem to find >>> some discordant information reading around. >>> >>> Is the WCE+volatile flag exposed to the guest already? I am logging into >>> a 2.6.38 guest and trying to find an indicator of disk cache in >>> /sys/block/vda/device but I am not able to. There is an obscure very >>> long "features" bitmask which I don't know what it shows. I think this >>> mode is not safe until WBC is exposed, AFAIU, right? >> >> qemu exposes the WCE flag and if your guest handles it correctly (i.e. >> it sends flush requests where needed), cache=writeback is safe. This is >> true for recent Linux versions. > > The thing that confuses me when this subject comes up is that > "cache=writeback" > is a property of the block layer, but the WCE flag is a SCSI parameter, > right? How does this work on non-SCSI disks? Is there something that > eg hw/sd.c should be doing to tell the block layer "writeback cache is > safe/unsafe" ?
IDE and virtio-blk have some kind of WCE bit as well. If your hardware doesn't have it, I think you need to check whether your hardware never has any write cache or if it always has one (if it sometimes has one but doesn't expose the information, it's already the hardware that is broken). You should probably just fail device creation with an inappropriate cache option. Kevin