[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 3/8] virtio-blk: fix barrier support
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 3/8] virtio-blk: fix barrier support |
Date: |
Thu, 20 May 2010 15:10:38 +0200 |
From: Christoph Hellwig <address@hidden>
Before issuing the barrier to the block driver we need to flush our oustanding
queue of write requests, as the flush is supposed to be issued after them.
Signed-off-by: Christoph Hellwig <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
hw/virtio-blk.c | 15 +++++++++++++--
1 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index d270225..5d7f1a2 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -240,10 +240,20 @@ static void do_multiwrite(BlockDriverState *bs,
BlockRequest *blkreq,
}
}
-static void virtio_blk_handle_flush(VirtIOBlockReq *req)
+static void virtio_blk_handle_flush(BlockRequest *blkreq, int *num_writes,
+ VirtIOBlockReq *req, BlockDriverState **old_bs)
{
BlockDriverAIOCB *acb;
+ /*
+ * Make sure all outstanding writes are posted to the backing device.
+ */
+ if (*old_bs != NULL) {
+ do_multiwrite(*old_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) {
virtio_blk_req_complete(req, VIRTIO_BLK_S_IOERR);
@@ -316,7 +326,8 @@ static void virtio_blk_handle_request(VirtIOBlockReq *req,
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(req);
+ virtio_blk_handle_flush(mrb->blkreq, &mrb->num_writes,
+ req, &mrb->old_bs);
} else if (req->out->type & VIRTIO_BLK_T_SCSI_CMD) {
virtio_blk_handle_scsi(req);
} else if (req->out->type & VIRTIO_BLK_T_OUT) {
--
1.6.6.1
- [Qemu-devel] [PULL 0/8] Block patches, Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 2/8] virtio-blk: Avoid zeroing every request structure, Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 4/8] block: fix sector comparism in multiwrite_req_compare, Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 3/8] virtio-blk: fix barrier support,
Kevin Wolf <=
- [Qemu-devel] [PATCH 1/8] block: fix aio_flush segfaults for read-only protocols (e.g. curl), Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 5/8] block: Make find_image_format() return 'raw' BlockDriver for SG_IO devices, Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 6/8] block: Add SG_IO device check in refresh_total_sectors(), Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 8/8] vvfat: More build fixes with DEBUG, Kevin Wolf, 2010/05/20
- [Qemu-devel] [PATCH 7/8] vvfat: Fix compilation with DEBUG defined, Kevin Wolf, 2010/05/20