[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 07/27] block: Factor out bdrv_replace_child_noperm()
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 07/27] block: Factor out bdrv_replace_child_noperm() |
Date: |
Tue, 7 Mar 2017 16:40:31 +0100 |
Signed-off-by: Kevin Wolf <address@hidden>
Reviewed-by: Fam Zheng <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
---
block.c | 38 +++++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 13 deletions(-)
diff --git a/block.c b/block.c
index 6dc02b8..d4570c8 100644
--- a/block.c
+++ b/block.c
@@ -1713,11 +1713,10 @@ void bdrv_format_default_perms(BlockDriverState *bs,
BdrvChild *c,
*nshared = shared;
}
-static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
- bool check_new_perm)
+static void bdrv_replace_child_noperm(BdrvChild *child,
+ BlockDriverState *new_bs)
{
BlockDriverState *old_bs = child->bs;
- uint64_t perm, shared_perm;
if (old_bs) {
if (old_bs->quiesce_counter && child->role->drained_end) {
@@ -1727,7 +1726,29 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs,
child->role->detach(child);
}
QLIST_REMOVE(child, next_parent);
+ }
+
+ child->bs = new_bs;
+
+ if (new_bs) {
+ QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
+ if (new_bs->quiesce_counter && child->role->drained_begin) {
+ child->role->drained_begin(child);
+ }
+
+ if (child->role->attach) {
+ child->role->attach(child);
+ }
+ }
+}
+static void bdrv_replace_child(BdrvChild *child, BlockDriverState *new_bs,
+ bool check_new_perm)
+{
+ BlockDriverState *old_bs = child->bs;
+ uint64_t perm, shared_perm;
+
+ if (old_bs) {
/* Update permissions for old node. This is guaranteed to succeed
* because we're just taking a parent away, so we're loosening
* restrictions. */
@@ -1736,23 +1757,14 @@ static void bdrv_replace_child(BdrvChild *child,
BlockDriverState *new_bs,
bdrv_set_perm(old_bs, perm, shared_perm);
}
- child->bs = new_bs;
+ bdrv_replace_child_noperm(child, new_bs);
if (new_bs) {
- QLIST_INSERT_HEAD(&new_bs->parents, child, next_parent);
- if (new_bs->quiesce_counter && child->role->drained_begin) {
- child->role->drained_begin(child);
- }
-
bdrv_get_cumulative_perm(new_bs, &perm, &shared_perm);
if (check_new_perm) {
bdrv_check_perm(new_bs, perm, shared_perm, &error_abort);
}
bdrv_set_perm(new_bs, perm, shared_perm);
-
- if (child->role->attach) {
- child->role->attach(child);
- }
}
}
--
1.8.3.1
- [Qemu-block] [PULL 00/27] Block layer fixes for 2.9.0-rc0, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 03/27] mirror: Fix permissions for removing mirror_top_bs, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 01/27] commit: Fix error handling, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 02/27] mirror: Fix permission problem with 'replaces', Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 05/27] block: Fix blockdev-snapshot error handling, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 04/27] mirror: Fix error path for dirty bitmap creation, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 07/27] block: Factor out bdrv_replace_child_noperm(),
Kevin Wolf <=
- [Qemu-block] [PULL 06/27] block: Factor out should_update_child(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 08/27] block: Ignore multiple children in bdrv_check_update_perm(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 11/27] sheepdog: Defuse time bomb in sd_open() error handling, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 09/27] block: Handle permission errors in change_parent_backing_link(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 10/27] block: Fix error handling in bdrv_replace_in_backing_chain(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 13/27] sheepdog: Fix error handling sd_create(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 14/27] sheepdog: Mark sd_snapshot_delete() lossage FIXME, Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 12/27] sheepdog: Fix error handling in sd_snapshot_delete(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 15/27] sheepdog: Fix snapshot ID parsing in _open(), _create, _goto(), Kevin Wolf, 2017/03/07
- [Qemu-block] [PULL 16/27] sheepdog: Don't truncate long VDI name in _open(), _create(), Kevin Wolf, 2017/03/07