[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 10/31] block.c: modify .attach and .detach callbacks of child_
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v5 10/31] block.c: modify .attach and .detach callbacks of child_of_bds |
Date: |
Wed, 24 Nov 2021 01:43:57 -0500 |
According to the assertions put in the previous patch, we should
first drain and then modify the ->children list. In this way
we prevent other iothreads to read the list while it is being
updated.
In this case, moving the drain won't cause any harm, because
child is a parameter of the drain function so it will still be
included in the operation, despite not being in the list.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/block.c b/block.c
index 522a273140..5516c84ec4 100644
--- a/block.c
+++ b/block.c
@@ -1416,6 +1416,7 @@ static void bdrv_child_cb_attach(BdrvChild *child)
{
BlockDriverState *bs = child->opaque;
+ bdrv_apply_subtree_drain(child, bs);
assert_bdrv_graph_writable(bs);
QLIST_INSERT_HEAD(&bs->children, child, next);
@@ -1423,7 +1424,6 @@ static void bdrv_child_cb_attach(BdrvChild *child)
bdrv_backing_attach(child);
}
- bdrv_apply_subtree_drain(child, bs);
}
static void bdrv_child_cb_detach(BdrvChild *child)
@@ -1434,10 +1434,9 @@ static void bdrv_child_cb_detach(BdrvChild *child)
bdrv_backing_detach(child);
}
- bdrv_unapply_subtree_drain(child, bs);
-
assert_bdrv_graph_writable(bs);
QLIST_REMOVE(child, next);
+ bdrv_unapply_subtree_drain(child, bs);
}
static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *base,
--
2.27.0
- [PATCH v5 00/31] block layer: split block APIs in global state and I/O, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 01/31] main-loop.h: introduce qemu_in_main_thread(), Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 04/31] include/sysemu/block-backend: split header into I/O and global state (GS) API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 05/31] block-backend: special comments for blk_set/get_perm due to fuse, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 03/31] assertions for block global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 06/31] block/block-backend.c: assertions for block-backend, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 02/31] include/block/block: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 10/31] block.c: modify .attach and .detach callbacks of child_of_bds,
Emanuele Giuseppe Esposito <=
- [PATCH v5 08/31] assertions for block_int global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 09/31] block: introduce assert_bdrv_graph_writable, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 07/31] include/block/block_int: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 12/31] assertions for blockjob_int.h, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 13/31] block.c: add assertions to static functions, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 11/31] include/block/blockjob_int.h: split header into I/O and GS API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 14/31] include/block/blockjob.h: global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 15/31] assertions for blockjob.h global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 17/31] assertions for blockdev.h global state API, Emanuele Giuseppe Esposito, 2021/11/24
- [PATCH v5 19/31] block/copy-before-write.h: global state API + assertions, Emanuele Giuseppe Esposito, 2021/11/24