block: Mark bdrv_co_copy_range() GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_copy_range() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230203152202.49054-15-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
eeb4777544
commit
742bf09b20
@ -2644,6 +2644,8 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_in, int64_t off_in,
|
|||||||
if (r) {
|
if (r) {
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GRAPH_RDLOCK_GUARD();
|
||||||
return bdrv_co_copy_range(blk_in->root, off_in,
|
return bdrv_co_copy_range(blk_in->root, off_in,
|
||||||
blk_out->root, off_out,
|
blk_out->root, off_out,
|
||||||
bytes, read_flags, write_flags);
|
bytes, read_flags, write_flags);
|
||||||
|
@ -3272,7 +3272,7 @@ static void raw_abort_perm_update(BlockDriverState *bs)
|
|||||||
raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL);
|
raw_handle_perm_lock(bs, RAW_PL_ABORT, 0, 0, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn raw_co_copy_range_from(
|
static int coroutine_fn GRAPH_RDLOCK raw_co_copy_range_from(
|
||||||
BlockDriverState *bs, BdrvChild *src, int64_t src_offset,
|
BlockDriverState *bs, BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst, int64_t dst_offset, int64_t bytes,
|
BdrvChild *dst, int64_t dst_offset, int64_t bytes,
|
||||||
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags)
|
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags)
|
||||||
@ -3281,14 +3281,12 @@ static int coroutine_fn raw_co_copy_range_from(
|
|||||||
read_flags, write_flags);
|
read_flags, write_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *src,
|
raw_co_copy_range_to(BlockDriverState *bs,
|
||||||
int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
int64_t dst_offset,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
int64_t bytes,
|
BdrvRequestFlags write_flags)
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags)
|
|
||||||
{
|
{
|
||||||
RawPosixAIOData acb;
|
RawPosixAIOData acb;
|
||||||
BDRVRawState *s = bs->opaque;
|
BDRVRawState *s = bs->opaque;
|
||||||
|
@ -3246,6 +3246,7 @@ static int coroutine_fn GRAPH_RDLOCK bdrv_co_copy_range_internal(
|
|||||||
{
|
{
|
||||||
BdrvTrackedRequest req;
|
BdrvTrackedRequest req;
|
||||||
int ret;
|
int ret;
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
|
|
||||||
/* TODO We can support BDRV_REQ_NO_FALLBACK here */
|
/* TODO We can support BDRV_REQ_NO_FALLBACK here */
|
||||||
assert(!(read_flags & BDRV_REQ_NO_FALLBACK));
|
assert(!(read_flags & BDRV_REQ_NO_FALLBACK));
|
||||||
@ -3327,7 +3328,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
|
|||||||
BdrvRequestFlags write_flags)
|
BdrvRequestFlags write_flags)
|
||||||
{
|
{
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
assume_graph_lock(); /* FIXME */
|
assert_bdrv_graph_readable();
|
||||||
trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
|
trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
|
||||||
read_flags, write_flags);
|
read_flags, write_flags);
|
||||||
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
||||||
@ -3345,7 +3346,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
|
|||||||
BdrvRequestFlags write_flags)
|
BdrvRequestFlags write_flags)
|
||||||
{
|
{
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
assume_graph_lock(); /* FIXME */
|
assert_bdrv_graph_readable();
|
||||||
trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
||||||
read_flags, write_flags);
|
read_flags, write_flags);
|
||||||
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
|
||||||
@ -3358,6 +3359,8 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
|
|||||||
BdrvRequestFlags write_flags)
|
BdrvRequestFlags write_flags)
|
||||||
{
|
{
|
||||||
IO_CODE();
|
IO_CODE();
|
||||||
|
assert_bdrv_graph_readable();
|
||||||
|
|
||||||
return bdrv_co_copy_range_from(src, src_offset,
|
return bdrv_co_copy_range_from(src, src_offset,
|
||||||
dst, dst_offset,
|
dst, dst_offset,
|
||||||
bytes, read_flags, write_flags);
|
bytes, read_flags, write_flags);
|
||||||
|
@ -2190,14 +2190,12 @@ static void coroutine_fn iscsi_co_invalidate_cache(BlockDriverState *bs,
|
|||||||
iscsi_allocmap_invalidate(iscsilun);
|
iscsi_allocmap_invalidate(iscsilun);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn iscsi_co_copy_range_from(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *src,
|
iscsi_co_copy_range_from(BlockDriverState *bs,
|
||||||
int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
int64_t dst_offset,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
int64_t bytes,
|
BdrvRequestFlags write_flags)
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags)
|
|
||||||
{
|
{
|
||||||
return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
return bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
|
||||||
read_flags, write_flags);
|
read_flags, write_flags);
|
||||||
@ -2331,14 +2329,12 @@ static void iscsi_xcopy_data(struct iscsi_data *data,
|
|||||||
src_lba, dst_lba);
|
src_lba, dst_lba);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn iscsi_co_copy_range_to(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *src,
|
iscsi_co_copy_range_to(BlockDriverState *bs,
|
||||||
int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
int64_t dst_offset,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
int64_t bytes,
|
BdrvRequestFlags write_flags)
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags)
|
|
||||||
{
|
{
|
||||||
IscsiLun *dst_lun = dst->bs->opaque;
|
IscsiLun *dst_lun = dst->bs->opaque;
|
||||||
IscsiLun *src_lun;
|
IscsiLun *src_lun;
|
||||||
|
@ -4065,7 +4065,7 @@ static coroutine_fn int qcow2_co_pdiscard(BlockDriverState *bs,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
qcow2_co_copy_range_from(BlockDriverState *bs,
|
qcow2_co_copy_range_from(BlockDriverState *bs,
|
||||||
BdrvChild *src, int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst, int64_t dst_offset,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
@ -4148,7 +4148,7 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
qcow2_co_copy_range_to(BlockDriverState *bs,
|
qcow2_co_copy_range_to(BlockDriverState *bs,
|
||||||
BdrvChild *src, int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst, int64_t dst_offset,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
@ -4161,7 +4161,6 @@ qcow2_co_copy_range_to(BlockDriverState *bs,
|
|||||||
uint64_t host_offset;
|
uint64_t host_offset;
|
||||||
QCowL2Meta *l2meta = NULL;
|
QCowL2Meta *l2meta = NULL;
|
||||||
|
|
||||||
assume_graph_lock(); /* FIXME */
|
|
||||||
assert(!bs->encrypted);
|
assert(!bs->encrypted);
|
||||||
|
|
||||||
qemu_co_mutex_lock(&s->lock);
|
qemu_co_mutex_lock(&s->lock);
|
||||||
|
@ -536,14 +536,12 @@ static int raw_probe_geometry(BlockDriverState *bs, HDGeometry *geo)
|
|||||||
return bdrv_probe_geometry(bs->file->bs, geo);
|
return bdrv_probe_geometry(bs->file->bs, geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *src,
|
raw_co_copy_range_from(BlockDriverState *bs,
|
||||||
int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
int64_t dst_offset,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
int64_t bytes,
|
BdrvRequestFlags write_flags)
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@ -555,14 +553,12 @@ static int coroutine_fn raw_co_copy_range_from(BlockDriverState *bs,
|
|||||||
bytes, read_flags, write_flags);
|
bytes, read_flags, write_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int coroutine_fn raw_co_copy_range_to(BlockDriverState *bs,
|
static int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *src,
|
raw_co_copy_range_to(BlockDriverState *bs,
|
||||||
int64_t src_offset,
|
BdrvChild *src, int64_t src_offset,
|
||||||
BdrvChild *dst,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
int64_t dst_offset,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
int64_t bytes,
|
BdrvRequestFlags write_flags)
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags)
|
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -274,10 +274,11 @@ bool co_wrapper bdrv_can_store_new_dirty_bitmap(BlockDriverState *bs,
|
|||||||
*
|
*
|
||||||
* Returns: 0 if succeeded; negative error code if failed.
|
* Returns: 0 if succeeded; negative error code if failed.
|
||||||
**/
|
**/
|
||||||
int coroutine_fn bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *dst, int64_t dst_offset,
|
bdrv_co_copy_range(BdrvChild *src, int64_t src_offset,
|
||||||
int64_t bytes, BdrvRequestFlags read_flags,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
BdrvRequestFlags write_flags);
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
|
BdrvRequestFlags write_flags);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* "I/O or GS" API functions. These functions can run without
|
* "I/O or GS" API functions. These functions can run without
|
||||||
|
@ -559,14 +559,10 @@ struct BlockDriver {
|
|||||||
* See the comment of bdrv_co_copy_range for the parameter and return value
|
* See the comment of bdrv_co_copy_range for the parameter and return value
|
||||||
* semantics.
|
* semantics.
|
||||||
*/
|
*/
|
||||||
int coroutine_fn (*bdrv_co_copy_range_from)(BlockDriverState *bs,
|
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_copy_range_from)(
|
||||||
BdrvChild *src,
|
BlockDriverState *bs, BdrvChild *src, int64_t offset,
|
||||||
int64_t offset,
|
BdrvChild *dst, int64_t dst_offset, int64_t bytes,
|
||||||
BdrvChild *dst,
|
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags);
|
||||||
int64_t dst_offset,
|
|
||||||
int64_t bytes,
|
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Map [offset, offset + nbytes) range onto a child of bs to copy data to,
|
* Map [offset, offset + nbytes) range onto a child of bs to copy data to,
|
||||||
@ -577,14 +573,10 @@ struct BlockDriver {
|
|||||||
* See the comment of bdrv_co_copy_range for the parameter and return value
|
* See the comment of bdrv_co_copy_range for the parameter and return value
|
||||||
* semantics.
|
* semantics.
|
||||||
*/
|
*/
|
||||||
int coroutine_fn (*bdrv_co_copy_range_to)(BlockDriverState *bs,
|
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_copy_range_to)(
|
||||||
BdrvChild *src,
|
BlockDriverState *bs, BdrvChild *src, int64_t src_offset,
|
||||||
int64_t src_offset,
|
BdrvChild *dst, int64_t dst_offset, int64_t bytes,
|
||||||
BdrvChild *dst,
|
BdrvRequestFlags read_flags, BdrvRequestFlags write_flags);
|
||||||
int64_t dst_offset,
|
|
||||||
int64_t bytes,
|
|
||||||
BdrvRequestFlags read_flags,
|
|
||||||
BdrvRequestFlags write_flags);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Building block for bdrv_block_status[_above] and
|
* Building block for bdrv_block_status[_above] and
|
||||||
|
@ -113,16 +113,16 @@ void bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest,
|
|||||||
void bdrv_inc_in_flight(BlockDriverState *bs);
|
void bdrv_inc_in_flight(BlockDriverState *bs);
|
||||||
void bdrv_dec_in_flight(BlockDriverState *bs);
|
void bdrv_dec_in_flight(BlockDriverState *bs);
|
||||||
|
|
||||||
int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *dst, int64_t dst_offset,
|
bdrv_co_copy_range_from(BdrvChild *src, int64_t src_offset,
|
||||||
int64_t bytes,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
BdrvRequestFlags read_flags,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
BdrvRequestFlags write_flags);
|
BdrvRequestFlags write_flags);
|
||||||
int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
|
int coroutine_fn GRAPH_RDLOCK
|
||||||
BdrvChild *dst, int64_t dst_offset,
|
bdrv_co_copy_range_to(BdrvChild *src, int64_t src_offset,
|
||||||
int64_t bytes,
|
BdrvChild *dst, int64_t dst_offset,
|
||||||
BdrvRequestFlags read_flags,
|
int64_t bytes, BdrvRequestFlags read_flags,
|
||||||
BdrvRequestFlags write_flags);
|
BdrvRequestFlags write_flags);
|
||||||
|
|
||||||
int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs,
|
int coroutine_fn bdrv_co_refresh_total_sectors(BlockDriverState *bs,
|
||||||
int64_t hint);
|
int64_t hint);
|
||||||
|
@ -2041,7 +2041,9 @@ retry:
|
|||||||
|
|
||||||
if (s->ret == -EINPROGRESS) {
|
if (s->ret == -EINPROGRESS) {
|
||||||
if (copy_range) {
|
if (copy_range) {
|
||||||
ret = convert_co_copy_range(s, sector_num, n);
|
WITH_GRAPH_RDLOCK_GUARD() {
|
||||||
|
ret = convert_co_copy_range(s, sector_num, n);
|
||||||
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
s->copy_range = false;
|
s->copy_range = false;
|
||||||
goto retry;
|
goto retry;
|
||||||
|
Loading…
Reference in New Issue
Block a user