Patchwork [2/3] virtio-blk: Fix restart after read error

login
register
mail settings
Submitter Kevin Wolf
Date Jan. 27, 2010, 12:12 p.m.
Message ID <1264594356-10375-3-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/43789/
State New
Headers show

Comments

Kevin Wolf - Jan. 27, 2010, 12:12 p.m.
Current code assumes that only write requests are ever going to be restarted.
This is wrong since rerror=stop exists. Instead of directly starting writes,
use the same request processing as used for new requests.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 hw/virtio-blk.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
Christoph Hellwig - Jan. 27, 2010, 6:20 p.m.
On Wed, Jan 27, 2010 at 01:12:35PM +0100, Kevin Wolf wrote:
> Current code assumes that only write requests are ever going to be restarted.
> This is wrong since rerror=stop exists. Instead of directly starting writes,
> use the same request processing as used for new requests.

Looks good,


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

Patch

diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index 82f96e5..5a413b9 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -384,6 +384,10 @@  static void virtio_blk_dma_restart_bh(void *opaque)
 {
     VirtIOBlock *s = opaque;
     VirtIOBlockReq *req = s->rq;
+    MultiReqBuffer mrb = {
+        .num_writes = 0,
+        .old_bs = NULL,
+    };
 
     qemu_bh_delete(s->bh);
     s->bh = NULL;
@@ -391,10 +395,13 @@  static void virtio_blk_dma_restart_bh(void *opaque)
     s->rq = NULL;
 
     while (req) {
-        bdrv_aio_writev(req->dev->bs, req->out->sector, &req->qiov,
-            req->qiov.size / 512, virtio_blk_rw_complete, req);
+        virtio_blk_handle_request(req, &mrb);
         req = req->next;
     }
+
+    if (mrb.num_writes > 0) {
+        do_multiwrite(mrb.old_bs, mrb.blkreq, mrb.num_writes);
+    }
 }
 
 static void virtio_blk_dma_restart_cb(void *opaque, int running, int reason)