IO_CODE and IO_OR_GS_CODE for block_int 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-14-eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
b4ad82aab1
commit
967d7905d1
14
block.c
14
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;
|
||||
@ -6197,6 +6199,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) {
|
||||
@ -7933,6 +7936,8 @@ int bdrv_make_empty(BdrvChild *c, Error **errp)
|
||||
*/
|
||||
BdrvChild *bdrv_cow_child(BlockDriverState *bs)
|
||||
{
|
||||
IO_CODE();
|
||||
|
||||
if (!bs || !bs->drv) {
|
||||
return NULL;
|
||||
}
|
||||
@ -7956,6 +7961,7 @@ BdrvChild *bdrv_cow_child(BlockDriverState *bs)
|
||||
BdrvChild *bdrv_filter_child(BlockDriverState *bs)
|
||||
{
|
||||
BdrvChild *c;
|
||||
IO_CODE();
|
||||
|
||||
if (!bs || !bs->drv) {
|
||||
return NULL;
|
||||
@ -7987,6 +7993,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));
|
||||
@ -8007,6 +8014,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) {
|
||||
@ -8069,6 +8077,7 @@ BlockDriverState *bdrv_skip_implicit_filters(BlockDriverState *bs)
|
||||
*/
|
||||
BlockDriverState *bdrv_skip_filters(BlockDriverState *bs)
|
||||
{
|
||||
IO_CODE();
|
||||
return bdrv_do_skip_filters(bs, false);
|
||||
}
|
||||
|
||||
@ -8078,6 +8087,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)));
|
||||
}
|
||||
|
||||
@ -8113,8 +8123,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);
|
||||
}
|
||||
|
||||
@ -8124,6 +8134,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)) {
|
||||
@ -8138,6 +8149,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,
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
|
13
block/io.c
13
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,
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user