]>
Commit | Line | Data |
---|---|---|
23102ed6 | 1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
95259824 | 2 | From: Wolfgang Bumiller <w.bumiller@proxmox.com> |
83faa3fe TL |
3 | Date: Mon, 6 Apr 2020 12:16:38 +0200 |
4 | Subject: [PATCH] PVE: [Up] glusterfs: allow partial reads | |
95259824 WB |
5 | |
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 | |
11 | sense. | |
b855dce7 TL |
12 | |
13 | Signed-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 | ||
18 | diff --git a/block/gluster.c b/block/gluster.c | |
4567474e | 19 | index 523304835e..80b75cb96c 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 { | |
8dca018b | 30 | @@ -752,8 +753,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); |
4567474e | 42 | @@ -1022,6 +1025,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 | ||
4567474e | 48 | ret = glfs_zerofill_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb); |
95259824 | 49 | if (ret < 0) { |
4567474e | 50 | @@ -1203,9 +1207,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 | } | |
4567474e | 62 | @@ -1269,6 +1275,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) { | |
4567474e | 70 | @@ -1317,6 +1324,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 | ||
4567474e | 76 | ret = glfs_discard_async(s->fd, offset, bytes, gluster_finish_aiocb, &acb); |
95259824 | 77 | if (ret < 0) { |