qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Christoph Hellwig <hch@lst.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/2] virtio-blk: stop tracking old_bs
Date: Mon, 14 Jun 2010 15:57:58 -0500	[thread overview]
Message-ID: <4C1697D6.2050008@codemonkey.ws> (raw)
In-Reply-To: <20100608162554.GA12253@lst.de>

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<hch@lst.de>
>    

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	other threads:[~2010-06-14 21:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-08 16:25 [Qemu-devel] [PATCH 1/2] virtio-blk: stop tracking old_bs Christoph Hellwig
2010-06-14 20:57 ` Anthony Liguori [this message]

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=4C1697D6.2050008@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=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).