[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v7 13/31] IO_CODE and IO_OR_GS_CODE for block_int I/O API
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v7 13/31] IO_CODE and IO_OR_GS_CODE for block_int I/O API |
Date: |
Fri, 11 Feb 2022 09:51:35 -0500 |
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>
---
block.c | 14 +++++++++++++-
block/block-backend.c | 2 ++
block/dirty-bitmap.c | 3 +++
block/io.c | 13 +++++++++++++
include/block/block_int-io.h | 6 ++++++
5 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 1fee5e41e8..496d2989d7 100644
--- a/block.c
+++ b/block.c
@@ -999,6 +999,7 @@ BlockDriver *bdrv_probe_all(const uint8_t *buf, int
buf_size,
{
int score_max = 0, score;
BlockDriver *drv = NULL, *d;
+ IO_CODE();
QLIST_FOREACH(d, &bdrv_drivers, list) {
if (d->bdrv_probe) {
@@ -1051,6 +1052,7 @@ static int find_image_format(BlockBackend *file, const
char *filename,
int refresh_total_sectors(BlockDriverState *bs, int64_t hint)
{
BlockDriver *drv = bs->drv;
+ IO_CODE();
if (!drv) {
return -ENOMEDIUM;
@@ -6195,6 +6197,7 @@ const char *bdrv_get_parent_name(const BlockDriverState
*bs)
{
BdrvChild *c;
const char *name;
+ IO_CODE();
/* If multiple parents have a name, just pick the first one. */
QLIST_FOREACH(c, &bs->parents, next_parent) {
@@ -7931,6 +7934,8 @@ int bdrv_make_empty(BdrvChild *c, Error **errp)
*/
BdrvChild *bdrv_cow_child(BlockDriverState *bs)
{
+ IO_CODE();
+
if (!bs || !bs->drv) {
return NULL;
}
@@ -7954,6 +7959,7 @@ BdrvChild *bdrv_cow_child(BlockDriverState *bs)
BdrvChild *bdrv_filter_child(BlockDriverState *bs)
{
BdrvChild *c;
+ IO_CODE();
if (!bs || !bs->drv) {
return NULL;
@@ -7985,6 +7991,7 @@ BdrvChild *bdrv_filter_or_cow_child(BlockDriverState *bs)
{
BdrvChild *cow_child = bdrv_cow_child(bs);
BdrvChild *filter_child = bdrv_filter_child(bs);
+ IO_CODE();
/* Filter nodes cannot have COW backing files */
assert(!(cow_child && filter_child));
@@ -8005,6 +8012,7 @@ BdrvChild *bdrv_filter_or_cow_child(BlockDriverState *bs)
BdrvChild *bdrv_primary_child(BlockDriverState *bs)
{
BdrvChild *c, *found = NULL;
+ IO_CODE();
QLIST_FOREACH(c, &bs->children, next) {
if (c->role & BDRV_CHILD_PRIMARY) {
@@ -8067,6 +8075,7 @@ BlockDriverState
*bdrv_skip_implicit_filters(BlockDriverState *bs)
*/
BlockDriverState *bdrv_skip_filters(BlockDriverState *bs)
{
+ IO_CODE();
return bdrv_do_skip_filters(bs, false);
}
@@ -8076,6 +8085,7 @@ BlockDriverState *bdrv_skip_filters(BlockDriverState *bs)
*/
BlockDriverState *bdrv_backing_chain_next(BlockDriverState *bs)
{
+ IO_CODE();
return bdrv_skip_filters(bdrv_cow_bs(bdrv_skip_filters(bs)));
}
@@ -8111,8 +8121,8 @@ static bool
bdrv_bsc_range_overlaps_locked(BlockDriverState *bs,
*/
bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t offset, int64_t *pnum)
{
+ IO_CODE();
RCU_READ_LOCK_GUARD();
-
return bdrv_bsc_range_overlaps_locked(bs, offset, 1, pnum);
}
@@ -8122,6 +8132,7 @@ bool bdrv_bsc_is_data(BlockDriverState *bs, int64_t
offset, int64_t *pnum)
void bdrv_bsc_invalidate_range(BlockDriverState *bs,
int64_t offset, int64_t bytes)
{
+ IO_CODE();
RCU_READ_LOCK_GUARD();
if (bdrv_bsc_range_overlaps_locked(bs, offset, bytes, NULL)) {
@@ -8136,6 +8147,7 @@ void bdrv_bsc_fill(BlockDriverState *bs, int64_t offset,
int64_t bytes)
{
BdrvBlockStatusCache *new_bsc = g_new(BdrvBlockStatusCache, 1);
BdrvBlockStatusCache *old_bsc;
+ IO_CODE();
*new_bsc = (BdrvBlockStatusCache) {
.valid = true,
diff --git a/block/block-backend.c b/block/block-backend.c
index 292481069f..d3dc13809f 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1115,6 +1115,7 @@ bool blk_dev_has_removable_media(BlockBackend *blk)
*/
bool blk_dev_has_tray(BlockBackend *blk)
{
+ IO_CODE();
return blk->dev_ops && blk->dev_ops->is_tray_open;
}
@@ -1135,6 +1136,7 @@ void blk_dev_eject_request(BlockBackend *blk, bool force)
*/
bool blk_dev_is_tray_open(BlockBackend *blk)
{
+ IO_CODE();
if (blk_dev_has_tray(blk)) {
return blk->dev_ops->is_tray_open(blk->dev_opaque);
}
diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c
index e2a1648deb..0334b85805 100644
--- a/block/dirty-bitmap.c
+++ b/block/dirty-bitmap.c
@@ -657,6 +657,7 @@ void bdrv_reset_dirty_bitmap(BdrvDirtyBitmap *bitmap,
void bdrv_clear_dirty_bitmap(BdrvDirtyBitmap *bitmap, HBitmap **out)
{
+ IO_CODE();
assert(!bdrv_dirty_bitmap_readonly(bitmap));
bdrv_dirty_bitmaps_lock(bitmap->bs);
if (!out) {
@@ -739,6 +740,7 @@ void bdrv_dirty_bitmap_deserialize_finish(BdrvDirtyBitmap
*bitmap)
void bdrv_set_dirty(BlockDriverState *bs, int64_t offset, int64_t bytes)
{
BdrvDirtyBitmap *bitmap;
+ IO_CODE();
if (QLIST_EMPTY(&bs->dirty_bitmaps)) {
return;
@@ -930,6 +932,7 @@ bool bdrv_dirty_bitmap_merge_internal(BdrvDirtyBitmap *dest,
bool lock)
{
bool ret;
+ IO_CODE();
assert(!bdrv_dirty_bitmap_readonly(dest));
assert(!bdrv_dirty_bitmap_inconsistent(dest));
diff --git a/block/io.c b/block/io.c
index 680bc8cc6d..d304774d11 100644
--- a/block/io.c
+++ b/block/io.c
@@ -570,6 +570,7 @@ void bdrv_subtree_drained_end(BlockDriverState *bs)
void bdrv_apply_subtree_drain(BdrvChild *child, BlockDriverState *new_parent)
{
int i;
+ IO_OR_GS_CODE();
for (i = 0; i < new_parent->recursive_quiesce_counter; i++) {
bdrv_do_drained_begin(child->bs, true, child, false, true);
@@ -580,6 +581,7 @@ void bdrv_unapply_subtree_drain(BdrvChild *child,
BlockDriverState *old_parent)
{
int drained_end_counter = 0;
int i;
+ IO_OR_GS_CODE();
for (i = 0; i < old_parent->recursive_quiesce_counter; i++) {
bdrv_do_drained_end(child->bs, true, child, false,
@@ -887,6 +889,7 @@ BdrvTrackedRequest *coroutine_fn
bdrv_co_get_self_request(BlockDriverState *bs)
{
BdrvTrackedRequest *req;
Coroutine *self = qemu_coroutine_self();
+ IO_CODE();
QLIST_FOREACH(req, &bs->tracked_requests, list) {
if (req->co == self) {
@@ -932,16 +935,19 @@ static int bdrv_get_cluster_size(BlockDriverState *bs)
void bdrv_inc_in_flight(BlockDriverState *bs)
{
+ IO_CODE();
qatomic_inc(&bs->in_flight);
}
void bdrv_wakeup(BlockDriverState *bs)
{
+ IO_CODE();
aio_wait_kick();
}
void bdrv_dec_in_flight(BlockDriverState *bs)
{
+ IO_CODE();
qatomic_dec(&bs->in_flight);
bdrv_wakeup(bs);
}
@@ -966,6 +972,7 @@ bool coroutine_fn
bdrv_make_request_serialising(BdrvTrackedRequest *req,
uint64_t align)
{
bool waited;
+ IO_CODE();
qemu_co_mutex_lock(&req->bs->reqs_lock);
@@ -1822,6 +1829,7 @@ int coroutine_fn bdrv_co_preadv(BdrvChild *child,
int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
+ IO_CODE();
return bdrv_co_preadv_part(child, offset, bytes, qiov, 0, flags);
}
@@ -1834,6 +1842,7 @@ int coroutine_fn bdrv_co_preadv_part(BdrvChild *child,
BdrvTrackedRequest req;
BdrvRequestPadding pad;
int ret;
+ IO_CODE();
trace_bdrv_co_preadv_part(bs, offset, bytes, flags);
@@ -2255,6 +2264,7 @@ int coroutine_fn bdrv_co_pwritev(BdrvChild *child,
int64_t offset, int64_t bytes, QEMUIOVector *qiov,
BdrvRequestFlags flags)
{
+ IO_CODE();
return bdrv_co_pwritev_part(child, offset, bytes, qiov, 0, flags);
}
@@ -2268,6 +2278,7 @@ int coroutine_fn bdrv_co_pwritev_part(BdrvChild *child,
BdrvRequestPadding pad;
int ret;
bool padded = false;
+ IO_CODE();
trace_bdrv_co_pwritev_part(child->bs, offset, bytes, flags);
@@ -3451,6 +3462,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *src,
int64_t src_offset,
BdrvRequestFlags read_flags,
BdrvRequestFlags write_flags)
{
+ IO_CODE();
trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes,
read_flags, write_flags);
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
@@ -3467,6 +3479,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src,
int64_t src_offset,
BdrvRequestFlags read_flags,
BdrvRequestFlags write_flags)
{
+ IO_CODE();
trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes,
read_flags, write_flags);
return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset,
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 677b8b49f4..3da5f01c42 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -50,6 +50,7 @@ static inline int coroutine_fn bdrv_co_pread(BdrvChild *child,
int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags)
{
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
+ IO_CODE();
return bdrv_co_preadv(child, offset, bytes, &qiov, flags);
}
@@ -58,6 +59,7 @@ static inline int coroutine_fn bdrv_co_pwrite(BdrvChild
*child,
int64_t offset, unsigned int bytes, void *buf, BdrvRequestFlags flags)
{
QEMUIOVector qiov = QEMU_IOVEC_INIT_BUF(qiov, buf, bytes);
+ IO_CODE();
return bdrv_co_pwritev(child, offset, bytes, &qiov, flags);
}
@@ -120,21 +122,25 @@ BlockDriverState
*bdrv_backing_chain_next(BlockDriverState *bs);
static inline BlockDriverState *bdrv_cow_bs(BlockDriverState *bs)
{
+ IO_CODE();
return child_bs(bdrv_cow_child(bs));
}
static inline BlockDriverState *bdrv_filter_bs(BlockDriverState *bs)
{
+ IO_CODE();
return child_bs(bdrv_filter_child(bs));
}
static inline BlockDriverState *bdrv_filter_or_cow_bs(BlockDriverState *bs)
{
+ IO_CODE();
return child_bs(bdrv_filter_or_cow_child(bs));
}
static inline BlockDriverState *bdrv_primary_bs(BlockDriverState *bs)
{
+ IO_CODE();
return child_bs(bdrv_primary_child(bs));
}
--
2.31.1
- [PATCH v7 02/31] main loop: macros to mark GS and I/O functions, (continued)
- [PATCH v7 02/31] main loop: macros to mark GS and I/O functions, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 12/31] assertions for block_int global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 15/31] include/block/blockjob_int.h: split header into I/O and GS API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 16/31] GS and IO CODE macros for blockjob_int.h, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 10/31] block.c: assertions to the block layer permissions API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 07/31] include/sysemu/block-backend: split header into I/O and global state (GS) API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 06/31] block/export/fuse.c: allow writable exports to take RESIZE permission, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 04/31] assertions for block global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 08/31] block/block-backend.c: assertions for block-backend, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 05/31] IO_CODE and IO_OR_GS_CODE for block I/O API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 13/31] IO_CODE and IO_OR_GS_CODE for block_int I/O API,
Emanuele Giuseppe Esposito <=
- [PATCH v7 20/31] include/sysemu/blockdev.h: global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 21/31] assertions for blockdev.h global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 26/31] block_int-common.h: assertions in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 09/31] IO_CODE and IO_OR_GS_CODE for block-backend I/O API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 18/31] include/block/blockjob.h: global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 11/31] include/block/block_int: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 03/31] include/block/block: split header into I/O and global state API, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 17/31] block.c: add assertions to static functions, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 14/31] block: introduce assert_bdrv_graph_writable, Emanuele Giuseppe Esposito, 2022/02/11
- [PATCH v7 19/31] assertions for blockjob.h global state API, Emanuele Giuseppe Esposito, 2022/02/11