qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] virtio-blk: stop tracking old_bs


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH 1/2] virtio-blk: stop tracking old_bs
Date: Mon, 14 Jun 2010 15:57:58 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4

On 06/08/2010 11:25 AM, Christoph Hellwig wrote:
There is a 1:1 relation between VirtIOBlock and BlockDriverState instances,
no need to track it because it won't change.

Signed-off-by: Christoph Hellwig<address@hidden>

Applied all.  Thanks.

Regards,

Anthony Liguori
Index: qemu/hw/virtio-blk.c
===================================================================
--- qemu.orig/hw/virtio-blk.c   2010-05-26 13:36:07.000000000 +0200
+++ qemu/hw/virtio-blk.c        2010-06-08 11:19:56.253262216 +0200
@@ -241,18 +241,17 @@ static void do_multiwrite(BlockDriverSta
  }

  static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,
-    VirtIOBlockReq *req, BlockDriverState **old_bs)
+    VirtIOBlockReq *req)
  {
      BlockDriverAIOCB *acb;

      /*
       * Make sure all outstanding writes are posted to the backing device.
       */
-    if (*old_bs != NULL) {
-        do_multiwrite(*old_bs, blkreq, *num_writes);
+    if (*num_writes>  0) {
+        do_multiwrite(req->dev->bs, blkreq, *num_writes);
      }
      *num_writes = 0;
-    *old_bs = req->dev->bs;

      acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);
      if (!acb) {
@@ -261,19 +260,16 @@ static void virtio_blk_handle_flush(Bloc
  }

  static void virtio_blk_handle_write(BlockRequest *blkreq, int *num_writes,
-    VirtIOBlockReq *req, BlockDriverState **old_bs)
+    VirtIOBlockReq *req)
  {
      if (req->out->sector&  req->dev->sector_mask) {
          virtio_blk_rw_complete(req, -EIO);
          return;
      }

-    if (req->dev->bs != *old_bs || *num_writes == 32) {
-        if (*old_bs != NULL) {
-            do_multiwrite(*old_bs, blkreq, *num_writes);
-        }
+    if (*num_writes == 32) {
+        do_multiwrite(req->dev->bs, blkreq, *num_writes);
          *num_writes = 0;
-        *old_bs = req->dev->bs;
      }

      blkreq[*num_writes].sector = req->out->sector;
@@ -305,7 +301,6 @@ static void virtio_blk_handle_read(VirtI
  typedef struct MultiReqBuffer {
      BlockRequest        blkreq[32];
      int                 num_writes;
-    BlockDriverState    *old_bs;
  } MultiReqBuffer;

  static void virtio_blk_handle_request(VirtIOBlockReq *req,
@@ -326,15 +321,13 @@ static void virtio_blk_handle_request(Vi
      req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base;

      if (req->out->type&  VIRTIO_BLK_T_FLUSH) {
-        virtio_blk_handle_flush(mrb->blkreq,&mrb->num_writes,
-            req,&mrb->old_bs);
+        virtio_blk_handle_flush(mrb->blkreq,&mrb->num_writes, req);
      } else if (req->out->type&  VIRTIO_BLK_T_SCSI_CMD) {
          virtio_blk_handle_scsi(req);
      } else if (req->out->type&  VIRTIO_BLK_T_OUT) {
          qemu_iovec_init_external(&req->qiov,&req->elem.out_sg[1],
                                   req->elem.out_num - 1);
-        virtio_blk_handle_write(mrb->blkreq,&mrb->num_writes,
-            req,&mrb->old_bs);
+        virtio_blk_handle_write(mrb->blkreq,&mrb->num_writes, req);
      } else {
          qemu_iovec_init_external(&req->qiov,&req->elem.in_sg[0],
                                   req->elem.in_num - 1);
@@ -348,7 +341,6 @@ static void virtio_blk_handle_output(Vir
      VirtIOBlockReq *req;
      MultiReqBuffer mrb = {
          .num_writes = 0,
-        .old_bs = NULL,
      };

      while ((req = virtio_blk_get_request(s))) {
@@ -356,7 +348,7 @@ static void virtio_blk_handle_output(Vir
      }

      if (mrb.num_writes>  0) {
-        do_multiwrite(mrb.old_bs, mrb.blkreq, mrb.num_writes);
+        do_multiwrite(s->bs, mrb.blkreq, mrb.num_writes);
      }

      /*
@@ -372,7 +364,6 @@ static void virtio_blk_dma_restart_bh(vo
      VirtIOBlockReq *req = s->rq;
      MultiReqBuffer mrb = {
          .num_writes = 0,
-        .old_bs = NULL,
      };

      qemu_bh_delete(s->bh);
@@ -386,7 +377,7 @@ static void virtio_blk_dma_restart_bh(vo
      }

      if (mrb.num_writes>  0) {
-        do_multiwrite(mrb.old_bs, mrb.blkreq, mrb.num_writes);
+        do_multiwrite(s->bs, mrb.blkreq, mrb.num_writes);
      }
  }







reply via email to

[Prev in Thread] Current Thread [Next in Thread]