OSDN Git Service

replication: Properly attach children
authorLukas Straub <lukasstraub2@web.de>
Sun, 18 Jul 2021 14:48:33 +0000 (16:48 +0200)
committerKevin Wolf <kwolf@redhat.com>
Tue, 20 Jul 2021 14:11:53 +0000 (16:11 +0200)
commit3b78420bb14f7e439a079aee28eeec997a229c5e
tree86cea7550198c3219206d9f8691a5a32080a8fd9
parenta990a42b39338ffd12fb9640d792276313f75ed5
replication: Properly attach children

The replication driver needs access to the children block-nodes of
it's child so it can issue bdrv_make_empty() and bdrv_co_pwritev()
to manage the replication. However, it does this by directly copying
the BdrvChilds, which is wrong.

Fix this by properly attaching the block-nodes with
bdrv_attach_child() and requesting the required permissions.

This ultimatively fixes a potential crash in replication_co_writev(),
because it may write to s->secondary_disk if it is in state
BLOCK_REPLICATION_FAILOVER_FAILED, without requesting write
permissions first. And now the workaround in
secondary_do_checkpoint() can be removed.

Signed-off-by: Lukas Straub <lukasstraub2@web.de>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Message-Id: <5d0539d729afb8072d0d7cde977c5066285591b4.1626619393.git.lukasstraub2@web.de>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block/replication.c