1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3 Date: Wed, 30 Nov 2016 10:27:47 +0100
4 Subject: [PATCH] PVE: [Up] glusterfs: allow partial reads
6 This should deal with qemu bug #1644754 until upstream
7 decides which way to go. The general direction seems to be
8 away from sector based block APIs and with that in mind, and
9 when comparing to other network block backends (eg. nfs)
10 treating partial reads as errors doesn't seem to make much
13 block/gluster.c | 10 +++++++++-
14 1 file changed, 9 insertions(+), 1 deletion(-)
16 diff --git a/block/gluster.c b/block/gluster.c
17 index 20d99aa1c3..569866421b 100644
20 @@ -45,6 +45,7 @@ typedef struct GlusterAIOCB {
23 AioContext *aio_context;
27 typedef struct BDRVGlusterState {
28 @@ -740,8 +741,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret, void *arg)
29 acb->ret = 0; /* Success */
31 acb->ret = -errno; /* Read/Write failed */
32 + } else if (acb->is_write) {
33 + acb->ret = -EIO; /* Partial write - fail it */
35 - acb->ret = -EIO; /* Partial read/write - fail it */
36 + acb->ret = 0; /* Success */
39 aio_co_schedule(acb->aio_context, acb->coroutine);
40 @@ -989,6 +992,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
42 acb.coroutine = qemu_coroutine_self();
43 acb.aio_context = bdrv_get_aio_context(bs);
44 + acb.is_write = true;
46 ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
48 @@ -1169,9 +1173,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
49 acb.aio_context = bdrv_get_aio_context(bs);
52 + acb.is_write = true;
53 ret = glfs_pwritev_async(s->fd, qiov->iov, qiov->niov, offset, 0,
54 gluster_finish_aiocb, &acb);
56 + acb.is_write = false;
57 ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
58 gluster_finish_aiocb, &acb);
60 @@ -1233,6 +1239,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
62 acb.coroutine = qemu_coroutine_self();
63 acb.aio_context = bdrv_get_aio_context(bs);
64 + acb.is_write = true;
66 ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
68 @@ -1279,6 +1286,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
70 acb.coroutine = qemu_coroutine_self();
71 acb.aio_context = bdrv_get_aio_context(bs);
72 + acb.is_write = true;
74 ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb);