mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
virtio-blk: fix barrier support
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 <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
de6c8042ec
commit
618fbb8429
1 changed files with 13 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue