virtio-blk: stop tracking old_bs
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> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
46aaebff40
commit
7e608e8903
|
@ -239,18 +239,17 @@ static void do_multiwrite(BlockDriverState *bs, BlockRequest *blkreq,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,
|
static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,
|
||||||
VirtIOBlockReq *req, BlockDriverState **old_bs)
|
VirtIOBlockReq *req)
|
||||||
{
|
{
|
||||||
BlockDriverAIOCB *acb;
|
BlockDriverAIOCB *acb;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure all outstanding writes are posted to the backing device.
|
* Make sure all outstanding writes are posted to the backing device.
|
||||||
*/
|
*/
|
||||||
if (*old_bs != NULL) {
|
if (*num_writes > 0) {
|
||||||
do_multiwrite(*old_bs, blkreq, *num_writes);
|
do_multiwrite(req->dev->bs, blkreq, *num_writes);
|
||||||
}
|
}
|
||||||
*num_writes = 0;
|
*num_writes = 0;
|
||||||
*old_bs = req->dev->bs;
|
|
||||||
|
|
||||||
acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);
|
acb = bdrv_aio_flush(req->dev->bs, virtio_blk_flush_complete, req);
|
||||||
if (!acb) {
|
if (!acb) {
|
||||||
|
@ -259,19 +258,16 @@ static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void virtio_blk_handle_write(BlockRequest *blkreq, int *num_writes,
|
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) {
|
if (req->out->sector & req->dev->sector_mask) {
|
||||||
virtio_blk_rw_complete(req, -EIO);
|
virtio_blk_rw_complete(req, -EIO);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req->dev->bs != *old_bs || *num_writes == 32) {
|
if (*num_writes == 32) {
|
||||||
if (*old_bs != NULL) {
|
do_multiwrite(req->dev->bs, blkreq, *num_writes);
|
||||||
do_multiwrite(*old_bs, blkreq, *num_writes);
|
|
||||||
}
|
|
||||||
*num_writes = 0;
|
*num_writes = 0;
|
||||||
*old_bs = req->dev->bs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blkreq[*num_writes].sector = req->out->sector;
|
blkreq[*num_writes].sector = req->out->sector;
|
||||||
|
@ -304,7 +300,6 @@ static void virtio_blk_handle_read(VirtIOBlockReq *req)
|
||||||
typedef struct MultiReqBuffer {
|
typedef struct MultiReqBuffer {
|
||||||
BlockRequest blkreq[32];
|
BlockRequest blkreq[32];
|
||||||
int num_writes;
|
int num_writes;
|
||||||
BlockDriverState *old_bs;
|
|
||||||
} MultiReqBuffer;
|
} MultiReqBuffer;
|
||||||
|
|
||||||
static void virtio_blk_handle_request(VirtIOBlockReq *req,
|
static void virtio_blk_handle_request(VirtIOBlockReq *req,
|
||||||
|
@ -325,15 +320,13 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req,
|
||||||
req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base;
|
req->in = (void *)req->elem.in_sg[req->elem.in_num - 1].iov_base;
|
||||||
|
|
||||||
if (req->out->type & VIRTIO_BLK_T_FLUSH) {
|
if (req->out->type & VIRTIO_BLK_T_FLUSH) {
|
||||||
virtio_blk_handle_flush(mrb->blkreq, &mrb->num_writes,
|
virtio_blk_handle_flush(mrb->blkreq, &mrb->num_writes, req);
|
||||||
req, &mrb->old_bs);
|
|
||||||
} else if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) {
|
} else if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) {
|
||||||
virtio_blk_handle_scsi(req);
|
virtio_blk_handle_scsi(req);
|
||||||
} else if (req->out->type & VIRTIO_BLK_T_OUT) {
|
} else if (req->out->type & VIRTIO_BLK_T_OUT) {
|
||||||
qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
|
qemu_iovec_init_external(&req->qiov, &req->elem.out_sg[1],
|
||||||
req->elem.out_num - 1);
|
req->elem.out_num - 1);
|
||||||
virtio_blk_handle_write(mrb->blkreq, &mrb->num_writes,
|
virtio_blk_handle_write(mrb->blkreq, &mrb->num_writes, req);
|
||||||
req, &mrb->old_bs);
|
|
||||||
} else {
|
} else {
|
||||||
qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
|
qemu_iovec_init_external(&req->qiov, &req->elem.in_sg[0],
|
||||||
req->elem.in_num - 1);
|
req->elem.in_num - 1);
|
||||||
|
@ -347,7 +340,6 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
VirtIOBlockReq *req;
|
VirtIOBlockReq *req;
|
||||||
MultiReqBuffer mrb = {
|
MultiReqBuffer mrb = {
|
||||||
.num_writes = 0,
|
.num_writes = 0,
|
||||||
.old_bs = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
while ((req = virtio_blk_get_request(s))) {
|
while ((req = virtio_blk_get_request(s))) {
|
||||||
|
@ -355,7 +347,7 @@ static void virtio_blk_handle_output(VirtIODevice *vdev, VirtQueue *vq)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mrb.num_writes > 0) {
|
if (mrb.num_writes > 0) {
|
||||||
do_multiwrite(mrb.old_bs, mrb.blkreq, mrb.num_writes);
|
do_multiwrite(s->bs, mrb.blkreq, mrb.num_writes);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -371,7 +363,6 @@ static void virtio_blk_dma_restart_bh(void *opaque)
|
||||||
VirtIOBlockReq *req = s->rq;
|
VirtIOBlockReq *req = s->rq;
|
||||||
MultiReqBuffer mrb = {
|
MultiReqBuffer mrb = {
|
||||||
.num_writes = 0,
|
.num_writes = 0,
|
||||||
.old_bs = NULL,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
qemu_bh_delete(s->bh);
|
qemu_bh_delete(s->bh);
|
||||||
|
@ -385,7 +376,7 @@ static void virtio_blk_dma_restart_bh(void *opaque)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mrb.num_writes > 0) {
|
if (mrb.num_writes > 0) {
|
||||||
do_multiwrite(mrb.old_bs, mrb.blkreq, mrb.num_writes);
|
do_multiwrite(s->bs, mrb.blkreq, mrb.num_writes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue