[pve-devel] Fwd: Re: recommanded cache setting for rbd image
Alexandre DERUMIER
aderumier at odiso.com
Wed Nov 7 13:54:35 CET 2012
also some infos here:
https://engage.eucalyptus.com/customer/portal/articles/753746-disabling-host-pagecache-for-instances-through-eucalyptus-libvirt-xsl-modification
" Typically both a KVM host and a running guest will use their own pagecaches to cache write operations to disk, the pagecache is not held on physical disk but rather in (much quicker) memory. With pageacaches, the Linux kernel considers a write operation to be complete once data has entered the pagecache. With writes to pagecache enabled on both KVM host and guest, data is being written into memory twice and this can put increased pressure on memory requirements. "
----- Mail original -----
De: "Alexandre DERUMIER" <aderumier at odiso.com>
À: "Dietmar Maurer" <dietmar at proxmox.com>
Cc: pve-devel at pve.proxmox.com
Envoyé: Mercredi 7 Novembre 2012 13:46:22
Objet: Re: [pve-devel] Fwd: Re: recommanded cache setting for rbd image
>> But why does a guest do not support flushes? What kind of guest is that?
also here :https://patchwork.kernel.org/patch/1151041/
"VIRTIO_BLK_F_FLUSH has been introduced in Linux 2.6.32 (in 2009) and
was backported to RHEL/CentOS 5.6 (in 2010). The Windows drivers have
two bugs, which I reported on the Red Hat Bugzilla as bugs 837321 and
837324. With these patches they will suffer a performance hit but
gain correctness."
So it's mainly for virtio-blk with kernel < 2.6.32 and buggy windows virtio drivers.
I'm beggining the benchs :)
----- Mail original -----
De: "Alexandre DERUMIER" <aderumier at odiso.com>
À: "Dietmar Maurer" <dietmar at proxmox.com>
Cc: pve-devel at pve.proxmox.com
Envoyé: Mercredi 7 Novembre 2012 08:09:23
Objet: Re: [pve-devel] Fwd: Re: recommanded cache setting for rbd image
>> But why does a guest do not support flushes? What kind of guest is that?
Some old kernels, or old filesystems version without barrier support.
Also virtio driver:
some virtio driver drivers versions doesn't support flushed
http://git.qemu-project.org/?p=qemu.git;a=commit;h=9315cbfd8d7074eca44fbc5f93902e97b27d5240
"
virtio-blk: disable write cache if not negotiated
If the guest does not support flushes, we should run in writethrough mode.
The setting is temporary until the next reset, so that for example the
BIOS will run in writethrough mode while Linux will run with a writeback
cache.
"
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 97bb4bd..fd8fa90 100644 (file)
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -543,6 +543,19 @@ static uint32_t virtio_blk_get_features(VirtIODevice *vdev, uint32_t features)
return features;
}
+static void virtio_blk_set_status(VirtIODevice *vdev, uint8_t status)
+{
+ VirtIOBlock *s = to_virtio_blk(vdev);
+ uint32_t features;
+
+ if (!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
+ return;
+ }
+
+ features = vdev->guest_features;
+ bdrv_set_enable_write_cache(s->bs, !!(features & (1 << VIRTIO_BLK_F_WCE)));
+}
+
static void virtio_blk_save(QEMUFile *f, void *opaque)
{
VirtIOBlock *s = opaque;
@@ -623,6 +636,7 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, VirtIOBlkConf *blk)
s->vdev.get_config = virtio_blk_update_config;
s->vdev.set_config = virtio_blk_set_config;
s->vdev.get_features = virtio_blk_get_features;
+ s->vdev.set_status = virtio_blk_set_status;
s->vdev.reset = virtio_blk_reset;
s->bs = blk->conf.bs;
s->conf = &blk->conf;
also
http://www.mail-archive.com/kvm@vger.kernel.org/msg74629.html
virtio-blk spec: writeback cache enable improvements
This patch introduces two improvements to writeback cache handling
in the virtio-blk spec.
1) The VIRTIO_BLK_F_FLUSH feature is renamed to VIRTIO_BLK_F_WCE, and
QEMU's behavior is documented explicitly as part of the spec: the host
negotiates the feature only if its cache is writeback. The obvious dual
requirement is imposed on the guest: it should negotiate the feature
only if it is able to send flushes. And in order to protect against
data loss, the spec now mandates that the host operates in writethrough
mode if the guest does not negotiate VIRTIO_BLK_F_WCE (this behavior
was already _allowed_ by the spec so far). This can change with every
reset of course; typically the BIOS will run as writethrough, while the
"main" OS will run in writeback mode. This is a backwards-compatible
refinement geared towards old or limited guests, so there is no need
for a new feature bit.
2) a second feature is added, VIRTIO_BLK_F_CONFIG_WCE, that provides
the same information in the configuration. This will enable the driver
to modify the write-cache setting at runtime (via sysfs for Linux, via
MODE SELECT for Windows).
-->So seem that if we put cache=writeback, and that virtio doesn't support flushes, it'll use writetrough, great :)
----- Mail original -----
De: "Dietmar Maurer" <dietmar at proxmox.com>
À: "Alexandre DERUMIER" <aderumier at odiso.com>
Cc: pve-devel at pve.proxmox.com
Envoyé: Mercredi 7 Novembre 2012 06:29:56
Objet: RE: [pve-devel] Fwd: Re: recommanded cache setting for rbd image
> >>block: default cache mode is now writeback
> >>
> >>so it is already 'writeback'?
> I think we need to read the qemu code. I don't know if writeback is writeback
> mode in guest or writeback in host.
> cache=none : writeback is guest
> cache=writeback : writeback is guest,writeback in host
So far, we only talk about cache mode in the host. I do not care what the guest it doing ;-)
> One another interesting thing in qemu 1.2 changelog:
>
> "Emulated IDE and SCSI as well as virtio-blk devices can now switch the cache
> mode between writethrough and writeback. virtio-blk automatically switches
> to writethrough if the guest driver doesn't support flushes. "
>
> So maybe if we set cache=none and that guest doesn't support flushes
> (drivers,kernel,?), it become writethrough in guest, so it's safe ?
No, default cache is 'writeback'. But this is unsafe when the guest doesn't support flushes.
That is why it is changed to writethrough to be safe.
But why does a guest do not support flushes? What kind of guest is that?
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
_______________________________________________
pve-devel mailing list
pve-devel at pve.proxmox.com
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
More information about the pve-devel
mailing list