aboutsummaryrefslogtreecommitdiff
path: root/block.c
diff options
context:
space:
mode:
authorEmanuele Giuseppe Esposito <eesposit@redhat.com>2022-03-03 10:15:50 -0500
committerKevin Wolf <kwolf@redhat.com>2022-03-04 18:18:25 +0100
commit384a48fb7423dfb303023eb504e1fc5e6acb4de4 (patch)
treea7f9e95f94e2e4c1d9fd0b1ac73a9b855295c87b /block.c
parentf791bf7f93f25f771b4423faa2694b514c5d26c7 (diff)
IO_CODE and IO_OR_GS_CODE for block I/O API
Mark all I/O functions with IO_CODE, and all "I/O OR GS" with IO_OR_GS_CODE. Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Message-Id: <20220303151616.325444-6-eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block.c')
-rw-r--r--block.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/block.c b/block.c
index ed1026e4d8..fd3f565a16 100644
--- a/block.c
+++ b/block.c
@@ -137,6 +137,7 @@ size_t bdrv_opt_mem_align(BlockDriverState *bs)
/* page size or 4k (hdd sector size) should be on the safe side */
return MAX(4096, qemu_real_host_page_size);
}
+ IO_CODE();
return bs->bl.opt_mem_alignment;
}
@@ -147,6 +148,7 @@ size_t bdrv_min_mem_align(BlockDriverState *bs)
/* page size or 4k (hdd sector size) should be on the safe side */
return MAX(4096, qemu_real_host_page_size);
}
+ IO_CODE();
return bs->bl.min_mem_alignment;
}
@@ -272,12 +274,15 @@ void bdrv_parse_filename_strip_prefix(const char *filename, const char *prefix,
* image is inactivated. */
bool bdrv_is_read_only(BlockDriverState *bs)
{
+ IO_CODE();
return !(bs->open_flags & BDRV_O_RDWR);
}
int bdrv_can_set_read_only(BlockDriverState *bs, bool read_only,
bool ignore_allow_rdw, Error **errp)
{
+ IO_CODE();
+
/* Do not set read_only if copy_on_read is enabled */
if (bs->copy_on_read && read_only) {
error_setg(errp, "Can't set node '%s' to r/o with copy-on-read enabled",
@@ -311,6 +316,7 @@ int bdrv_apply_auto_read_only(BlockDriverState *bs, const char *errmsg,
Error **errp)
{
int ret = 0;
+ IO_CODE();
if (!(bs->open_flags & BDRV_O_RDWR)) {
return 0;
@@ -757,6 +763,7 @@ int coroutine_fn bdrv_co_delete_file(BlockDriverState *bs, Error **errp)
Error *local_err = NULL;
int ret;
+ IO_CODE();
assert(bs != NULL);
if (!bs->drv) {
@@ -782,6 +789,7 @@ void coroutine_fn bdrv_co_delete_file_noerr(BlockDriverState *bs)
{
Error *local_err = NULL;
int ret;
+ IO_CODE();
if (!bs) {
return;
@@ -1442,6 +1450,7 @@ static int bdrv_child_cb_update_filename(BdrvChild *c, BlockDriverState *base,
AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c)
{
BlockDriverState *bs = c->opaque;
+ IO_CODE();
return bdrv_get_aio_context(bs);
}
@@ -1464,6 +1473,7 @@ const BdrvChildClass child_of_bds = {
AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c)
{
+ IO_CODE();
return c->klass->get_parent_aio_context(c);
}
@@ -2077,6 +2087,7 @@ static bool bdrv_is_writable_after_reopen(BlockDriverState *bs,
*/
bool bdrv_is_writable(BlockDriverState *bs)
{
+ IO_CODE();
return bdrv_is_writable_after_reopen(bs, NULL);
}
@@ -5706,6 +5717,8 @@ static int64_t bdrv_sum_allocated_file_size(BlockDriverState *bs)
int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
+
if (!drv) {
return -ENOMEDIUM;
}
@@ -5755,6 +5768,7 @@ int64_t bdrv_get_allocated_file_size(BlockDriverState *bs)
BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
BlockDriverState *in_bs, Error **errp)
{
+ IO_CODE();
if (!drv->bdrv_measure) {
error_setg(errp, "Block driver '%s' does not support size measurement",
drv->format_name);
@@ -5770,6 +5784,7 @@ BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts,
int64_t bdrv_nb_sectors(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
if (!drv)
return -ENOMEDIUM;
@@ -5790,6 +5805,7 @@ int64_t bdrv_nb_sectors(BlockDriverState *bs)
int64_t bdrv_getlength(BlockDriverState *bs)
{
int64_t ret = bdrv_nb_sectors(bs);
+ IO_CODE();
if (ret < 0) {
return ret;
@@ -5804,12 +5820,14 @@ int64_t bdrv_getlength(BlockDriverState *bs)
void bdrv_get_geometry(BlockDriverState *bs, uint64_t *nb_sectors_ptr)
{
int64_t nb_sectors = bdrv_nb_sectors(bs);
+ IO_CODE();
*nb_sectors_ptr = nb_sectors < 0 ? 0 : nb_sectors;
}
bool bdrv_is_sg(BlockDriverState *bs)
{
+ IO_CODE();
return bs->sg;
}
@@ -5819,6 +5837,7 @@ bool bdrv_is_sg(BlockDriverState *bs)
bool bdrv_supports_compressed_writes(BlockDriverState *bs)
{
BlockDriverState *filtered;
+ IO_CODE();
if (!bs->drv || !block_driver_can_compress(bs->drv)) {
return false;
@@ -5838,6 +5857,7 @@ bool bdrv_supports_compressed_writes(BlockDriverState *bs)
const char *bdrv_get_format_name(BlockDriverState *bs)
{
+ IO_CODE();
return bs->drv ? bs->drv->format_name : NULL;
}
@@ -6146,6 +6166,7 @@ BlockDriverState *bdrv_next_all_states(BlockDriverState *bs)
const char *bdrv_get_node_name(const BlockDriverState *bs)
{
+ IO_CODE();
return bs->node_name;
}
@@ -6170,6 +6191,7 @@ const char *bdrv_get_parent_name(const BlockDriverState *bs)
/* TODO check what callers really want: bs->node_name or blk_name() */
const char *bdrv_get_device_name(const BlockDriverState *bs)
{
+ IO_CODE();
return bdrv_get_parent_name(bs) ?: "";
}
@@ -6179,6 +6201,7 @@ const char *bdrv_get_device_name(const BlockDriverState *bs)
* absent, then this returns an empty (non-null) string. */
const char *bdrv_get_device_or_node_name(const BlockDriverState *bs)
{
+ IO_CODE();
return bdrv_get_parent_name(bs) ?: bs->node_name;
}
@@ -6223,6 +6246,7 @@ int bdrv_has_zero_init(BlockDriverState *bs)
bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
{
+ IO_CODE();
if (!(bs->open_flags & BDRV_O_UNMAP)) {
return false;
}
@@ -6233,6 +6257,7 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs)
void bdrv_get_backing_filename(BlockDriverState *bs,
char *filename, int filename_size)
{
+ IO_CODE();
pstrcpy(filename, filename_size, bs->backing_file);
}
@@ -6240,6 +6265,7 @@ int bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
{
int ret;
BlockDriver *drv = bs->drv;
+ IO_CODE();
/* if bs->drv == NULL, bs is closed, so there's nothing to do here */
if (!drv) {
return -ENOMEDIUM;
@@ -6268,6 +6294,7 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
Error **errp)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
if (drv && drv->bdrv_get_specific_info) {
return drv->bdrv_get_specific_info(bs, errp);
}
@@ -6277,6 +6304,7 @@ ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs,
BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
if (!drv || !drv->bdrv_get_specific_stats) {
return NULL;
}
@@ -6285,6 +6313,7 @@ BlockStatsSpecific *bdrv_get_specific_stats(BlockDriverState *bs)
void bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event)
{
+ IO_CODE();
if (!bs || !bs->drv || !bs->drv->bdrv_debug_event) {
return;
}
@@ -6727,6 +6756,7 @@ bool bdrv_is_inserted(BlockDriverState *bs)
{
BlockDriver *drv = bs->drv;
BdrvChild *child;
+ IO_CODE();
if (!drv) {
return false;
@@ -6748,6 +6778,7 @@ bool bdrv_is_inserted(BlockDriverState *bs)
void bdrv_eject(BlockDriverState *bs, bool eject_flag)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
if (drv && drv->bdrv_eject) {
drv->bdrv_eject(bs, eject_flag);
@@ -6761,7 +6792,7 @@ void bdrv_eject(BlockDriverState *bs, bool eject_flag)
void bdrv_lock_medium(BlockDriverState *bs, bool locked)
{
BlockDriver *drv = bs->drv;
-
+ IO_CODE();
trace_bdrv_lock_medium(bs, locked);
if (drv && drv->bdrv_lock_medium) {
@@ -7057,6 +7088,7 @@ out:
AioContext *bdrv_get_aio_context(BlockDriverState *bs)
{
+ IO_CODE();
return bs ? bs->aio_context : qemu_get_aio_context();
}
@@ -7065,6 +7097,7 @@ AioContext *coroutine_fn bdrv_co_enter(BlockDriverState *bs)
Coroutine *self = qemu_coroutine_self();
AioContext *old_ctx = qemu_coroutine_get_aio_context(self);
AioContext *new_ctx;
+ IO_CODE();
/*
* Increase bs->in_flight to ensure that this operation is completed before
@@ -7079,6 +7112,7 @@ AioContext *coroutine_fn bdrv_co_enter(BlockDriverState *bs)
void coroutine_fn bdrv_co_leave(BlockDriverState *bs, AioContext *old_ctx)
{
+ IO_CODE();
aio_co_reschedule_self(old_ctx);
bdrv_dec_in_flight(bs);
}
@@ -7112,6 +7146,7 @@ void coroutine_fn bdrv_co_unlock(BlockDriverState *bs)
void bdrv_coroutine_enter(BlockDriverState *bs, Coroutine *co)
{
+ IO_CODE();
aio_co_enter(bdrv_get_aio_context(bs), co);
}