[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/10] block: Expect graph changes in bdrv_parent_dra
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 06/10] block: Expect graph changes in bdrv_parent_drained_begin/end |
Date: |
Wed, 29 Nov 2017 16:26:24 +0100 |
The .drained_begin/end callbacks can (directly or indirectly via
aio_poll()) cause block nodes to be removed or the current BdrvChild to
point to a different child node.
Use QLIST_FOREACH_SAFE() to make sure we don't access invalid
BlockDriverStates or accidentally continue iterating the parents of the
new child node instead of the node we actually came from.
Signed-off-by: Kevin Wolf <address@hidden>
Tested-by: Jeff Cody <address@hidden>
Reviewed-by: Stefan Hajnoczi <address@hidden>
Reviewed-by: Jeff Cody <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/io.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/block/io.c b/block/io.c
index 4fdf93a014..6773926fc1 100644
--- a/block/io.c
+++ b/block/io.c
@@ -42,9 +42,9 @@ static int coroutine_fn
bdrv_co_do_pwrite_zeroes(BlockDriverState *bs,
void bdrv_parent_drained_begin(BlockDriverState *bs)
{
- BdrvChild *c;
+ BdrvChild *c, *next;
- QLIST_FOREACH(c, &bs->parents, next_parent) {
+ QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
if (c->role->drained_begin) {
c->role->drained_begin(c);
}
@@ -53,9 +53,9 @@ void bdrv_parent_drained_begin(BlockDriverState *bs)
void bdrv_parent_drained_end(BlockDriverState *bs)
{
- BdrvChild *c;
+ BdrvChild *c, *next;
- QLIST_FOREACH(c, &bs->parents, next_parent) {
+ QLIST_FOREACH_SAFE(c, &bs->parents, next_parent, next) {
if (c->role->drained_end) {
c->role->drained_end(c);
}
--
2.13.6
- [Qemu-devel] [PULL 00/10] Block layer fixes for 2.11.0-rc3, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 01/10] iotests: fix 075 and 078, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 03/10] qemu-options: Mention locking option of file driver, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 04/10] QAPI & interop: Clarify events emitted by 'block-job-cancel', Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 02/10] docs: Add image locking subsection, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 05/10] blockjob: Remove the job from the list earlier in block_job_unref(), Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 06/10] block: Expect graph changes in bdrv_parent_drained_begin/end,
Kevin Wolf <=
- [Qemu-devel] [PULL 07/10] blockjob: remove clock argument from block_job_sleep_ns, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 08/10] blockjob: introduce block_job_do_yield, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 09/10] blockjob: reimplement block_job_sleep_ns to allow cancellation, Kevin Wolf, 2017/11/29
- [Qemu-devel] [PULL 10/10] block/nfs: fix nfs_client_open for filesize greater than 1TB, Kevin Wolf, 2017/11/29
- Re: [Qemu-devel] [PULL 00/10] Block layer fixes for 2.11.0-rc3, Peter Maydell, 2017/11/29