block: bdrv_set_backing_hd(): use drained section
Graph modifications should be done in drained section. stream_prepare() handler of block stream job call bdrv_set_backing_hd() without using drained section and it's theoretically possible that some IO request will interleave with graph modification and will use outdated pointers to removed block nodes. Some other callers use bdrv_set_backing_hd() not caring about drained sections too. So it seems good to make a drained section exactly in bdrv_set_backing_hd(). Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20220124173741.2984056-1-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
e66e665f15
commit
c0829cb1fd
4
block.c
4
block.c
@ -3341,6 +3341,8 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
|
|||||||
int ret;
|
int ret;
|
||||||
Transaction *tran = tran_new();
|
Transaction *tran = tran_new();
|
||||||
|
|
||||||
|
bdrv_drained_begin(bs);
|
||||||
|
|
||||||
ret = bdrv_set_backing_noperm(bs, backing_hd, tran, errp);
|
ret = bdrv_set_backing_noperm(bs, backing_hd, tran, errp);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
goto out;
|
goto out;
|
||||||
@ -3350,6 +3352,8 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDriverState *backing_hd,
|
|||||||
out:
|
out:
|
||||||
tran_finalize(tran, ret);
|
tran_finalize(tran, ret);
|
||||||
|
|
||||||
|
bdrv_drained_end(bs);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user