[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 25/42] dataplane: implement async flush
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 25/42] dataplane: implement async flush |
Date: |
Fri, 6 Jun 2014 18:13:46 +0200 |
Stop using the raw-posix file descriptor for synchronous
qemu_fdatasync(). Use bdrv_aio_flush() instead and drop the
VirtIOBlockDataPlane->fd field.
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
hw/block/dataplane/virtio-blk.c | 43 ++++++++++++++++++++++++++---------------
1 file changed, 27 insertions(+), 16 deletions(-)
diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-blk.c
index 75616da..c058c73 100644
--- a/hw/block/dataplane/virtio-blk.c
+++ b/hw/block/dataplane/virtio-blk.c
@@ -40,7 +40,6 @@ struct VirtIOBlockDataPlane {
bool stopping;
VirtIOBlkConf *blk;
- int fd; /* image file descriptor */
VirtIODevice *vdev;
Vring vring; /* virtqueue vring */
@@ -179,6 +178,32 @@ static void do_rdwr_cmd(VirtIOBlockDataPlane *s, bool read,
}
}
+static void complete_flush(void *opaque, int ret)
+{
+ VirtIOBlockRequest *req = opaque;
+ unsigned char status;
+
+ if (ret == 0) {
+ status = VIRTIO_BLK_S_OK;
+ } else {
+ status = VIRTIO_BLK_S_IOERR;
+ }
+
+ complete_request_early(req->s, req->elem, req->inhdr, status);
+ g_slice_free(VirtIOBlockRequest, req);
+}
+
+static void do_flush_cmd(VirtIOBlockDataPlane *s, VirtQueueElement *elem,
+ QEMUIOVector *inhdr)
+{
+ VirtIOBlockRequest *req = g_slice_new(VirtIOBlockRequest);
+ req->s = s;
+ req->elem = elem;
+ req->inhdr = inhdr;
+
+ bdrv_aio_flush(s->blk->conf.bs, complete_flush, req);
+}
+
static int process_request(VirtIOBlockDataPlane *s, VirtQueueElement *elem)
{
struct iovec *iov = elem->out_sg;
@@ -232,12 +257,7 @@ static int process_request(VirtIOBlockDataPlane *s,
VirtQueueElement *elem)
return 0;
case VIRTIO_BLK_T_FLUSH:
- /* TODO fdsync not supported by Linux AIO, do it synchronously here! */
- if (qemu_fdatasync(s->fd) < 0) {
- complete_request_early(s, elem, inhdr, VIRTIO_BLK_S_IOERR);
- } else {
- complete_request_early(s, elem, inhdr, VIRTIO_BLK_S_OK);
- }
+ do_flush_cmd(s, elem, inhdr);
return 0;
case VIRTIO_BLK_T_GET_ID:
@@ -302,7 +322,6 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev,
VirtIOBlkConf *blk,
Error **errp)
{
VirtIOBlockDataPlane *s;
- int fd;
Error *local_err = NULL;
*dataplane = NULL;
@@ -333,16 +352,8 @@ void virtio_blk_data_plane_create(VirtIODevice *vdev,
VirtIOBlkConf *blk,
return;
}
- fd = raw_get_aio_fd(blk->conf.bs);
- if (fd < 0) {
- error_setg(errp, "drive is incompatible with x-data-plane, "
- "use format=raw,cache=none,aio=native");
- return;
- }
-
s = g_new0(VirtIOBlockDataPlane, 1);
s->vdev = vdev;
- s->fd = fd;
s->blk = blk;
if (blk->iothread) {
--
1.9.3
- [Qemu-devel] [PULL 10/42] iscsi: implement .bdrv_detach/attach_aio_context(), (continued)
- [Qemu-devel] [PULL 10/42] iscsi: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 12/42] nfs: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 14/42] quorum: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 13/42] qed: use BlockDriverState's AioContext, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 15/42] block/raw-posix: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 16/42] block/linux-aio: fix memory and fd leak, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 17/42] block/raw-win32: create one QEMUWin32AIOState per BDRVRawState, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 19/42] rbd: use BlockDriverState's AioContext, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 18/42] block/raw-win32: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 24/42] dataplane: delete IOQueue since it is no longer used, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 25/42] dataplane: implement async flush,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 20/42] sheepdog: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 26/42] raw-posix: drop raw_get_aio_fd() since it is no longer used, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 27/42] block: Move declaration of bdrv_get_aio_context to block.h, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 22/42] vmdk: implement .bdrv_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 28/42] virtio-blk: Allow config-wce in dataplane, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 29/42] virtio-blk: Factor out virtio_blk_handle_scsi_req from virtio_blk_handle_scsi, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 31/42] throttle: add throttle_detach/attach_aio_context(), Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 30/42] dataplane: Support VIRTIO_BLK_T_SCSI_CMD, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 32/42] throttle: add detach/attach test case, Stefan Hajnoczi, 2014/06/06
- [Qemu-devel] [PULL 33/42] blockdev: acquire AioContext in block_set_io_throttle, Stefan Hajnoczi, 2014/06/06