qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Virtbie <virtbie@shiftmail.org>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: Kevin Wolf <kwolf@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Is cache=writeback safe yet?
Date: Mon, 20 Feb 2012 18:52:44 +0100	[thread overview]
Message-ID: <4F42886C.1010804@shiftmail.org> (raw)
In-Reply-To: <4F426A16.9090609@shiftmail.org>

On 02/20/12 16:43, Virtbie wrote:
>
> Great explanation Anthony,
>
> may I still ask:
>
> 1)
> Is WCE + volatile flag exposed to the guest, by all three virtual 
> devices:
> - virtio
> - scsi
> - ide
> ?
> (if not, I still don't understand how this works)
>
>
> 2) Is there a minimum guest kernel and a minimum viostor Windows 
> driver version, to see such WCE+volatile flag in a virtio disk, so 
> that the guest OS can actually see the cache?
>
>
> Because I can't seem to find such flag for a virtio disk on a linux 
> 2.6.38 guest and that seems serious to me.
> Is it visible somewhere in /sys hierarchy? Or is 2.6.38 too old?
>

Is it this commit?

commit f1b0ef062602713c2c7cfa12362d5d90ed01c5f6
Author: Christoph Hellwig <hch@lst.de>
Date:   Thu Sep 17 19:57:42 2009 +0200

     virtio_blk: add support for cache flush

     Recent qemu has added a VIRTIO_BLK_F_FLUSH flag to advertise that the
     virtual disk has a volatile write cache that needs to be flushed.  
In case
     we see this feature implement tell the Linux block layer about the fact
     and use the new VIRTIO_BLK_T_FLUSH to flush the cache when 
required.  This
     allows for an correct and simple implementation of write barriers.

     Signed-off-by: Christoph Hellwig <hch@lst.de>
     Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>



That was introduced in 2.6.32 .
So can I suppose that a guest running linux 2.6.32+ detects the write 
cache in a virtio disk and actually flushes? (suppose a wise filesystem)


The flag seems to go into :

     /* Feature bits */
     #define VIRTIO_BLK_F_BARRIER    0       /* Does host support 
barriers? */
     #define VIRTIO_BLK_F_SIZE_MAX   1       /* Indicates maximum 
segment size */
     #define VIRTIO_BLK_F_SEG_MAX    2       /* Indicates maximum # of 
segments */
     #define VIRTIO_BLK_F_GEOMETRY   4       /* Legacy geometry 
available  */
     #define VIRTIO_BLK_F_RO         5       /* Disk is read-only */
     #define VIRTIO_BLK_F_BLK_SIZE   6       /* Block size of disk is 
available*/
     #define VIRTIO_BLK_F_SCSI       7       /* Supports scsi command 
passthru */
     #define VIRTIO_BLK_F_FLUSH      9       /* Cache flush command 
support */
     #define VIRTIO_BLK_F_TOPOLOGY   10      /* Topology information is 
available */

     #define VIRTIO_BLK_ID_BYTES     20      /* ID string length */

     ........

     static unsigned int features[] = {
             VIRTIO_BLK_F_SEG_MAX, VIRTIO_BLK_F_SIZE_MAX, 
VIRTIO_BLK_F_GEOMETRY,
             VIRTIO_BLK_F_RO, VIRTIO_BLK_F_BLK_SIZE, VIRTIO_BLK_F_SCSI,
             VIRTIO_BLK_F_FLUSH, VIRTIO_BLK_F_TOPOLOGY
     };

so the presence of volatile cache is probably exposed by:

     $ cat /sys/block/vda/device/features
     0010101101100000000000000000100000000000000000000000000000000000

I don't understand if I should look at the 10th bit (9 in 0-based as per 
#define's ) which would be 0 == "no cache" in this case, or at the 7th 
bit (by the position in features[] array), which would be 1 == "has 
cache" in this case .


Thank you
Vb.

  reply	other threads:[~2012-02-20 17:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-20 14:18 [Qemu-devel] Is cache=writeback safe yet? Virtbie
2012-02-20 15:06 ` Anthony Liguori
2012-02-20 15:43   ` Virtbie
2012-02-20 17:52     ` Virtbie [this message]
2012-02-20 15:20 ` Kevin Wolf
2012-02-20 15:29   ` Peter Maydell
2012-02-20 15:56     ` Kevin Wolf
2012-02-20 16:08       ` Peter Maydell
2012-02-20 17:03         ` Paolo Bonzini
2012-02-20 17:10           ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F42886C.1010804@shiftmail.org \
    --to=virtbie@shiftmail.org \
    --cc=anthony@codemonkey.ws \
    --cc=kwolf@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).