]> git.proxmox.com Git - pve-qemu.git/blame - debian/patches/pve/0009-PVE-Up-glusterfs-allow-partial-reads.patch
Update and rebase to QEMU 4.1
[pve-qemu.git] / debian / patches / pve / 0009-PVE-Up-glusterfs-allow-partial-reads.patch
CommitLineData
23102ed6 1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
95259824
WB
2From: Wolfgang Bumiller <w.bumiller@proxmox.com>
3Date: Wed, 30 Nov 2016 10:27:47 +0100
53e83913 4Subject: [PATCH] PVE: [Up] glusterfs: allow partial reads
95259824
WB
5
6This should deal with qemu bug #1644754 until upstream
7decides which way to go. The general direction seems to be
8away from sector based block APIs and with that in mind, and
9when comparing to other network block backends (eg. nfs)
10treating partial reads as errors doesn't seem to make much
11sense.
b855dce7
TL
12
13Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
95259824
WB
14---
15 block/gluster.c | 10 +++++++++-
16 1 file changed, 9 insertions(+), 1 deletion(-)
17
18diff --git a/block/gluster.c b/block/gluster.c
be901f66 19index 061cab48c0..0ed1ec5856 100644
95259824
WB
20--- a/block/gluster.c
21+++ b/block/gluster.c
be901f66 22@@ -57,6 +57,7 @@ typedef struct GlusterAIOCB {
a544966d 23 int ret;
95259824
WB
24 Coroutine *coroutine;
25 AioContext *aio_context;
26+ bool is_write;
27 } GlusterAIOCB;
28
29 typedef struct BDRVGlusterState {
be901f66 30@@ -763,8 +764,10 @@ static void gluster_finish_aiocb(struct glfs_fd *fd, ssize_t ret,
95259824
WB
31 acb->ret = 0; /* Success */
32 } else if (ret < 0) {
33 acb->ret = -errno; /* Read/Write failed */
34+ } else if (acb->is_write) {
35+ acb->ret = -EIO; /* Partial write - fail it */
36 } else {
37- acb->ret = -EIO; /* Partial read/write - fail it */
38+ acb->ret = 0; /* Success */
39 }
40
a544966d 41 aio_co_schedule(acb->aio_context, acb->coroutine);
be901f66 42@@ -1035,6 +1038,7 @@ static coroutine_fn int qemu_gluster_co_pwrite_zeroes(BlockDriverState *bs,
95259824
WB
43 acb.ret = 0;
44 acb.coroutine = qemu_coroutine_self();
45 acb.aio_context = bdrv_get_aio_context(bs);
46+ acb.is_write = true;
47
48 ret = glfs_zerofill_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
49 if (ret < 0) {
be901f66 50@@ -1215,9 +1219,11 @@ static coroutine_fn int qemu_gluster_co_rw(BlockDriverState *bs,
95259824
WB
51 acb.aio_context = bdrv_get_aio_context(bs);
52
53 if (write) {
54+ acb.is_write = true;
55 ret = glfs_pwritev_async(s->fd, qiov->iov, qiov->niov, offset, 0,
56 gluster_finish_aiocb, &acb);
57 } else {
58+ acb.is_write = false;
59 ret = glfs_preadv_async(s->fd, qiov->iov, qiov->niov, offset, 0,
60 gluster_finish_aiocb, &acb);
61 }
be901f66 62@@ -1279,6 +1285,7 @@ static coroutine_fn int qemu_gluster_co_flush_to_disk(BlockDriverState *bs)
95259824
WB
63 acb.ret = 0;
64 acb.coroutine = qemu_coroutine_self();
65 acb.aio_context = bdrv_get_aio_context(bs);
66+ acb.is_write = true;
67
68 ret = glfs_fsync_async(s->fd, gluster_finish_aiocb, &acb);
69 if (ret < 0) {
be901f66 70@@ -1325,6 +1332,7 @@ static coroutine_fn int qemu_gluster_co_pdiscard(BlockDriverState *bs,
95259824
WB
71 acb.ret = 0;
72 acb.coroutine = qemu_coroutine_self();
73 acb.aio_context = bdrv_get_aio_context(bs);
74+ acb.is_write = true;
75
76 ret = glfs_discard_async(s->fd, offset, size, gluster_finish_aiocb, &acb);
77 if (ret < 0) {