aboutsummaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito <eesposit@redhat.com>2023-01-13 21:42:08 +0100
committerKevin Wolf <kwolf@redhat.com>2023-02-01 16:52:32 +0100
commit3d47eb0a2a42b13734d1beb75c4310b3881f906f (patch)
treedccfa2e6cac772fe8c38cecca7d69c077c89d90d /block
parent82618d7bc341cb93b9ce9c206d7ec84cebe83d00 (diff)
block: Convert bdrv_get_info() to co_wrapper_mixed
bdrv_get_info() is categorized as an I/O function, and it currently doesn't run in a coroutine. We should let it take a graph rdlock since it traverses the block nodes graph, which however is only possible in a coroutine. Therefore turn it into a co_wrapper to move the actual function into a coroutine where the lock can be taken. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230113204212.359076-11-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/blkio.c5
-rw-r--r--block/crypto.c8
-rw-r--r--block/file-posix.c7
-rw-r--r--block/io.c8
-rw-r--r--block/iscsi.c7
-rw-r--r--block/mirror.c2
-rw-r--r--block/qcow.c5
-rw-r--r--block/qcow2.c5
-rw-r--r--block/qed.c5
-rw-r--r--block/raw-format.c7
-rw-r--r--block/rbd.c5
-rw-r--r--block/vdi.c7
-rw-r--r--block/vhdx.c5
-rw-r--r--block/vmdk.c5
-rw-r--r--block/vpc.c5
15 files changed, 49 insertions, 37 deletions
diff --git a/block/blkio.c b/block/blkio.c
index 284fb292cf..0cdc99a729 100644
--- a/block/blkio.c
+++ b/block/blkio.c
@@ -880,7 +880,8 @@ static int coroutine_fn blkio_truncate(BlockDriverState *bs, int64_t offset,
return 0;
}
-static int blkio_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+blkio_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
return 0;
}
@@ -1000,7 +1001,7 @@ static void blkio_refresh_limits(BlockDriverState *bs, Error **errp)
.bdrv_close = blkio_close, \
.bdrv_co_getlength = blkio_co_getlength, \
.bdrv_co_truncate = blkio_truncate, \
- .bdrv_get_info = blkio_get_info, \
+ .bdrv_co_get_info = blkio_co_get_info, \
.bdrv_attach_aio_context = blkio_attach_aio_context, \
.bdrv_detach_aio_context = blkio_detach_aio_context, \
.bdrv_co_pdiscard = blkio_co_pdiscard, \
diff --git a/block/crypto.c b/block/crypto.c
index 6d6c006887..b70cec97c7 100644
--- a/block/crypto.c
+++ b/block/crypto.c
@@ -737,13 +737,13 @@ fail:
return ret;
}
-static int block_crypto_get_info_luks(BlockDriverState *bs,
- BlockDriverInfo *bdi)
+static int coroutine_fn
+block_crypto_co_get_info_luks(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BlockDriverInfo subbdi;
int ret;
- ret = bdrv_get_info(bs->file->bs, &subbdi);
+ ret = bdrv_co_get_info(bs->file->bs, &subbdi);
if (ret != 0) {
return ret;
}
@@ -955,7 +955,7 @@ static BlockDriver bdrv_crypto_luks = {
.bdrv_co_pwritev = block_crypto_co_pwritev,
.bdrv_co_getlength = block_crypto_co_getlength,
.bdrv_measure = block_crypto_measure,
- .bdrv_get_info = block_crypto_get_info_luks,
+ .bdrv_co_get_info = block_crypto_co_get_info_luks,
.bdrv_get_specific_info = block_crypto_get_specific_info_luks,
.bdrv_amend_options = block_crypto_amend_options_luks,
.bdrv_co_amend = block_crypto_co_amend_luks,
diff --git a/block/file-posix.c b/block/file-posix.c
index 532ceb82da..c76ed7d9a7 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -3086,7 +3086,8 @@ static int coroutine_fn raw_co_pwrite_zeroes(
return raw_do_pwrite_zeroes(bs, offset, bytes, flags, false);
}
-static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+raw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
return 0;
}
@@ -3323,7 +3324,7 @@ BlockDriver bdrv_file = {
.bdrv_co_truncate = raw_co_truncate,
.bdrv_co_getlength = raw_co_getlength,
- .bdrv_get_info = raw_get_info,
+ .bdrv_co_get_info = raw_co_get_info,
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
.bdrv_get_specific_stats = raw_get_specific_stats,
.bdrv_check_perm = raw_check_perm,
@@ -3694,7 +3695,7 @@ static BlockDriver bdrv_host_device = {
.bdrv_co_truncate = raw_co_truncate,
.bdrv_co_getlength = raw_co_getlength,
- .bdrv_get_info = raw_get_info,
+ .bdrv_co_get_info = raw_co_get_info,
.bdrv_co_get_allocated_file_size = raw_co_get_allocated_file_size,
.bdrv_get_specific_stats = hdev_get_specific_stats,
.bdrv_check_perm = raw_check_perm,
diff --git a/block/io.c b/block/io.c
index e77087a7e8..15d57d0f14 100644
--- a/block/io.c
+++ b/block/io.c
@@ -722,14 +722,14 @@ BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_request(BlockDriverState *bs)
/**
* Round a region to cluster boundaries
*/
-void bdrv_round_to_clusters(BlockDriverState *bs,
+void coroutine_fn bdrv_round_to_clusters(BlockDriverState *bs,
int64_t offset, int64_t bytes,
int64_t *cluster_offset,
int64_t *cluster_bytes)
{
BlockDriverInfo bdi;
IO_CODE();
- if (bdrv_get_info(bs, &bdi) < 0 || bdi.cluster_size == 0) {
+ if (bdrv_co_get_info(bs, &bdi) < 0 || bdi.cluster_size == 0) {
*cluster_offset = offset;
*cluster_bytes = bytes;
} else {
@@ -739,12 +739,12 @@ void bdrv_round_to_clusters(BlockDriverState *bs,
}
}
-static int bdrv_get_cluster_size(BlockDriverState *bs)
+static coroutine_fn int bdrv_get_cluster_size(BlockDriverState *bs)
{
BlockDriverInfo bdi;
int ret;
- ret = bdrv_get_info(bs, &bdi);
+ ret = bdrv_co_get_info(bs, &bdi);
if (ret < 0 || bdi.cluster_size == 0) {
return bs->bl.request_alignment;
} else {
diff --git a/block/iscsi.c b/block/iscsi.c
index 359b532a33..b3e10f40b6 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -2171,7 +2171,8 @@ static int coroutine_fn iscsi_co_truncate(BlockDriverState *bs, int64_t offset,
return 0;
}
-static int iscsi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+iscsi_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
IscsiLun *iscsilun = bs->opaque;
bdi->cluster_size = iscsilun->cluster_size;
@@ -2435,7 +2436,7 @@ static BlockDriver bdrv_iscsi = {
.bdrv_co_invalidate_cache = iscsi_co_invalidate_cache,
.bdrv_co_getlength = iscsi_co_getlength,
- .bdrv_get_info = iscsi_get_info,
+ .bdrv_co_get_info = iscsi_co_get_info,
.bdrv_co_truncate = iscsi_co_truncate,
.bdrv_refresh_limits = iscsi_refresh_limits,
@@ -2474,7 +2475,7 @@ static BlockDriver bdrv_iser = {
.bdrv_co_invalidate_cache = iscsi_co_invalidate_cache,
.bdrv_co_getlength = iscsi_co_getlength,
- .bdrv_get_info = iscsi_get_info,
+ .bdrv_co_get_info = iscsi_co_get_info,
.bdrv_co_truncate = iscsi_co_truncate,
.bdrv_refresh_limits = iscsi_refresh_limits,
diff --git a/block/mirror.c b/block/mirror.c
index 7ed4dbde04..ab326b67c9 100644
--- a/block/mirror.c
+++ b/block/mirror.c
@@ -957,7 +957,7 @@ static int coroutine_fn mirror_run(Job *job, Error **errp)
*/
bdrv_get_backing_filename(target_bs, backing_filename,
sizeof(backing_filename));
- if (!bdrv_get_info(target_bs, &bdi) && bdi.cluster_size) {
+ if (!bdrv_co_get_info(target_bs, &bdi) && bdi.cluster_size) {
s->target_cluster_size = bdi.cluster_size;
} else {
s->target_cluster_size = BDRV_SECTOR_SIZE;
diff --git a/block/qcow.c b/block/qcow.c
index 5d99f00411..5f0801f545 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -1129,7 +1129,8 @@ fail:
return ret;
}
-static int qcow_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+qcow_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQcowState *s = bs->opaque;
bdi->cluster_size = s->cluster_size;
@@ -1198,7 +1199,7 @@ static BlockDriver bdrv_qcow = {
.bdrv_make_empty = qcow_make_empty,
.bdrv_co_pwritev_compressed = qcow_co_pwritev_compressed,
- .bdrv_get_info = qcow_get_info,
+ .bdrv_co_get_info = qcow_co_get_info,
.create_opts = &qcow_create_opts,
.strong_runtime_opts = qcow_strong_runtime_opts,
diff --git a/block/qcow2.c b/block/qcow2.c
index 2e9c57e269..5effd4b732 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -5143,7 +5143,8 @@ err:
return NULL;
}
-static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+qcow2_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQcow2State *s = bs->opaque;
bdi->cluster_size = s->cluster_size;
@@ -6077,7 +6078,7 @@ BlockDriver bdrv_qcow2 = {
.bdrv_snapshot_list = qcow2_snapshot_list,
.bdrv_snapshot_load_tmp = qcow2_snapshot_load_tmp,
.bdrv_measure = qcow2_measure,
- .bdrv_get_info = qcow2_get_info,
+ .bdrv_co_get_info = qcow2_co_get_info,
.bdrv_get_specific_info = qcow2_get_specific_info,
.bdrv_save_vmstate = qcow2_save_vmstate,
diff --git a/block/qed.c b/block/qed.c
index 16bf0cb080..4473465bba 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1486,7 +1486,8 @@ static int64_t coroutine_fn bdrv_qed_co_getlength(BlockDriverState *bs)
return s->header.image_size;
}
-static int bdrv_qed_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+bdrv_qed_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVQEDState *s = bs->opaque;
@@ -1654,7 +1655,7 @@ static BlockDriver bdrv_qed = {
.bdrv_co_pwrite_zeroes = bdrv_qed_co_pwrite_zeroes,
.bdrv_co_truncate = bdrv_qed_co_truncate,
.bdrv_co_getlength = bdrv_qed_co_getlength,
- .bdrv_get_info = bdrv_qed_get_info,
+ .bdrv_co_get_info = bdrv_qed_co_get_info,
.bdrv_refresh_limits = bdrv_qed_refresh_limits,
.bdrv_change_backing_file = bdrv_qed_change_backing_file,
.bdrv_co_invalidate_cache = bdrv_qed_co_invalidate_cache,
diff --git a/block/raw-format.c b/block/raw-format.c
index 836190a306..33d94e290b 100644
--- a/block/raw-format.c
+++ b/block/raw-format.c
@@ -368,9 +368,10 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, BlockDriverState *in_bs,
return info;
}
-static int raw_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+raw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
- return bdrv_get_info(bs->file->bs, bdi);
+ return bdrv_co_get_info(bs->file->bs, bdi);
}
static void raw_refresh_limits(BlockDriverState *bs, Error **errp)
@@ -626,7 +627,7 @@ BlockDriver bdrv_raw = {
.is_format = true,
.has_variable_length = true,
.bdrv_measure = &raw_measure,
- .bdrv_get_info = &raw_get_info,
+ .bdrv_co_get_info = &raw_co_get_info,
.bdrv_refresh_limits = &raw_refresh_limits,
.bdrv_probe_blocksizes = &raw_probe_blocksizes,
.bdrv_probe_geometry = &raw_probe_geometry,
diff --git a/block/rbd.c b/block/rbd.c
index c127c1550d..5e102fea0d 100644
--- a/block/rbd.c
+++ b/block/rbd.c
@@ -1240,7 +1240,8 @@ coroutine_fn qemu_rbd_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset,
}
#endif
-static int qemu_rbd_getinfo(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+qemu_rbd_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVRBDState *s = bs->opaque;
bdi->cluster_size = s->object_size;
@@ -1651,7 +1652,7 @@ static BlockDriver bdrv_rbd = {
.bdrv_co_create = qemu_rbd_co_create,
.bdrv_co_create_opts = qemu_rbd_co_create_opts,
.bdrv_has_zero_init = bdrv_has_zero_init_1,
- .bdrv_get_info = qemu_rbd_getinfo,
+ .bdrv_co_get_info = qemu_rbd_co_get_info,
.bdrv_get_specific_info = qemu_rbd_get_specific_info,
.create_opts = &qemu_rbd_create_opts,
.bdrv_co_getlength = qemu_rbd_co_getlength,
diff --git a/block/vdi.c b/block/vdi.c
index 479bcfe820..9c8736b26f 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -327,9 +327,10 @@ static int coroutine_fn vdi_co_check(BlockDriverState *bs, BdrvCheckResult *res,
return 0;
}
-static int vdi_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+vdi_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
- /* TODO: vdi_get_info would be needed for machine snapshots.
+ /* TODO: vdi_co_get_info would be needed for machine snapshots.
vm_state_offset is still missing. */
BDRVVdiState *s = (BDRVVdiState *)bs->opaque;
logout("\n");
@@ -1049,7 +1050,7 @@ static BlockDriver bdrv_vdi = {
.bdrv_co_pwritev = vdi_co_pwritev,
#endif
- .bdrv_get_info = vdi_get_info,
+ .bdrv_co_get_info = vdi_co_get_info,
.is_format = true,
.create_opts = &vdi_create_opts,
diff --git a/block/vhdx.c b/block/vhdx.c
index 4c929800fe..ef1f65d917 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1161,7 +1161,8 @@ static void vhdx_block_translate(BDRVVHDXState *s, int64_t sector_num,
}
-static int vhdx_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+vhdx_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVVHDXState *s = bs->opaque;
@@ -2245,7 +2246,7 @@ static BlockDriver bdrv_vhdx = {
.bdrv_co_writev = vhdx_co_writev,
.bdrv_co_create = vhdx_co_create,
.bdrv_co_create_opts = vhdx_co_create_opts,
- .bdrv_get_info = vhdx_get_info,
+ .bdrv_co_get_info = vhdx_co_get_info,
.bdrv_co_check = vhdx_co_check,
.bdrv_has_zero_init = vhdx_has_zero_init,
diff --git a/block/vmdk.c b/block/vmdk.c
index 04f50d2e49..1bba61ad7d 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -3012,7 +3012,8 @@ static bool vmdk_extents_type_eq(const VmdkExtent *a, const VmdkExtent *b)
(a->flat || a->cluster_sectors == b->cluster_sectors);
}
-static int vmdk_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+vmdk_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
int i;
BDRVVmdkState *s = bs->opaque;
@@ -3129,7 +3130,7 @@ static BlockDriver bdrv_vmdk = {
.bdrv_has_zero_init = vmdk_has_zero_init,
.bdrv_get_specific_info = vmdk_get_specific_info,
.bdrv_refresh_limits = vmdk_refresh_limits,
- .bdrv_get_info = vmdk_get_info,
+ .bdrv_co_get_info = vmdk_co_get_info,
.bdrv_gather_child_options = vmdk_gather_child_options,
.is_format = true,
diff --git a/block/vpc.c b/block/vpc.c
index 6ee95dcb96..cfdea7db80 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -598,7 +598,8 @@ fail:
return ret;
}
-static int vpc_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
+static int coroutine_fn
+vpc_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
BDRVVPCState *s = (BDRVVPCState *)bs->opaque;
@@ -1240,7 +1241,7 @@ static BlockDriver bdrv_vpc = {
.bdrv_co_pwritev = vpc_co_pwritev,
.bdrv_co_block_status = vpc_co_block_status,
- .bdrv_get_info = vpc_get_info,
+ .bdrv_co_get_info = vpc_co_get_info,
.is_format = true,
.create_opts = &vpc_create_opts,