1 | The following changes since commit fa54abb8c298f892639ffc4bc2f61448ac3be4a1: | 1 | The following changes since commit 00928a421d47f49691cace1207481b7aad31b1f1: |
---|---|---|---|
2 | 2 | ||
3 | Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1 (2017-04-20 18:33:33 +0100) | 3 | Merge remote-tracking branch 'remotes/pmaydell/tags/pull-target-arm-20180626' into staging (2018-06-26 18:23:49 +0100) |
4 | 4 | ||
5 | are available in the git repository at: | 5 | are available in the Git repository at: |
6 | 6 | ||
7 | git://github.com/stefanha/qemu.git tags/block-pull-request | 7 | git://github.com/stefanha/qemu.git tags/block-pull-request |
8 | 8 | ||
9 | for you to fetch changes up to 3ccc0a0163b932fe980dce8d26db4bf98b1900e9: | 9 | for you to fetch changes up to ed6e2161715c527330f936d44af4c547f25f687e: |
10 | 10 | ||
11 | MAINTAINERS: update my email address (2017-04-21 10:36:12 +0100) | 11 | linux-aio: properly bubble up errors from initialization (2018-06-27 13:06:34 +0100) |
12 | |||
13 | ---------------------------------------------------------------- | ||
14 | Pull request | ||
15 | |||
16 | * Gracefully handle Linux AIO init failure | ||
12 | 17 | ||
13 | ---------------------------------------------------------------- | 18 | ---------------------------------------------------------------- |
14 | 19 | ||
15 | ---------------------------------------------------------------- | 20 | Nishanth Aravamudan (1): |
21 | linux-aio: properly bubble up errors from initialization | ||
16 | 22 | ||
17 | Changlong Xie (1): | 23 | Stefan Hajnoczi (1): |
18 | MAINTAINERS: update Wen's email address | 24 | compiler: add a sizeof_field() macro |
19 | 25 | ||
20 | Lidong Chen (1): | 26 | include/block/aio.h | 3 +++ |
21 | migration/block: use blk_pwrite_zeroes for each zero cluster | 27 | include/block/raw-aio.h | 2 +- |
22 | 28 | include/hw/xen/io/ring.h | 2 +- | |
23 | Stefan Hajnoczi (3): | 29 | include/qemu/compiler.h | 2 ++ |
24 | qemu-options: explain disk I/O throttling options | 30 | accel/tcg/translate-all.c | 2 +- |
25 | throttle: do not use invalid config in test | 31 | block/file-posix.c | 33 ++++++++++++++++++++++++++++----- |
26 | throttle: make throttle_config(throttle_get_config()) symmetric | 32 | block/linux-aio.c | 12 +++++++++--- |
27 | 33 | hw/display/xenfb.c | 4 ++-- | |
28 | Zhang Chen (1): | 34 | hw/net/rocker/rocker_of_dpa.c | 2 +- |
29 | MAINTAINERS: update my email address | 35 | hw/net/virtio-net.c | 2 +- |
30 | 36 | stubs/linux-aio.c | 2 +- | |
31 | MAINTAINERS | 4 ++-- | 37 | target/i386/kvm.c | 2 +- |
32 | migration/block.c | 35 +++++++++++++++++++++++++++++++++-- | 38 | target/ppc/arch_dump.c | 10 +++++----- |
33 | tests/test-throttle.c | 8 ++++---- | 39 | target/s390x/arch_dump.c | 20 ++++++++++---------- |
34 | util/throttle.c | 14 ++++++++++++++ | 40 | util/async.c | 14 +++++++++++--- |
35 | qemu-options.hx | 24 ++++++++++++++++++++++++ | 41 | 15 files changed, 77 insertions(+), 35 deletions(-) |
36 | 5 files changed, 77 insertions(+), 8 deletions(-) | ||
37 | 42 | ||
38 | -- | 43 | -- |
39 | 2.9.3 | 44 | 2.17.1 |
40 | 45 | ||
41 | 46 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | The disk I/O throttling options have been listed for a long time but | ||
2 | never explained on the QEMU man page. | ||
3 | 1 | ||
4 | Suggested-by: Nini Gu <ngu@redhat.com> | ||
5 | Cc: Alberto Garcia <berto@igalia.com> | ||
6 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
7 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
8 | Reviewed-by: Greg Kurz <groug@kaod.org> | ||
9 | Message-id: 20170301115026.22621-2-stefanha@redhat.com | ||
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
11 | --- | ||
12 | qemu-options.hx | 24 ++++++++++++++++++++++++ | ||
13 | 1 file changed, 24 insertions(+) | ||
14 | |||
15 | diff --git a/qemu-options.hx b/qemu-options.hx | ||
16 | index XXXXXXX..XXXXXXX 100644 | ||
17 | --- a/qemu-options.hx | ||
18 | +++ b/qemu-options.hx | ||
19 | @@ -XXX,XX +XXX,XX @@ file sectors into the image file. | ||
20 | conversion of plain zero writes by the OS to driver specific optimized | ||
21 | zero write commands. You may even choose "unmap" if @var{discard} is set | ||
22 | to "unmap" to allow a zero write to be converted to an UNMAP operation. | ||
23 | +@item bps=@var{b},bps_rd=@var{r},bps_wr=@var{w} | ||
24 | +Specify bandwidth throttling limits in bytes per second, either for all request | ||
25 | +types or for reads or writes only. Small values can lead to timeouts or hangs | ||
26 | +inside the guest. A safe minimum for disks is 2 MB/s. | ||
27 | +@item bps_max=@var{bm},bps_rd_max=@var{rm},bps_wr_max=@var{wm} | ||
28 | +Specify bursts in bytes per second, either for all request types or for reads | ||
29 | +or writes only. Bursts allow the guest I/O to spike above the limit | ||
30 | +temporarily. | ||
31 | +@item iops=@var{i},iops_rd=@var{r},iops_wr=@var{w} | ||
32 | +Specify request rate limits in requests per second, either for all request | ||
33 | +types or for reads or writes only. | ||
34 | +@item iops_max=@var{bm},iops_rd_max=@var{rm},iops_wr_max=@var{wm} | ||
35 | +Specify bursts in requests per second, either for all request types or for reads | ||
36 | +or writes only. Bursts allow the guest I/O to spike above the limit | ||
37 | +temporarily. | ||
38 | +@item iops_size=@var{is} | ||
39 | +Let every @var{is} bytes of a request count as a new request for iops | ||
40 | +throttling purposes. Use this option to prevent guests from circumventing iops | ||
41 | +limits by sending fewer but larger requests. | ||
42 | +@item group=@var{g} | ||
43 | +Join a throttling quota group with given name @var{g}. All drives that are | ||
44 | +members of the same group are accounted for together. Use this option to | ||
45 | +prevent guests from circumventing throttling limits by using many small disks | ||
46 | +instead of a single larger disk. | ||
47 | @end table | ||
48 | |||
49 | By default, the @option{cache=writeback} mode is used. It will report data | ||
50 | -- | ||
51 | 2.9.3 | ||
52 | |||
53 | diff view generated by jsdifflib |
1 | The (burst) max parameter cannot be smaller than the avg parameter. | 1 | Determining the size of a field is useful when you don't have a struct |
---|---|---|---|
2 | There is a test case that uses avg = 56, max = 1 and gets away with it | 2 | variable handy. Open-coding this is ugly. |
3 | because no input validation is performed by the test case. | ||
4 | 3 | ||
5 | This patch switches to valid test input parameters. | 4 | This patch adds the sizeof_field() macro, which is similar to |
5 | typeof_field(). Existing instances are updated to use the macro. | ||
6 | 6 | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
8 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 8 | Reviewed-by: John Snow <jsnow@redhat.com> |
9 | Message-id: 20170301115026.22621-3-stefanha@redhat.com | 9 | Message-id: 20180614164431.29305-1-stefanha@redhat.com |
10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 10 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
11 | --- | 11 | --- |
12 | tests/test-throttle.c | 8 ++++---- | 12 | include/hw/xen/io/ring.h | 2 +- |
13 | 1 file changed, 4 insertions(+), 4 deletions(-) | 13 | include/qemu/compiler.h | 2 ++ |
14 | accel/tcg/translate-all.c | 2 +- | ||
15 | hw/display/xenfb.c | 4 ++-- | ||
16 | hw/net/rocker/rocker_of_dpa.c | 2 +- | ||
17 | hw/net/virtio-net.c | 2 +- | ||
18 | target/i386/kvm.c | 2 +- | ||
19 | target/ppc/arch_dump.c | 10 +++++----- | ||
20 | target/s390x/arch_dump.c | 20 ++++++++++---------- | ||
21 | 9 files changed, 24 insertions(+), 22 deletions(-) | ||
14 | 22 | ||
15 | diff --git a/tests/test-throttle.c b/tests/test-throttle.c | 23 | diff --git a/include/hw/xen/io/ring.h b/include/hw/xen/io/ring.h |
16 | index XXXXXXX..XXXXXXX 100644 | 24 | index XXXXXXX..XXXXXXX 100644 |
17 | --- a/tests/test-throttle.c | 25 | --- a/include/hw/xen/io/ring.h |
18 | +++ b/tests/test-throttle.c | 26 | +++ b/include/hw/xen/io/ring.h |
19 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | 27 | @@ -XXX,XX +XXX,XX @@ typedef unsigned int RING_IDX; |
20 | orig_cfg.buckets[THROTTLE_OPS_READ].avg = 69; | 28 | */ |
21 | orig_cfg.buckets[THROTTLE_OPS_WRITE].avg = 23; | 29 | #define __CONST_RING_SIZE(_s, _sz) \ |
22 | 30 | (__RD32(((_sz) - offsetof(struct _s##_sring, ring)) / \ | |
23 | - orig_cfg.buckets[THROTTLE_BPS_TOTAL].max = 0; /* should be corrected */ | 31 | - sizeof(((struct _s##_sring *)0)->ring[0]))) |
24 | - orig_cfg.buckets[THROTTLE_BPS_READ].max = 1; /* should not be corrected */ | 32 | + sizeof_field(struct _s##_sring, ring[0]))) |
25 | + orig_cfg.buckets[THROTTLE_BPS_TOTAL].max = 0; /* should be corrected */ | 33 | /* |
26 | + orig_cfg.buckets[THROTTLE_BPS_READ].max = 56; /* should not be corrected */ | 34 | * The same for passing in an actual pointer instead of a name tag. |
27 | orig_cfg.buckets[THROTTLE_BPS_WRITE].max = 120; | 35 | */ |
28 | 36 | diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h | |
29 | orig_cfg.buckets[THROTTLE_OPS_TOTAL].max = 150; | 37 | index XXXXXXX..XXXXXXX 100644 |
30 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | 38 | --- a/include/qemu/compiler.h |
31 | g_assert(final_cfg.buckets[THROTTLE_OPS_READ].avg == 69); | 39 | +++ b/include/qemu/compiler.h |
32 | g_assert(final_cfg.buckets[THROTTLE_OPS_WRITE].avg == 23); | 40 | @@ -XXX,XX +XXX,XX @@ |
33 | 41 | (type *) ((char *) __mptr - offsetof(type, member));}) | |
34 | - g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max == 15.3);/* fixed */ | 42 | #endif |
35 | - g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max == 1); /* not fixed */ | 43 | |
36 | + g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max == 15.3); /* fixed */ | 44 | +#define sizeof_field(type, field) sizeof(((type *)0)->field) |
37 | + g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max == 56); /* not fixed */ | 45 | + |
38 | g_assert(final_cfg.buckets[THROTTLE_BPS_WRITE].max == 120); | 46 | /* Convert from a base type to a parent type, with compile time checking. */ |
39 | 47 | #ifdef __GNUC__ | |
40 | g_assert(final_cfg.buckets[THROTTLE_OPS_TOTAL].max == 150); | 48 | #define DO_UPCAST(type, field, dev) ( __extension__ ( { \ |
49 | diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c | ||
50 | index XXXXXXX..XXXXXXX 100644 | ||
51 | --- a/accel/tcg/translate-all.c | ||
52 | +++ b/accel/tcg/translate-all.c | ||
53 | @@ -XXX,XX +XXX,XX @@ struct page_collection { | ||
54 | |||
55 | /* Make sure all possible CPU event bits fit in tb->trace_vcpu_dstate */ | ||
56 | QEMU_BUILD_BUG_ON(CPU_TRACE_DSTATE_MAX_EVENTS > | ||
57 | - sizeof(((TranslationBlock *)0)->trace_vcpu_dstate) | ||
58 | + sizeof_field(TranslationBlock, trace_vcpu_dstate) | ||
59 | * BITS_PER_BYTE); | ||
60 | |||
61 | /* | ||
62 | diff --git a/hw/display/xenfb.c b/hw/display/xenfb.c | ||
63 | index XXXXXXX..XXXXXXX 100644 | ||
64 | --- a/hw/display/xenfb.c | ||
65 | +++ b/hw/display/xenfb.c | ||
66 | @@ -XXX,XX +XXX,XX @@ static int xenfb_configure_fb(struct XenFB *xenfb, size_t fb_len_lim, | ||
67 | int width, int height, int depth, | ||
68 | size_t fb_len, int offset, int row_stride) | ||
69 | { | ||
70 | - size_t mfn_sz = sizeof(*((struct xenfb_page *)0)->pd); | ||
71 | - size_t pd_len = sizeof(((struct xenfb_page *)0)->pd) / mfn_sz; | ||
72 | + size_t mfn_sz = sizeof_field(struct xenfb_page, pd[0]); | ||
73 | + size_t pd_len = sizeof_field(struct xenfb_page, pd) / mfn_sz; | ||
74 | size_t fb_pages = pd_len * XC_PAGE_SIZE / mfn_sz; | ||
75 | size_t fb_len_max = fb_pages * XC_PAGE_SIZE; | ||
76 | int max_width, max_height; | ||
77 | diff --git a/hw/net/rocker/rocker_of_dpa.c b/hw/net/rocker/rocker_of_dpa.c | ||
78 | index XXXXXXX..XXXXXXX 100644 | ||
79 | --- a/hw/net/rocker/rocker_of_dpa.c | ||
80 | +++ b/hw/net/rocker/rocker_of_dpa.c | ||
81 | @@ -XXX,XX +XXX,XX @@ typedef struct of_dpa_flow_key { | ||
82 | |||
83 | /* Width of key which includes field 'f' in u64s, rounded up */ | ||
84 | #define FLOW_KEY_WIDTH(f) \ | ||
85 | - DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof(((OfDpaFlowKey *)0)->f), \ | ||
86 | + DIV_ROUND_UP(offsetof(OfDpaFlowKey, f) + sizeof_field(OfDpaFlowKey, f), \ | ||
87 | sizeof(uint64_t)) | ||
88 | |||
89 | typedef struct of_dpa_flow_action { | ||
90 | diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c | ||
91 | index XXXXXXX..XXXXXXX 100644 | ||
92 | --- a/hw/net/virtio-net.c | ||
93 | +++ b/hw/net/virtio-net.c | ||
94 | @@ -XXX,XX +XXX,XX @@ | ||
95 | * 'container'. | ||
96 | */ | ||
97 | #define endof(container, field) \ | ||
98 | - (offsetof(container, field) + sizeof(((container *)0)->field)) | ||
99 | + (offsetof(container, field) + sizeof_field(container, field)) | ||
100 | |||
101 | typedef struct VirtIOFeature { | ||
102 | uint64_t flags; | ||
103 | diff --git a/target/i386/kvm.c b/target/i386/kvm.c | ||
104 | index XXXXXXX..XXXXXXX 100644 | ||
105 | --- a/target/i386/kvm.c | ||
106 | +++ b/target/i386/kvm.c | ||
107 | @@ -XXX,XX +XXX,XX @@ static int kvm_put_fpu(X86CPU *cpu) | ||
108 | #define XSAVE_PKRU 672 | ||
109 | |||
110 | #define XSAVE_BYTE_OFFSET(word_offset) \ | ||
111 | - ((word_offset) * sizeof(((struct kvm_xsave *)0)->region[0])) | ||
112 | + ((word_offset) * sizeof_field(struct kvm_xsave, region[0])) | ||
113 | |||
114 | #define ASSERT_OFFSET(word_offset, field) \ | ||
115 | QEMU_BUILD_BUG_ON(XSAVE_BYTE_OFFSET(word_offset) != \ | ||
116 | diff --git a/target/ppc/arch_dump.c b/target/ppc/arch_dump.c | ||
117 | index XXXXXXX..XXXXXXX 100644 | ||
118 | --- a/target/ppc/arch_dump.c | ||
119 | +++ b/target/ppc/arch_dump.c | ||
120 | @@ -XXX,XX +XXX,XX @@ static const struct NoteFuncDescStruct { | ||
121 | int contents_size; | ||
122 | void (*note_contents_func)(NoteFuncArg *arg, PowerPCCPU *cpu); | ||
123 | } note_func[] = { | ||
124 | - {sizeof(((Note *)0)->contents.prstatus), ppc_write_elf_prstatus}, | ||
125 | - {sizeof(((Note *)0)->contents.fpregset), ppc_write_elf_fpregset}, | ||
126 | - {sizeof(((Note *)0)->contents.vmxregset), ppc_write_elf_vmxregset}, | ||
127 | - {sizeof(((Note *)0)->contents.vsxregset), ppc_write_elf_vsxregset}, | ||
128 | - {sizeof(((Note *)0)->contents.speregset), ppc_write_elf_speregset}, | ||
129 | + {sizeof_field(Note, contents.prstatus), ppc_write_elf_prstatus}, | ||
130 | + {sizeof_field(Note, contents.fpregset), ppc_write_elf_fpregset}, | ||
131 | + {sizeof_field(Note, contents.vmxregset), ppc_write_elf_vmxregset}, | ||
132 | + {sizeof_field(Note, contents.vsxregset), ppc_write_elf_vsxregset}, | ||
133 | + {sizeof_field(Note, contents.speregset), ppc_write_elf_speregset}, | ||
134 | { 0, NULL} | ||
135 | }; | ||
136 | |||
137 | diff --git a/target/s390x/arch_dump.c b/target/s390x/arch_dump.c | ||
138 | index XXXXXXX..XXXXXXX 100644 | ||
139 | --- a/target/s390x/arch_dump.c | ||
140 | +++ b/target/s390x/arch_dump.c | ||
141 | @@ -XXX,XX +XXX,XX @@ typedef struct NoteFuncDescStruct { | ||
142 | } NoteFuncDesc; | ||
143 | |||
144 | static const NoteFuncDesc note_core[] = { | ||
145 | - {sizeof(((Note *)0)->contents.prstatus), s390x_write_elf64_prstatus}, | ||
146 | - {sizeof(((Note *)0)->contents.fpregset), s390x_write_elf64_fpregset}, | ||
147 | + {sizeof_field(Note, contents.prstatus), s390x_write_elf64_prstatus}, | ||
148 | + {sizeof_field(Note, contents.fpregset), s390x_write_elf64_fpregset}, | ||
149 | { 0, NULL} | ||
150 | }; | ||
151 | |||
152 | static const NoteFuncDesc note_linux[] = { | ||
153 | - {sizeof(((Note *)0)->contents.prefix), s390x_write_elf64_prefix}, | ||
154 | - {sizeof(((Note *)0)->contents.ctrs), s390x_write_elf64_ctrs}, | ||
155 | - {sizeof(((Note *)0)->contents.timer), s390x_write_elf64_timer}, | ||
156 | - {sizeof(((Note *)0)->contents.todcmp), s390x_write_elf64_todcmp}, | ||
157 | - {sizeof(((Note *)0)->contents.todpreg), s390x_write_elf64_todpreg}, | ||
158 | - {sizeof(((Note *)0)->contents.vregslo), s390x_write_elf64_vregslo}, | ||
159 | - {sizeof(((Note *)0)->contents.vregshi), s390x_write_elf64_vregshi}, | ||
160 | - {sizeof(((Note *)0)->contents.gscb), s390x_write_elf64_gscb}, | ||
161 | + {sizeof_field(Note, contents.prefix), s390x_write_elf64_prefix}, | ||
162 | + {sizeof_field(Note, contents.ctrs), s390x_write_elf64_ctrs}, | ||
163 | + {sizeof_field(Note, contents.timer), s390x_write_elf64_timer}, | ||
164 | + {sizeof_field(Note, contents.todcmp), s390x_write_elf64_todcmp}, | ||
165 | + {sizeof_field(Note, contents.todpreg), s390x_write_elf64_todpreg}, | ||
166 | + {sizeof_field(Note, contents.vregslo), s390x_write_elf64_vregslo}, | ||
167 | + {sizeof_field(Note, contents.vregshi), s390x_write_elf64_vregshi}, | ||
168 | + {sizeof_field(Note, contents.gscb), s390x_write_elf64_gscb}, | ||
169 | { 0, NULL} | ||
170 | }; | ||
171 | |||
41 | -- | 172 | -- |
42 | 2.9.3 | 173 | 2.17.1 |
43 | 174 | ||
44 | 175 | diff view generated by jsdifflib |
1 | Throttling has a weird property that throttle_get_config() does not | 1 | From: Nishanth Aravamudan <naravamudan@digitalocean.com> |
---|---|---|---|
2 | always return the same throttling settings that were given with | 2 | |
3 | throttle_config(). In other words, the set and get functions aren't | 3 | laio_init() can fail for a couple of reasons, which will lead to a NULL |
4 | symmetric. | 4 | pointer dereference in laio_attach_aio_context(). |
5 | 5 | ||
6 | If .max is 0 then the throttling code assigns a default value of .avg / | 6 | To solve this, add a aio_setup_linux_aio() function which is called |
7 | 10 in throttle_config(). This is an implementation detail of the | 7 | early in raw_open_common. If this fails, propagate the error up. The |
8 | throttling algorithm. When throttle_get_config() is called the .max | 8 | signature of aio_get_linux_aio() was not modified, because it seems |
9 | value returned should still be 0. | 9 | preferable to return the actual errno from the possible failing |
10 | 10 | initialization calls. | |
11 | Users are exposed to this quirk via "info block" or "query-block" | 11 | |
12 | monitor commands. This has caused confusion because it looks like a bug | 12 | Additionally, when the AioContext changes, we need to associate a |
13 | when an unexpected value is reported. | 13 | LinuxAioState with the new AioContext. Use the bdrv_attach_aio_context |
14 | 14 | callback and call the new aio_setup_linux_aio(), which will allocate a | |
15 | This patch hides the .max value adjustment in throttle_get_config() and | 15 | new AioContext if needed, and return errors on failures. If it fails for |
16 | updates test-throttle.c appropriately. | 16 | any reason, fallback to threaded AIO with an error message, as the |
17 | 17 | device is already in-use by the guest. | |
18 | Reported-by: Nini Gu <ngu@redhat.com> | 18 | |
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 19 | Add an assert that aio_get_linux_aio() cannot return NULL. |
20 | Reviewed-by: Alberto Garcia <berto@igalia.com> | 20 | |
21 | Message-id: 20170301115026.22621-4-stefanha@redhat.com | 21 | Signed-off-by: Nishanth Aravamudan <naravamudan@digitalocean.com> |
22 | Message-id: 20180622193700.6523-1-naravamudan@digitalocean.com | ||
22 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 23 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
23 | --- | 24 | --- |
24 | tests/test-throttle.c | 8 ++++---- | 25 | include/block/aio.h | 3 +++ |
25 | util/throttle.c | 14 ++++++++++++++ | 26 | include/block/raw-aio.h | 2 +- |
26 | 2 files changed, 18 insertions(+), 4 deletions(-) | 27 | block/file-posix.c | 33 ++++++++++++++++++++++++++++----- |
27 | 28 | block/linux-aio.c | 12 +++++++++--- | |
28 | diff --git a/tests/test-throttle.c b/tests/test-throttle.c | 29 | stubs/linux-aio.c | 2 +- |
29 | index XXXXXXX..XXXXXXX 100644 | 30 | util/async.c | 14 +++++++++++--- |
30 | --- a/tests/test-throttle.c | 31 | 6 files changed, 53 insertions(+), 13 deletions(-) |
31 | +++ b/tests/test-throttle.c | 32 | |
32 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | 33 | diff --git a/include/block/aio.h b/include/block/aio.h |
33 | orig_cfg.buckets[THROTTLE_OPS_READ].avg = 69; | 34 | index XXXXXXX..XXXXXXX 100644 |
34 | orig_cfg.buckets[THROTTLE_OPS_WRITE].avg = 23; | 35 | --- a/include/block/aio.h |
35 | 36 | +++ b/include/block/aio.h | |
36 | - orig_cfg.buckets[THROTTLE_BPS_TOTAL].max = 0; /* should be corrected */ | 37 | @@ -XXX,XX +XXX,XX @@ GSource *aio_get_g_source(AioContext *ctx); |
37 | - orig_cfg.buckets[THROTTLE_BPS_READ].max = 56; /* should not be corrected */ | 38 | /* Return the ThreadPool bound to this AioContext */ |
38 | + orig_cfg.buckets[THROTTLE_BPS_TOTAL].max = 0; | 39 | struct ThreadPool *aio_get_thread_pool(AioContext *ctx); |
39 | + orig_cfg.buckets[THROTTLE_BPS_READ].max = 56; | 40 | |
40 | orig_cfg.buckets[THROTTLE_BPS_WRITE].max = 120; | 41 | +/* Setup the LinuxAioState bound to this AioContext */ |
41 | 42 | +struct LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp); | |
42 | orig_cfg.buckets[THROTTLE_OPS_TOTAL].max = 150; | 43 | + |
43 | @@ -XXX,XX +XXX,XX @@ static void test_config_functions(void) | 44 | /* Return the LinuxAioState bound to this AioContext */ |
44 | g_assert(final_cfg.buckets[THROTTLE_OPS_READ].avg == 69); | 45 | struct LinuxAioState *aio_get_linux_aio(AioContext *ctx); |
45 | g_assert(final_cfg.buckets[THROTTLE_OPS_WRITE].avg == 23); | 46 | |
46 | 47 | diff --git a/include/block/raw-aio.h b/include/block/raw-aio.h | |
47 | - g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max == 15.3); /* fixed */ | 48 | index XXXXXXX..XXXXXXX 100644 |
48 | - g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max == 56); /* not fixed */ | 49 | --- a/include/block/raw-aio.h |
49 | + g_assert(final_cfg.buckets[THROTTLE_BPS_TOTAL].max == 0); | 50 | +++ b/include/block/raw-aio.h |
50 | + g_assert(final_cfg.buckets[THROTTLE_BPS_READ].max == 56); | 51 | @@ -XXX,XX +XXX,XX @@ |
51 | g_assert(final_cfg.buckets[THROTTLE_BPS_WRITE].max == 120); | 52 | /* linux-aio.c - Linux native implementation */ |
52 | 53 | #ifdef CONFIG_LINUX_AIO | |
53 | g_assert(final_cfg.buckets[THROTTLE_OPS_TOTAL].max == 150); | 54 | typedef struct LinuxAioState LinuxAioState; |
54 | diff --git a/util/throttle.c b/util/throttle.c | 55 | -LinuxAioState *laio_init(void); |
55 | index XXXXXXX..XXXXXXX 100644 | 56 | +LinuxAioState *laio_init(Error **errp); |
56 | --- a/util/throttle.c | 57 | void laio_cleanup(LinuxAioState *s); |
57 | +++ b/util/throttle.c | 58 | int coroutine_fn laio_co_submit(BlockDriverState *bs, LinuxAioState *s, int fd, |
58 | @@ -XXX,XX +XXX,XX @@ static void throttle_fix_bucket(LeakyBucket *bkt) | 59 | uint64_t offset, QEMUIOVector *qiov, int type); |
59 | } | 60 | diff --git a/block/file-posix.c b/block/file-posix.c |
60 | } | 61 | index XXXXXXX..XXXXXXX 100644 |
61 | 62 | --- a/block/file-posix.c | |
62 | +/* undo internal bucket parameter changes (see throttle_fix_bucket()) */ | 63 | +++ b/block/file-posix.c |
63 | +static void throttle_unfix_bucket(LeakyBucket *bkt) | 64 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, |
65 | |||
66 | #ifdef CONFIG_LINUX_AIO | ||
67 | /* Currently Linux does AIO only for files opened with O_DIRECT */ | ||
68 | - if (s->use_linux_aio && !(s->open_flags & O_DIRECT)) { | ||
69 | - error_setg(errp, "aio=native was specified, but it requires " | ||
70 | - "cache.direct=on, which was not specified."); | ||
71 | - ret = -EINVAL; | ||
72 | - goto fail; | ||
73 | + if (s->use_linux_aio) { | ||
74 | + if (!(s->open_flags & O_DIRECT)) { | ||
75 | + error_setg(errp, "aio=native was specified, but it requires " | ||
76 | + "cache.direct=on, which was not specified."); | ||
77 | + ret = -EINVAL; | ||
78 | + goto fail; | ||
79 | + } | ||
80 | + if (!aio_setup_linux_aio(bdrv_get_aio_context(bs), errp)) { | ||
81 | + error_prepend(errp, "Unable to use native AIO: "); | ||
82 | + goto fail; | ||
83 | + } | ||
84 | } | ||
85 | #else | ||
86 | if (s->use_linux_aio) { | ||
87 | @@ -XXX,XX +XXX,XX @@ static BlockAIOCB *raw_aio_flush(BlockDriverState *bs, | ||
88 | return paio_submit(bs, s->fd, 0, NULL, 0, cb, opaque, QEMU_AIO_FLUSH); | ||
89 | } | ||
90 | |||
91 | +static void raw_aio_attach_aio_context(BlockDriverState *bs, | ||
92 | + AioContext *new_context) | ||
64 | +{ | 93 | +{ |
65 | + if (bkt->max < bkt->avg) { | 94 | +#ifdef CONFIG_LINUX_AIO |
66 | + bkt->max = 0; | 95 | + BDRVRawState *s = bs->opaque; |
96 | + if (s->use_linux_aio) { | ||
97 | + Error *local_err; | ||
98 | + if (!aio_setup_linux_aio(new_context, &local_err)) { | ||
99 | + error_reportf_err(local_err, "Unable to use native AIO, " | ||
100 | + "falling back to thread pool: "); | ||
101 | + s->use_linux_aio = false; | ||
102 | + } | ||
67 | + } | 103 | + } |
104 | +#endif | ||
68 | +} | 105 | +} |
69 | + | 106 | + |
70 | /* take care of canceling a timer */ | 107 | static void raw_close(BlockDriverState *bs) |
71 | static void throttle_cancel_timer(QEMUTimer *timer) | 108 | { |
72 | { | 109 | BDRVRawState *s = bs->opaque; |
73 | @@ -XXX,XX +XXX,XX @@ void throttle_config(ThrottleState *ts, | 110 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_file = { |
74 | */ | 111 | .bdrv_refresh_limits = raw_refresh_limits, |
75 | void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg) | 112 | .bdrv_io_plug = raw_aio_plug, |
76 | { | 113 | .bdrv_io_unplug = raw_aio_unplug, |
77 | + int i; | 114 | + .bdrv_attach_aio_context = raw_aio_attach_aio_context, |
115 | |||
116 | .bdrv_truncate = raw_truncate, | ||
117 | .bdrv_getlength = raw_getlength, | ||
118 | diff --git a/block/linux-aio.c b/block/linux-aio.c | ||
119 | index XXXXXXX..XXXXXXX 100644 | ||
120 | --- a/block/linux-aio.c | ||
121 | +++ b/block/linux-aio.c | ||
122 | @@ -XXX,XX +XXX,XX @@ | ||
123 | #include "block/raw-aio.h" | ||
124 | #include "qemu/event_notifier.h" | ||
125 | #include "qemu/coroutine.h" | ||
126 | +#include "qapi/error.h" | ||
127 | |||
128 | #include <libaio.h> | ||
129 | |||
130 | @@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) | ||
131 | qemu_laio_poll_cb); | ||
132 | } | ||
133 | |||
134 | -LinuxAioState *laio_init(void) | ||
135 | +LinuxAioState *laio_init(Error **errp) | ||
136 | { | ||
137 | + int rc; | ||
138 | LinuxAioState *s; | ||
139 | |||
140 | s = g_malloc0(sizeof(*s)); | ||
141 | - if (event_notifier_init(&s->e, false) < 0) { | ||
142 | + rc = event_notifier_init(&s->e, false); | ||
143 | + if (rc < 0) { | ||
144 | + error_setg_errno(errp, -rc, "failed to to initialize event notifier"); | ||
145 | goto out_free_state; | ||
146 | } | ||
147 | |||
148 | - if (io_setup(MAX_EVENTS, &s->ctx) != 0) { | ||
149 | + rc = io_setup(MAX_EVENTS, &s->ctx); | ||
150 | + if (rc < 0) { | ||
151 | + error_setg_errno(errp, -rc, "failed to create linux AIO context"); | ||
152 | goto out_close_efd; | ||
153 | } | ||
154 | |||
155 | diff --git a/stubs/linux-aio.c b/stubs/linux-aio.c | ||
156 | index XXXXXXX..XXXXXXX 100644 | ||
157 | --- a/stubs/linux-aio.c | ||
158 | +++ b/stubs/linux-aio.c | ||
159 | @@ -XXX,XX +XXX,XX @@ void laio_attach_aio_context(LinuxAioState *s, AioContext *new_context) | ||
160 | abort(); | ||
161 | } | ||
162 | |||
163 | -LinuxAioState *laio_init(void) | ||
164 | +LinuxAioState *laio_init(Error **errp) | ||
165 | { | ||
166 | abort(); | ||
167 | } | ||
168 | diff --git a/util/async.c b/util/async.c | ||
169 | index XXXXXXX..XXXXXXX 100644 | ||
170 | --- a/util/async.c | ||
171 | +++ b/util/async.c | ||
172 | @@ -XXX,XX +XXX,XX @@ ThreadPool *aio_get_thread_pool(AioContext *ctx) | ||
173 | } | ||
174 | |||
175 | #ifdef CONFIG_LINUX_AIO | ||
176 | -LinuxAioState *aio_get_linux_aio(AioContext *ctx) | ||
177 | +LinuxAioState *aio_setup_linux_aio(AioContext *ctx, Error **errp) | ||
178 | { | ||
179 | if (!ctx->linux_aio) { | ||
180 | - ctx->linux_aio = laio_init(); | ||
181 | - laio_attach_aio_context(ctx->linux_aio, ctx); | ||
182 | + ctx->linux_aio = laio_init(errp); | ||
183 | + if (ctx->linux_aio) { | ||
184 | + laio_attach_aio_context(ctx->linux_aio, ctx); | ||
185 | + } | ||
186 | } | ||
187 | return ctx->linux_aio; | ||
188 | } | ||
78 | + | 189 | + |
79 | *cfg = ts->cfg; | 190 | +LinuxAioState *aio_get_linux_aio(AioContext *ctx) |
80 | + | 191 | +{ |
81 | + for (i = 0; i < BUCKETS_COUNT; i++) { | 192 | + assert(ctx->linux_aio); |
82 | + throttle_unfix_bucket(&cfg->buckets[i]); | 193 | + return ctx->linux_aio; |
83 | + } | 194 | +} |
84 | } | 195 | #endif |
85 | 196 | ||
86 | 197 | void aio_notify(AioContext *ctx) | |
87 | -- | 198 | -- |
88 | 2.9.3 | 199 | 2.17.1 |
89 | 200 | ||
90 | 201 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Lidong Chen <lidongchen@tencent.com> | ||
2 | 1 | ||
3 | BLOCK_SIZE is (1 << 20), qcow2 cluster size is 65536 by default, | ||
4 | this may cause the qcow2 file size to be bigger after migration. | ||
5 | This patch checks each cluster, using blk_pwrite_zeroes for each | ||
6 | zero cluster. | ||
7 | |||
8 | [Initialize cluster_size to BLOCK_SIZE to prevent a gcc uninitialized | ||
9 | variable compiler warning. In reality we always initialize cluster_size | ||
10 | in a conditional but gcc doesn't know that. | ||
11 | --Stefan] | ||
12 | |||
13 | Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
14 | Signed-off-by: Lidong Chen <lidongchen@tencent.com> | ||
15 | Message-id: 1492050868-16200-1-git-send-email-lidongchen@tencent.com | ||
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
17 | --- | ||
18 | migration/block.c | 35 +++++++++++++++++++++++++++++++++-- | ||
19 | 1 file changed, 33 insertions(+), 2 deletions(-) | ||
20 | |||
21 | diff --git a/migration/block.c b/migration/block.c | ||
22 | index XXXXXXX..XXXXXXX 100644 | ||
23 | --- a/migration/block.c | ||
24 | +++ b/migration/block.c | ||
25 | @@ -XXX,XX +XXX,XX @@ static int block_load(QEMUFile *f, void *opaque, int version_id) | ||
26 | int64_t total_sectors = 0; | ||
27 | int nr_sectors; | ||
28 | int ret; | ||
29 | + BlockDriverInfo bdi; | ||
30 | + int cluster_size = BLOCK_SIZE; | ||
31 | |||
32 | do { | ||
33 | addr = qemu_get_be64(f); | ||
34 | @@ -XXX,XX +XXX,XX @@ static int block_load(QEMUFile *f, void *opaque, int version_id) | ||
35 | error_report_err(local_err); | ||
36 | return -EINVAL; | ||
37 | } | ||
38 | + | ||
39 | + ret = bdrv_get_info(blk_bs(blk), &bdi); | ||
40 | + if (ret == 0 && bdi.cluster_size > 0 && | ||
41 | + bdi.cluster_size <= BLOCK_SIZE && | ||
42 | + BLOCK_SIZE % bdi.cluster_size == 0) { | ||
43 | + cluster_size = bdi.cluster_size; | ||
44 | + } else { | ||
45 | + cluster_size = BLOCK_SIZE; | ||
46 | + } | ||
47 | } | ||
48 | |||
49 | if (total_sectors - addr < BDRV_SECTORS_PER_DIRTY_CHUNK) { | ||
50 | @@ -XXX,XX +XXX,XX @@ static int block_load(QEMUFile *f, void *opaque, int version_id) | ||
51 | nr_sectors * BDRV_SECTOR_SIZE, | ||
52 | BDRV_REQ_MAY_UNMAP); | ||
53 | } else { | ||
54 | + int i; | ||
55 | + int64_t cur_addr; | ||
56 | + uint8_t *cur_buf; | ||
57 | + | ||
58 | buf = g_malloc(BLOCK_SIZE); | ||
59 | qemu_get_buffer(f, buf, BLOCK_SIZE); | ||
60 | - ret = blk_pwrite(blk, addr * BDRV_SECTOR_SIZE, buf, | ||
61 | - nr_sectors * BDRV_SECTOR_SIZE, 0); | ||
62 | + for (i = 0; i < BLOCK_SIZE / cluster_size; i++) { | ||
63 | + cur_addr = addr * BDRV_SECTOR_SIZE + i * cluster_size; | ||
64 | + cur_buf = buf + i * cluster_size; | ||
65 | + | ||
66 | + if ((!block_mig_state.zero_blocks || | ||
67 | + cluster_size < BLOCK_SIZE) && | ||
68 | + buffer_is_zero(cur_buf, cluster_size)) { | ||
69 | + ret = blk_pwrite_zeroes(blk, cur_addr, | ||
70 | + cluster_size, | ||
71 | + BDRV_REQ_MAY_UNMAP); | ||
72 | + } else { | ||
73 | + ret = blk_pwrite(blk, cur_addr, cur_buf, | ||
74 | + cluster_size, 0); | ||
75 | + } | ||
76 | + if (ret < 0) { | ||
77 | + break; | ||
78 | + } | ||
79 | + } | ||
80 | g_free(buf); | ||
81 | } | ||
82 | |||
83 | -- | ||
84 | 2.9.3 | ||
85 | |||
86 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Changlong Xie <xiecl.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | So he can get CC'ed on future patches and bugs for this feature | ||
4 | |||
5 | Signed-off-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com> | ||
6 | Message-id: 1492484893-23435-1-git-send-email-xiecl.fnst@cn.fujitsu.com | ||
7 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
8 | --- | ||
9 | MAINTAINERS | 2 +- | ||
10 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
11 | |||
12 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
13 | index XXXXXXX..XXXXXXX 100644 | ||
14 | --- a/MAINTAINERS | ||
15 | +++ b/MAINTAINERS | ||
16 | @@ -XXX,XX +XXX,XX @@ S: Supported | ||
17 | F: tests/image-fuzzer/ | ||
18 | |||
19 | Replication | ||
20 | -M: Wen Congyang <wency@cn.fujitsu.com> | ||
21 | +M: Wen Congyang <wencongyang2@huawei.com> | ||
22 | M: Changlong Xie <xiecl.fnst@cn.fujitsu.com> | ||
23 | S: Supported | ||
24 | F: replication* | ||
25 | -- | ||
26 | 2.9.3 | ||
27 | |||
28 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Zhang Chen <zhangchen.fnst@cn.fujitsu.com> | ||
2 | 1 | ||
3 | I'm leaving my job at Fujitsu, this email address will stop working | ||
4 | this week. Update it to one that I will have access to later. | ||
5 | |||
6 | Signed-off-by: Xie Changlong <xiecl.fnst@cn.fujitsu.com> | ||
7 | Message-id: 1492758767-19716-1-git-send-email-xiecl.fnst@cn.fujitsu.com | ||
8 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | --- | ||
10 | MAINTAINERS | 2 +- | ||
11 | 1 file changed, 1 insertion(+), 1 deletion(-) | ||
12 | |||
13 | diff --git a/MAINTAINERS b/MAINTAINERS | ||
14 | index XXXXXXX..XXXXXXX 100644 | ||
15 | --- a/MAINTAINERS | ||
16 | +++ b/MAINTAINERS | ||
17 | @@ -XXX,XX +XXX,XX @@ F: tests/image-fuzzer/ | ||
18 | |||
19 | Replication | ||
20 | M: Wen Congyang <wencongyang2@huawei.com> | ||
21 | -M: Changlong Xie <xiecl.fnst@cn.fujitsu.com> | ||
22 | +M: Xie Changlong <xiechanglong.d@gmail.com> | ||
23 | S: Supported | ||
24 | F: replication* | ||
25 | F: block/replication.c | ||
26 | -- | ||
27 | 2.9.3 | ||
28 | |||
29 | diff view generated by jsdifflib |