[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 20/51] block-io: introduce coroutine_fn duplicates for bdrv_common
From: |
Kevin Wolf |
Subject: |
[PULL 20/51] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers |
Date: |
Wed, 14 Dec 2022 14:44:22 +0100 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
bdrv_common_block_status_above() is a g_c_w, and it is being called by
many "wrapper" functions like bdrv_is_allocated(),
bdrv_is_allocated_above() and bdrv_block_status_above().
Because we want to eventually split the coroutine from non-coroutine
case in g_c_w, create duplicate wrappers that take care of directly
calling the same coroutine functions called in the g_c_w.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru>
Message-Id: <20221128142337.657646-2-eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block-io.h | 15 +++++++++++
block/io.c | 58 +++++++++++++++++++++++++++++++++++++---
2 files changed, 70 insertions(+), 3 deletions(-)
diff --git a/include/block/block-io.h b/include/block/block-io.h
index 92aaa7c1e9..72919254cd 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -94,14 +94,29 @@ bool bdrv_can_write_zeroes_with_unmap(BlockDriverState *bs);
int bdrv_block_status(BlockDriverState *bs, int64_t offset,
int64_t bytes, int64_t *pnum, int64_t *map,
BlockDriverState **file);
+
+int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs,
+ BlockDriverState *base,
+ int64_t offset, int64_t bytes,
+ int64_t *pnum, int64_t *map,
+ BlockDriverState **file);
int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
int64_t offset, int64_t bytes, int64_t *pnum,
int64_t *map, BlockDriverState **file);
+
+int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t offset,
+ int64_t bytes, int64_t *pnum);
int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
int64_t *pnum);
+
+int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
+ BlockDriverState *base,
+ bool include_base, int64_t offset,
+ int64_t bytes, int64_t *pnum);
int bdrv_is_allocated_above(BlockDriverState *top, BlockDriverState *base,
bool include_base, int64_t offset, int64_t bytes,
int64_t *pnum);
+
int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset,
int64_t bytes);
diff --git a/block/io.c b/block/io.c
index 38e57d1f67..f4444b7777 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2533,6 +2533,17 @@ bdrv_co_common_block_status_above(BlockDriverState *bs,
return ret;
}
+int coroutine_fn bdrv_co_block_status_above(BlockDriverState *bs,
+ BlockDriverState *base,
+ int64_t offset, int64_t bytes,
+ int64_t *pnum, int64_t *map,
+ BlockDriverState **file)
+{
+ IO_CODE();
+ return bdrv_co_common_block_status_above(bs, base, false, true, offset,
+ bytes, pnum, map, file, NULL);
+}
+
int bdrv_block_status_above(BlockDriverState *bs, BlockDriverState *base,
int64_t offset, int64_t bytes, int64_t *pnum,
int64_t *map, BlockDriverState **file)
@@ -2578,6 +2589,22 @@ int coroutine_fn bdrv_co_is_zero_fast(BlockDriverState
*bs, int64_t offset,
return (pnum == bytes) && (ret & BDRV_BLOCK_ZERO);
}
+int coroutine_fn bdrv_co_is_allocated(BlockDriverState *bs, int64_t offset,
+ int64_t bytes, int64_t *pnum)
+{
+ int ret;
+ int64_t dummy;
+ IO_CODE();
+
+ ret = bdrv_co_common_block_status_above(bs, bs, true, false, offset,
+ bytes, pnum ? pnum : &dummy, NULL,
+ NULL, NULL);
+ if (ret < 0) {
+ return ret;
+ }
+ return !!(ret & BDRV_BLOCK_ALLOCATED);
+}
+
int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
int64_t *pnum)
{
@@ -2594,6 +2621,29 @@ int bdrv_is_allocated(BlockDriverState *bs, int64_t
offset, int64_t bytes,
return !!(ret & BDRV_BLOCK_ALLOCATED);
}
+/* See bdrv_is_allocated_above for documentation */
+int coroutine_fn bdrv_co_is_allocated_above(BlockDriverState *top,
+ BlockDriverState *base,
+ bool include_base, int64_t offset,
+ int64_t bytes, int64_t *pnum)
+{
+ int depth;
+ int ret;
+ IO_CODE();
+
+ ret = bdrv_co_common_block_status_above(top, base, include_base, false,
+ offset, bytes, pnum, NULL, NULL,
+ &depth);
+ if (ret < 0) {
+ return ret;
+ }
+
+ if (ret & BDRV_BLOCK_ALLOCATED) {
+ return depth;
+ }
+ return 0;
+}
+
/*
* Given an image chain: ... -> [BASE] -> [INTER1] -> [INTER2] -> [TOP]
*
@@ -2617,10 +2667,12 @@ int bdrv_is_allocated_above(BlockDriverState *top,
int64_t bytes, int64_t *pnum)
{
int depth;
- int ret = bdrv_common_block_status_above(top, base, include_base, false,
- offset, bytes, pnum, NULL, NULL,
- &depth);
+ int ret;
IO_CODE();
+
+ ret = bdrv_common_block_status_above(top, base, include_base, false,
+ offset, bytes, pnum, NULL, NULL,
+ &depth);
if (ret < 0) {
return ret;
}
--
2.38.1
- [PULL 04/51] block: refactor bdrv_list_refresh_perms to allow any list of nodes, (continued)
- [PULL 04/51] block: refactor bdrv_list_refresh_perms to allow any list of nodes, Kevin Wolf, 2022/12/14
- [PULL 12/51] block: Don't use subtree drains in bdrv_drop_intermediate(), Kevin Wolf, 2022/12/14
- [PULL 15/51] block: Call drain callbacks only once, Kevin Wolf, 2022/12/14
- [PULL 13/51] stream: Replace subtree drain with a single node drain, Kevin Wolf, 2022/12/14
- [PULL 19/51] block: Remove poll parameter from bdrv_parent_drained_begin_single(), Kevin Wolf, 2022/12/14
- [PULL 01/51] block: Inline bdrv_detach_child(), Kevin Wolf, 2022/12/14
- [PULL 10/51] block: Fix locking for bdrv_reopen_queue_child(), Kevin Wolf, 2022/12/14
- [PULL 09/51] block: Inline bdrv_drain_invoke(), Kevin Wolf, 2022/12/14
- [PULL 14/51] block: Remove subtree drains, Kevin Wolf, 2022/12/14
- [PULL 06/51] test-bdrv-drain: Don't yield in .bdrv_co_drained_begin/end(), Kevin Wolf, 2022/12/14
- [PULL 20/51] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers,
Kevin Wolf <=
- [PULL 23/51] block-backend: replace bdrv_*_above with blk_*_above, Kevin Wolf, 2022/12/14
- [PULL 16/51] block: Remove ignore_bds_parents parameter from drain_begin/end., Kevin Wolf, 2022/12/14
- [PULL 11/51] block: Drain individual nodes during reopen, Kevin Wolf, 2022/12/14
- [PULL 22/51] nbd/server.c: add coroutine_fn annotations, Kevin Wolf, 2022/12/14
- [PULL 18/51] block: Don't poll in bdrv_replace_child_noperm(), Kevin Wolf, 2022/12/14
- [PULL 21/51] block-copy: add coroutine_fn annotations, Kevin Wolf, 2022/12/14
- [PULL 17/51] block: Drop out of coroutine in bdrv_do_drained_begin_quiesce(), Kevin Wolf, 2022/12/14
- [PULL 29/51] block-coroutine-wrapper.py: introduce co_wrapper, Kevin Wolf, 2022/12/14
- [PULL 31/51] block-coroutine-wrapper.py: support also basic return types, Kevin Wolf, 2022/12/14
- [PULL 36/51] graph-lock: Implement guard macros, Kevin Wolf, 2022/12/14