qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] barriers: virtio
Date: Tue, 5 May 2009 14:09:05 +0200	[thread overview]
Message-ID: <20090505120905.GC30721@lst.de> (raw)
In-Reply-To: <20090505120804.GA30651@lst.de>

Advertise the barriers feature to virtio guests if the underlying device
supports it, and make sure to pass down the barrier flag on write requests
to the block layer.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: qemu/hw/virtio-blk.c
===================================================================
--- qemu.orig/hw/virtio-blk.c	2009-05-05 13:21:24.196784347 +0200
+++ qemu/hw/virtio-blk.c	2009-05-05 13:31:33.654786861 +0200
@@ -211,8 +211,14 @@ static void virtio_blk_handle_scsi(VirtI
 
 static void virtio_blk_handle_write(VirtIOBlockReq *req)
 {
+
+    unsigned flags = 0;
+
+    if (req->out->type & VIRTIO_BLK_T_BARRIER)
+        flags |= BDRV_IO_BARRIER;
+
     bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov,
-                    req->qiov.size / 512, virtio_blk_rw_complete, req, 0);
+                    req->qiov.size / 512, virtio_blk_rw_complete, req, flags);
 }
 
 static void virtio_blk_handle_read(VirtIOBlockReq *req)
@@ -304,6 +310,7 @@ static void virtio_blk_update_config(Vir
 
 static uint32_t virtio_blk_get_features(VirtIODevice *vdev)
 {
+    VirtIOBlock *s = to_virtio_blk(vdev);
     uint32_t features = 0;
 
     features |= (1 << VIRTIO_BLK_F_SEG_MAX);
@@ -312,6 +319,9 @@ static uint32_t virtio_blk_get_features(
     features |= (1 << VIRTIO_BLK_F_SCSI);
 #endif
 
+    if (s->bs->barrier_support)
+        features |= (1 << VIRTIO_BLK_F_BARRIER);
+
     return features;
 }
 

  parent reply	other threads:[~2009-05-05 12:09 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-05 12:08 [Qemu-devel] [PATCH 0/3] write barrier support Christoph Hellwig
2009-05-05 12:08 ` [Qemu-devel] barriers: block layer preparations Christoph Hellwig
2009-05-05 13:51   ` Avi Kivity
2009-05-05 15:38     ` Jamie Lokier
2009-05-05 15:49       ` Avi Kivity
2009-05-05 16:00         ` Jamie Lokier
2009-05-05 20:57     ` Christoph Hellwig
2009-05-05 22:49       ` Jamie Lokier
2009-05-05 12:08 ` [Qemu-devel] [PATCH 2/3] barriers: block-raw-posix barrier support Christoph Hellwig
2009-05-05 12:33   ` Jamie Lokier
2009-05-05 13:29     ` Christoph Hellwig
2009-05-05 16:00       ` Jamie Lokier
2009-05-05 12:09 ` Christoph Hellwig [this message]
2009-05-05 13:53 ` [Qemu-devel] [PATCH 0/3] write " Avi Kivity
2009-05-05 21:00   ` Christoph Hellwig

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=20090505120905.GC30721@lst.de \
    --to=hch@lst.de \
    --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).