1
The following changes since commit fe8ee082db5038a05dbd8872e946049e9a9c550e:
1
The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def:
2
2
3
Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2017-02-22' into staging (2017-02-24 15:00:51 +0000)
3
Merge remote-tracking branch 'remotes/quic/tags/pull-hex-20211006' into staging (2021-10-06 12:11:14 -0700)
4
4
5
are available in the git repository at:
5
are available in the Git repository at:
6
6
7
https://github.com/codyprime/qemu-kvm-jtc.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 1d393bdeae22fde2cb83c1ea719675747c85c40e:
9
for you to fetch changes up to 1cc7eada97914f090125e588497986f6f7900514:
10
10
11
RBD: Add support readv,writev for rbd (2017-02-24 12:43:01 -0500)
11
iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Block patches for 2.9
14
Pull request
15
15
----------------------------------------------------------------
16
----------------------------------------------------------------
16
17
17
Peter Lieven (2):
18
Stefano Garzarella (2):
18
block/nfs: convert to preadv / pwritev
19
iothread: rename PollParamInfo to IOThreadParamInfo
19
block/nfs: try to avoid the bounce buffer in pwritev
20
iothread: use IOThreadParamInfo in iothread_[set|get]_param()
20
21
21
tianqing (1):
22
iothread.c | 28 +++++++++++++++-------------
22
RBD: Add support readv,writev for rbd
23
1 file changed, 15 insertions(+), 13 deletions(-)
23
24
block/nfs.c | 62 +++++++++++++++++++++++++----------------------
25
block/rbd.c | 80 ++++++++++++++++++++++++++++++++++++++++++-------------------
26
2 files changed, 90 insertions(+), 52 deletions(-)
27
24
28
--
25
--
29
2.9.3
26
2.31.1
30
27
31
28
29
diff view generated by jsdifflib
1
From: tianqing <tianqing@unitedstack.com>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
2
3
Rbd can do readv and writev directly, so wo do not need to transform
3
Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added
4
iov to buf or vice versa any more.
4
a new parameter (aio-max-batch) to IOThread and used PollParamInfo
5
structure to handle it.
5
6
6
Signed-off-by: tianqing <tianqing@unitedstack.com>
7
Since it is not a parameter of the polling mechanism, we rename the
7
Reviewed-by: Jeff Cody <jcody@redhat.com>
8
structure to a more generic IOThreadParamInfo.
8
Signed-off-by: Jeff Cody <jcody@redhat.com>
9
10
Suggested-by: Kevin Wolf <kwolf@redhat.com>
11
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
13
Message-id: 20210727145936.147032-2-sgarzare@redhat.com
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
---
15
---
10
block/rbd.c | 80 ++++++++++++++++++++++++++++++++++++++++++-------------------
16
iothread.c | 14 +++++++-------
11
1 file changed, 56 insertions(+), 24 deletions(-)
17
1 file changed, 7 insertions(+), 7 deletions(-)
12
18
13
diff --git a/block/rbd.c b/block/rbd.c
19
diff --git a/iothread.c b/iothread.c
14
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
15
--- a/block/rbd.c
21
--- a/iothread.c
16
+++ b/block/rbd.c
22
+++ b/iothread.c
17
@@ -XXX,XX +XXX,XX @@
23
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
18
#define RBD_MAX_SNAP_NAME_SIZE 128
24
typedef struct {
19
#define RBD_MAX_SNAPS 100
25
const char *name;
20
26
ptrdiff_t offset; /* field's byte offset in IOThread struct */
21
+/* The LIBRBD_SUPPORTS_IOVEC is defined in librbd.h */
27
-} PollParamInfo;
22
+#ifdef LIBRBD_SUPPORTS_IOVEC
28
+} IOThreadParamInfo;
23
+#define LIBRBD_USE_IOVEC 1
29
24
+#else
30
-static PollParamInfo poll_max_ns_info = {
25
+#define LIBRBD_USE_IOVEC 0
31
+static IOThreadParamInfo poll_max_ns_info = {
26
+#endif
32
"poll-max-ns", offsetof(IOThread, poll_max_ns),
27
+
33
};
28
typedef enum {
34
-static PollParamInfo poll_grow_info = {
29
RBD_AIO_READ,
35
+static IOThreadParamInfo poll_grow_info = {
30
RBD_AIO_WRITE,
36
"poll-grow", offsetof(IOThread, poll_grow),
31
@@ -XXX,XX +XXX,XX @@ static int qemu_rbd_set_conf(rados_t cluster, const char *conf,
37
};
32
return ret;
38
-static PollParamInfo poll_shrink_info = {
33
}
39
+static IOThreadParamInfo poll_shrink_info = {
34
40
"poll-shrink", offsetof(IOThread, poll_shrink),
35
+static void qemu_rbd_memset(RADOSCB *rcb, int64_t offs)
41
};
36
+{
42
-static PollParamInfo aio_max_batch_info = {
37
+ if (LIBRBD_USE_IOVEC) {
43
+static IOThreadParamInfo aio_max_batch_info = {
38
+ RBDAIOCB *acb = rcb->acb;
44
"aio-max-batch", offsetof(IOThread, aio_max_batch),
39
+ iov_memset(acb->qiov->iov, acb->qiov->niov, offs, 0,
45
};
40
+ acb->qiov->size - offs);
46
41
+ } else {
47
@@ -XXX,XX +XXX,XX @@ static void iothread_get_param(Object *obj, Visitor *v,
42
+ memset(rcb->buf + offs, 0, rcb->size - offs);
48
const char *name, void *opaque, Error **errp)
43
+ }
44
+}
45
+
46
static int qemu_rbd_create(const char *filename, QemuOpts *opts, Error **errp)
47
{
49
{
48
Error *local_err = NULL;
50
IOThread *iothread = IOTHREAD(obj);
49
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
51
- PollParamInfo *info = opaque;
50
}
52
+ IOThreadParamInfo *info = opaque;
51
} else {
53
int64_t *field = (void *)iothread + info->offset;
52
if (r < 0) {
54
53
- memset(rcb->buf, 0, rcb->size);
55
visit_type_int64(v, name, field, errp);
54
+ qemu_rbd_memset(rcb, 0);
56
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
55
acb->ret = r;
57
const char *name, void *opaque, Error **errp)
56
acb->error = 1;
58
{
57
} else if (r < rcb->size) {
59
IOThread *iothread = IOTHREAD(obj);
58
- memset(rcb->buf + r, 0, rcb->size - r);
60
- PollParamInfo *info = opaque;
59
+ qemu_rbd_memset(rcb, r);
61
+ IOThreadParamInfo *info = opaque;
60
if (!acb->error) {
62
int64_t *field = (void *)iothread + info->offset;
61
acb->ret = rcb->size;
63
int64_t value;
62
}
64
63
@@ -XXX,XX +XXX,XX @@ static void qemu_rbd_complete_aio(RADOSCB *rcb)
64
65
g_free(rcb);
66
67
- if (acb->cmd == RBD_AIO_READ) {
68
- qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
69
+ if (!LIBRBD_USE_IOVEC) {
70
+ if (acb->cmd == RBD_AIO_READ) {
71
+ qemu_iovec_from_buf(acb->qiov, 0, acb->bounce, acb->qiov->size);
72
+ }
73
+ qemu_vfree(acb->bounce);
74
}
75
- qemu_vfree(acb->bounce);
76
+
77
acb->common.cb(acb->common.opaque, (acb->ret > 0 ? 0 : acb->ret));
78
79
qemu_aio_unref(acb);
80
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
81
RBDAIOCB *acb;
82
RADOSCB *rcb = NULL;
83
rbd_completion_t c;
84
- char *buf;
85
int r;
86
87
BDRVRBDState *s = bs->opaque;
88
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
89
acb->cmd = cmd;
90
acb->qiov = qiov;
91
assert(!qiov || qiov->size == size);
92
- if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
93
- acb->bounce = NULL;
94
- } else {
95
- acb->bounce = qemu_try_blockalign(bs, qiov->size);
96
- if (acb->bounce == NULL) {
97
- goto failed;
98
+
99
+ rcb = g_new(RADOSCB, 1);
100
+
101
+ if (!LIBRBD_USE_IOVEC) {
102
+ if (cmd == RBD_AIO_DISCARD || cmd == RBD_AIO_FLUSH) {
103
+ acb->bounce = NULL;
104
+ } else {
105
+ acb->bounce = qemu_try_blockalign(bs, qiov->size);
106
+ if (acb->bounce == NULL) {
107
+ goto failed;
108
+ }
109
}
110
+ if (cmd == RBD_AIO_WRITE) {
111
+ qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
112
+ }
113
+ rcb->buf = acb->bounce;
114
}
115
+
116
acb->ret = 0;
117
acb->error = 0;
118
acb->s = s;
119
120
- if (cmd == RBD_AIO_WRITE) {
121
- qemu_iovec_to_buf(acb->qiov, 0, acb->bounce, qiov->size);
122
- }
123
-
124
- buf = acb->bounce;
125
-
126
- rcb = g_new(RADOSCB, 1);
127
rcb->acb = acb;
128
- rcb->buf = buf;
129
rcb->s = acb->s;
130
rcb->size = size;
131
r = rbd_aio_create_completion(rcb, (rbd_callback_t) rbd_finish_aiocb, &c);
132
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
133
134
switch (cmd) {
135
case RBD_AIO_WRITE:
136
- r = rbd_aio_write(s->image, off, size, buf, c);
137
+#ifdef LIBRBD_SUPPORTS_IOVEC
138
+ r = rbd_aio_writev(s->image, qiov->iov, qiov->niov, off, c);
139
+#else
140
+ r = rbd_aio_write(s->image, off, size, rcb->buf, c);
141
+#endif
142
break;
143
case RBD_AIO_READ:
144
- r = rbd_aio_read(s->image, off, size, buf, c);
145
+#ifdef LIBRBD_SUPPORTS_IOVEC
146
+ r = rbd_aio_readv(s->image, qiov->iov, qiov->niov, off, c);
147
+#else
148
+ r = rbd_aio_read(s->image, off, size, rcb->buf, c);
149
+#endif
150
break;
151
case RBD_AIO_DISCARD:
152
r = rbd_aio_discard_wrapper(s->image, off, size, c);
153
@@ -XXX,XX +XXX,XX @@ static BlockAIOCB *rbd_start_aio(BlockDriverState *bs,
154
if (r < 0) {
155
goto failed_completion;
156
}
157
-
158
return &acb->common;
159
160
failed_completion:
161
rbd_aio_release(c);
162
failed:
163
g_free(rcb);
164
- qemu_vfree(acb->bounce);
165
+ if (!LIBRBD_USE_IOVEC) {
166
+ qemu_vfree(acb->bounce);
167
+ }
168
+
169
qemu_aio_unref(acb);
170
return NULL;
171
}
172
--
65
--
173
2.9.3
66
2.31.1
174
67
175
68
diff view generated by jsdifflib
1
From: Peter Lieven <pl@kamp.de>
1
From: Stefano Garzarella <sgarzare@redhat.com>
2
2
3
Signed-off-by: Peter Lieven <pl@kamp.de>
3
Commit 0445409d74 ("iothread: generalize
4
Reviewed-by: Jeff Cody <jcody@redhat.com>
4
iothread_set_param/iothread_get_param") moved common code to set and
5
Message-id: 1487349541-10201-2-git-send-email-pl@kamp.de
5
get IOThread parameters in two new functions.
6
Signed-off-by: Jeff Cody <jcody@redhat.com>
6
7
These functions are called inside callbacks, so we don't need to use an
8
opaque pointer. Let's replace `void *opaque` parameter with
9
`IOThreadParamInfo *info`.
10
11
Suggested-by: Kevin Wolf <kwolf@redhat.com>
12
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Message-id: 20210727145936.147032-3-sgarzare@redhat.com
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
7
---
16
---
8
block/nfs.c | 33 +++++++++++++++------------------
17
iothread.c | 18 ++++++++++--------
9
1 file changed, 15 insertions(+), 18 deletions(-)
18
1 file changed, 10 insertions(+), 8 deletions(-)
10
19
11
diff --git a/block/nfs.c b/block/nfs.c
20
diff --git a/iothread.c b/iothread.c
12
index XXXXXXX..XXXXXXX 100644
21
index XXXXXXX..XXXXXXX 100644
13
--- a/block/nfs.c
22
--- a/iothread.c
14
+++ b/block/nfs.c
23
+++ b/iothread.c
15
@@ -XXX,XX +XXX,XX @@ nfs_co_generic_cb(int ret, struct nfs_context *nfs, void *data,
24
@@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = {
16
nfs_co_generic_bh_cb, task);
25
};
26
27
static void iothread_get_param(Object *obj, Visitor *v,
28
- const char *name, void *opaque, Error **errp)
29
+ const char *name, IOThreadParamInfo *info, Error **errp)
30
{
31
IOThread *iothread = IOTHREAD(obj);
32
- IOThreadParamInfo *info = opaque;
33
int64_t *field = (void *)iothread + info->offset;
34
35
visit_type_int64(v, name, field, errp);
17
}
36
}
18
37
19
-static int coroutine_fn nfs_co_readv(BlockDriverState *bs,
38
static bool iothread_set_param(Object *obj, Visitor *v,
20
- int64_t sector_num, int nb_sectors,
39
- const char *name, void *opaque, Error **errp)
21
- QEMUIOVector *iov)
40
+ const char *name, IOThreadParamInfo *info, Error **errp)
22
+static int coroutine_fn nfs_co_preadv(BlockDriverState *bs, uint64_t offset,
23
+ uint64_t bytes, QEMUIOVector *iov,
24
+ int flags)
25
{
41
{
26
NFSClient *client = bs->opaque;
42
IOThread *iothread = IOTHREAD(obj);
27
NFSRPC task;
43
- IOThreadParamInfo *info = opaque;
28
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nfs_co_readv(BlockDriverState *bs,
44
int64_t *field = (void *)iothread + info->offset;
29
task.iov = iov;
45
int64_t value;
30
46
31
if (nfs_pread_async(client->context, client->fh,
47
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
32
- sector_num * BDRV_SECTOR_SIZE,
48
static void iothread_get_poll_param(Object *obj, Visitor *v,
33
- nb_sectors * BDRV_SECTOR_SIZE,
49
const char *name, void *opaque, Error **errp)
34
- nfs_co_generic_cb, &task) != 0) {
50
{
35
+ offset, bytes, nfs_co_generic_cb, &task) != 0) {
51
+ IOThreadParamInfo *info = opaque;
36
return -ENOMEM;
52
53
- iothread_get_param(obj, v, name, opaque, errp);
54
+ iothread_get_param(obj, v, name, info, errp);
55
}
56
57
static void iothread_set_poll_param(Object *obj, Visitor *v,
58
const char *name, void *opaque, Error **errp)
59
{
60
IOThread *iothread = IOTHREAD(obj);
61
+ IOThreadParamInfo *info = opaque;
62
63
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
64
+ if (!iothread_set_param(obj, v, name, info, errp)) {
65
return;
37
}
66
}
38
67
39
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nfs_co_readv(BlockDriverState *bs,
68
@@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
40
return 0;
69
static void iothread_get_aio_param(Object *obj, Visitor *v,
70
const char *name, void *opaque, Error **errp)
71
{
72
+ IOThreadParamInfo *info = opaque;
73
74
- iothread_get_param(obj, v, name, opaque, errp);
75
+ iothread_get_param(obj, v, name, info, errp);
41
}
76
}
42
77
43
-static int coroutine_fn nfs_co_writev(BlockDriverState *bs,
78
static void iothread_set_aio_param(Object *obj, Visitor *v,
44
- int64_t sector_num, int nb_sectors,
79
const char *name, void *opaque, Error **errp)
45
- QEMUIOVector *iov)
46
+static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offset,
47
+ uint64_t bytes, QEMUIOVector *iov,
48
+ int flags)
49
{
80
{
50
NFSClient *client = bs->opaque;
81
IOThread *iothread = IOTHREAD(obj);
51
NFSRPC task;
82
+ IOThreadParamInfo *info = opaque;
52
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nfs_co_writev(BlockDriverState *bs,
83
53
84
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
54
nfs_co_init_task(bs, &task);
85
+ if (!iothread_set_param(obj, v, name, info, errp)) {
55
86
return;
56
- buf = g_try_malloc(nb_sectors * BDRV_SECTOR_SIZE);
57
- if (nb_sectors && buf == NULL) {
58
+ buf = g_try_malloc(bytes);
59
+ if (bytes && buf == NULL) {
60
return -ENOMEM;
61
}
87
}
62
88
63
- qemu_iovec_to_buf(iov, 0, buf, nb_sectors * BDRV_SECTOR_SIZE);
64
+ qemu_iovec_to_buf(iov, 0, buf, bytes);
65
66
if (nfs_pwrite_async(client->context, client->fh,
67
- sector_num * BDRV_SECTOR_SIZE,
68
- nb_sectors * BDRV_SECTOR_SIZE,
69
- buf, nfs_co_generic_cb, &task) != 0) {
70
+ offset, bytes, buf,
71
+ nfs_co_generic_cb, &task) != 0) {
72
g_free(buf);
73
return -ENOMEM;
74
}
75
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nfs_co_writev(BlockDriverState *bs,
76
77
g_free(buf);
78
79
- if (task.ret != nb_sectors * BDRV_SECTOR_SIZE) {
80
+ if (task.ret != bytes) {
81
return task.ret < 0 ? task.ret : -EIO;
82
}
83
84
@@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_nfs = {
85
.bdrv_create = nfs_file_create,
86
.bdrv_reopen_prepare = nfs_reopen_prepare,
87
88
- .bdrv_co_readv = nfs_co_readv,
89
- .bdrv_co_writev = nfs_co_writev,
90
+ .bdrv_co_preadv = nfs_co_preadv,
91
+ .bdrv_co_pwritev = nfs_co_pwritev,
92
.bdrv_co_flush_to_disk = nfs_co_flush,
93
94
.bdrv_detach_aio_context = nfs_detach_aio_context,
95
--
89
--
96
2.9.3
90
2.31.1
97
91
98
92
diff view generated by jsdifflib
Deleted patch
1
From: Peter Lieven <pl@kamp.de>
2
1
3
if the passed qiov contains exactly one iov we can
4
pass the buffer directly.
5
6
Signed-off-by: Peter Lieven <pl@kamp.de>
7
Reviewed-by: Jeff Cody <jcody@redhat.com>
8
Message-id: 1487349541-10201-3-git-send-email-pl@kamp.de
9
Signed-off-by: Jeff Cody <jcody@redhat.com>
10
---
11
block/nfs.c | 35 ++++++++++++++++++++++-------------
12
1 file changed, 22 insertions(+), 13 deletions(-)
13
14
diff --git a/block/nfs.c b/block/nfs.c
15
index XXXXXXX..XXXXXXX 100644
16
--- a/block/nfs.c
17
+++ b/block/nfs.c
18
@@ -XXX,XX +XXX,XX @@ static int coroutine_fn nfs_co_pwritev(BlockDriverState *bs, uint64_t offset,
19
NFSClient *client = bs->opaque;
20
NFSRPC task;
21
char *buf = NULL;
22
+ bool my_buffer = false;
23
24
nfs_co_init_task(bs, &task);
25
26
- buf = g_try_malloc(bytes);
27
- if (bytes && buf == NULL) {
28
- return -ENOMEM;
29
+ if (iov->niov != 1) {
30
+ buf = g_try_malloc(bytes);
31
+ if (bytes && buf == NULL) {
32
+ return -ENOMEM;
33
+ }
34
+ qemu_iovec_to_buf(iov, 0, buf, bytes);
35
+ my_buffer = true;
36
+ } else {
37
+ buf = iov->iov[0].iov_base;
38
}
39
40
- qemu_iovec_to_buf(iov, 0, buf, bytes);
41
-
42
if (nfs_pwrite_async(client->context, client->fh,
43
offset, bytes, buf,
44
nfs_co_generic_cb, &task) != 0) {
45
+ if (my_buffer) {
46
+ g_free(buf);
47
+ }
48
+ return -ENOMEM;
49
+ }
50
+
51
+ nfs_set_events(client);
52
+ while (!task.complete) {
53
+ qemu_coroutine_yield();
54
+ }
55
+
56
+ if (my_buffer) {
57
g_free(buf);
58
- return -ENOMEM;
59
}
60
61
- nfs_set_events(client);
62
- while (!task.complete) {
63
- qemu_coroutine_yield();
64
- }
65
-
66
- g_free(buf);
67
-
68
if (task.ret != bytes) {
69
return task.ret < 0 ? task.ret : -EIO;
70
}
71
--
72
2.9.3
73
74
diff view generated by jsdifflib