1
The following changes since commit ca61fa4b803e5d0abaf6f1ceb690f23bb78a4def:
1
The following changes since commit 8e9398e3b1a860b8c29c670c1b6c36afe8d87849:
2
2
3
Merge remote-tracking branch 'remotes/quic/tags/pull-hex-20211006' into staging (2021-10-06 12:11:14 -0700)
3
Merge tag 'pull-ppc-20220706' of https://gitlab.com/danielhb/qemu into staging (2022-07-07 06:21:05 +0530)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
https://gitlab.com/stefanha/qemu.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 1cc7eada97914f090125e588497986f6f7900514:
9
for you to fetch changes up to be6a166fde652589761cf70471bcde623e9bd72a:
10
10
11
iothread: use IOThreadParamInfo in iothread_[set|get]_param() (2021-10-07 15:29:50 +0100)
11
block/io_uring: clarify that short reads can happen (2022-07-07 09:04:15 +0100)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
----------------------------------------------------------------
16
----------------------------------------------------------------
17
17
18
Stefano Garzarella (2):
18
Dominique Martinet (1):
19
iothread: rename PollParamInfo to IOThreadParamInfo
19
io_uring: fix short read slow path
20
iothread: use IOThreadParamInfo in iothread_[set|get]_param()
21
20
22
iothread.c | 28 +++++++++++++++-------------
21
Stefan Hajnoczi (1):
23
1 file changed, 15 insertions(+), 13 deletions(-)
22
block/io_uring: clarify that short reads can happen
23
24
block/io_uring.c | 12 ++++--------
25
1 file changed, 4 insertions(+), 8 deletions(-)
24
26
25
--
27
--
26
2.31.1
28
2.36.1
27
28
29
diff view generated by jsdifflib
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
From: Dominique Martinet <dominique.martinet@atmark-techno.com>
2
2
3
Commit 0445409d74 ("iothread: generalize
3
sqeq.off here is the offset to read within the disk image, so obviously
4
iothread_set_param/iothread_get_param") moved common code to set and
4
not 'nread' (the amount we just read), but as the author meant to write
5
get IOThread parameters in two new functions.
5
its current value incremented by the amount we just read.
6
6
7
These functions are called inside callbacks, so we don't need to use an
7
Normally recent versions of linux will not issue short reads,
8
opaque pointer. Let's replace `void *opaque` parameter with
8
but it can happen so we should fix this.
9
`IOThreadParamInfo *info`.
10
9
11
Suggested-by: Kevin Wolf <kwolf@redhat.com>
10
This lead to weird image corruptions when short read happened
12
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
11
13
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
12
Fixes: 6663a0a33764 ("block/io_uring: implements interfaces for io_uring")
14
Message-id: 20210727145936.147032-3-sgarzare@redhat.com
13
Link: https://lkml.kernel.org/r/YrrFGO4A1jS0GI0G@atmark-techno.com
14
Signed-off-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
15
Message-Id: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com>
16
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
17
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
15
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
18
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
16
---
19
---
17
iothread.c | 18 ++++++++++--------
20
block/io_uring.c | 4 ++--
18
1 file changed, 10 insertions(+), 8 deletions(-)
21
1 file changed, 2 insertions(+), 2 deletions(-)
19
22
20
diff --git a/iothread.c b/iothread.c
23
diff --git a/block/io_uring.c b/block/io_uring.c
21
index XXXXXXX..XXXXXXX 100644
24
index XXXXXXX..XXXXXXX 100644
22
--- a/iothread.c
25
--- a/block/io_uring.c
23
+++ b/iothread.c
26
+++ b/block/io_uring.c
24
@@ -XXX,XX +XXX,XX @@ static IOThreadParamInfo aio_max_batch_info = {
27
@@ -XXX,XX +XXX,XX @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
25
};
28
trace_luring_resubmit_short_read(s, luringcb, nread);
26
29
27
static void iothread_get_param(Object *obj, Visitor *v,
30
/* Update read position */
28
- const char *name, void *opaque, Error **errp)
31
- luringcb->total_read = nread;
29
+ const char *name, IOThreadParamInfo *info, Error **errp)
32
+ luringcb->total_read += nread;
30
{
33
remaining = luringcb->qiov->size - luringcb->total_read;
31
IOThread *iothread = IOTHREAD(obj);
34
32
- IOThreadParamInfo *info = opaque;
35
/* Shorten qiov */
33
int64_t *field = (void *)iothread + info->offset;
36
@@ -XXX,XX +XXX,XX @@ static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
34
37
remaining);
35
visit_type_int64(v, name, field, errp);
38
36
}
39
/* Update sqe */
37
40
- luringcb->sqeq.off = nread;
38
static bool iothread_set_param(Object *obj, Visitor *v,
41
+ luringcb->sqeq.off += nread;
39
- const char *name, void *opaque, Error **errp)
42
luringcb->sqeq.addr = (__u64)(uintptr_t)luringcb->resubmit_qiov.iov;
40
+ const char *name, IOThreadParamInfo *info, Error **errp)
43
luringcb->sqeq.len = luringcb->resubmit_qiov.niov;
41
{
42
IOThread *iothread = IOTHREAD(obj);
43
- IOThreadParamInfo *info = opaque;
44
int64_t *field = (void *)iothread + info->offset;
45
int64_t value;
46
47
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
48
static void iothread_get_poll_param(Object *obj, Visitor *v,
49
const char *name, void *opaque, Error **errp)
50
{
51
+ IOThreadParamInfo *info = opaque;
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;
66
}
67
68
@@ -XXX,XX +XXX,XX @@ static void iothread_set_poll_param(Object *obj, Visitor *v,
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);
76
}
77
78
static void iothread_set_aio_param(Object *obj, Visitor *v,
79
const char *name, void *opaque, Error **errp)
80
{
81
IOThread *iothread = IOTHREAD(obj);
82
+ IOThreadParamInfo *info = opaque;
83
84
- if (!iothread_set_param(obj, v, name, opaque, errp)) {
85
+ if (!iothread_set_param(obj, v, name, info, errp)) {
86
return;
87
}
88
44
89
--
45
--
90
2.31.1
46
2.36.1
91
92
diff view generated by jsdifflib
1
From: Stefano Garzarella <sgarzare@redhat.com>
1
Jens Axboe has confirmed that short reads are rare but can happen:
2
https://lore.kernel.org/io-uring/YsU%2FCGkl9ZXUI+Tj@stefanha-x1.localdomain/T/#m729963dc577d709b709c191922e98ec79d7eef54
2
3
3
Commit 1793ad0247 ("iothread: add aio-max-batch parameter") added
4
The luring_resubmit_short_read() comment claimed they were only due to a
4
a new parameter (aio-max-batch) to IOThread and used PollParamInfo
5
specific io_uring bug that was fixed in Linux commit 9d93a3f5a0c
5
structure to handle it.
6
("io_uring: punt short reads to async context"), which is wrong.
7
Dominique Martinet found that a btrfs bug also causes short reads. There
8
may be more kernel code paths that result in short reads.
6
9
7
Since it is not a parameter of the polling mechanism, we rename the
10
Let's consider short reads fair game.
8
structure to a more generic IOThreadParamInfo.
9
11
10
Suggested-by: Kevin Wolf <kwolf@redhat.com>
12
Cc: Dominique Martinet <dominique.martinet@atmark-techno.com>
11
Signed-off-by: Stefano Garzarella <sgarzare@redhat.com>
13
Based-on: <20220630010137.2518851-1-dominique.martinet@atmark-techno.com>
12
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Message-id: 20210727145936.147032-2-sgarzare@redhat.com
15
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
16
Message-id: 20220706080341.1206476-1-stefanha@redhat.com
14
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
17
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
15
---
18
---
16
iothread.c | 14 +++++++-------
19
block/io_uring.c | 8 ++------
17
1 file changed, 7 insertions(+), 7 deletions(-)
20
1 file changed, 2 insertions(+), 6 deletions(-)
18
21
19
diff --git a/iothread.c b/iothread.c
22
diff --git a/block/io_uring.c b/block/io_uring.c
20
index XXXXXXX..XXXXXXX 100644
23
index XXXXXXX..XXXXXXX 100644
21
--- a/iothread.c
24
--- a/block/io_uring.c
22
+++ b/iothread.c
25
+++ b/block/io_uring.c
23
@@ -XXX,XX +XXX,XX @@ static void iothread_complete(UserCreatable *obj, Error **errp)
26
@@ -XXX,XX +XXX,XX @@ static void luring_resubmit(LuringState *s, LuringAIOCB *luringcb)
24
typedef struct {
27
/**
25
const char *name;
28
* luring_resubmit_short_read:
26
ptrdiff_t offset; /* field's byte offset in IOThread struct */
29
*
27
-} PollParamInfo;
30
- * Before Linux commit 9d93a3f5a0c ("io_uring: punt short reads to async
28
+} IOThreadParamInfo;
31
- * context") a buffered I/O request with the start of the file range in the
29
32
- * page cache could result in a short read. Applications need to resubmit the
30
-static PollParamInfo poll_max_ns_info = {
33
- * remaining read request.
31
+static IOThreadParamInfo poll_max_ns_info = {
34
- *
32
"poll-max-ns", offsetof(IOThread, poll_max_ns),
35
- * This is a slow path but recent kernels never take it.
33
};
36
+ * Short reads are rare but may occur. The remaining read request needs to be
34
-static PollParamInfo poll_grow_info = {
37
+ * resubmitted.
35
+static IOThreadParamInfo poll_grow_info = {
38
*/
36
"poll-grow", offsetof(IOThread, poll_grow),
39
static void luring_resubmit_short_read(LuringState *s, LuringAIOCB *luringcb,
37
};
40
int nread)
38
-static PollParamInfo poll_shrink_info = {
39
+static IOThreadParamInfo poll_shrink_info = {
40
"poll-shrink", offsetof(IOThread, poll_shrink),
41
};
42
-static PollParamInfo aio_max_batch_info = {
43
+static IOThreadParamInfo aio_max_batch_info = {
44
"aio-max-batch", offsetof(IOThread, aio_max_batch),
45
};
46
47
@@ -XXX,XX +XXX,XX @@ static void iothread_get_param(Object *obj, Visitor *v,
48
const char *name, void *opaque, Error **errp)
49
{
50
IOThread *iothread = IOTHREAD(obj);
51
- PollParamInfo *info = opaque;
52
+ IOThreadParamInfo *info = opaque;
53
int64_t *field = (void *)iothread + info->offset;
54
55
visit_type_int64(v, name, field, errp);
56
@@ -XXX,XX +XXX,XX @@ static bool iothread_set_param(Object *obj, Visitor *v,
57
const char *name, void *opaque, Error **errp)
58
{
59
IOThread *iothread = IOTHREAD(obj);
60
- PollParamInfo *info = opaque;
61
+ IOThreadParamInfo *info = opaque;
62
int64_t *field = (void *)iothread + info->offset;
63
int64_t value;
64
65
--
41
--
66
2.31.1
42
2.36.1
67
68
diff view generated by jsdifflib