[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] block: switch to co_wrapper for bdrv_is_allocated_*
From: |
Paolo Bonzini |
Subject: |
[PATCH 3/4] block: switch to co_wrapper for bdrv_is_allocated_* |
Date: |
Wed, 5 Apr 2023 12:32:15 +0200 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
block/io.c | 53 ++++++----------------------------------
include/block/block-io.h | 12 +++++----
2 files changed, 14 insertions(+), 51 deletions(-)
diff --git a/block/io.c b/block/io.c
index 0aad0f57d8c7..cacde79a3e98 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2623,45 +2623,6 @@ int coroutine_fn bdrv_co_is_allocated(BlockDriverState
*bs, int64_t offset,
return !!(ret & BDRV_BLOCK_ALLOCATED);
}
-int bdrv_is_allocated(BlockDriverState *bs, int64_t offset, int64_t bytes,
- int64_t *pnum)
-{
- int ret;
- int64_t dummy;
- IO_CODE();
-
- ret = bdrv_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);
-}
-
-/* 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]
*
@@ -2679,18 +2640,18 @@ int coroutine_fn
bdrv_co_is_allocated_above(BlockDriverState *top,
* words, the result is not necessarily the maximum possible range);
* but 'pnum' will only be 0 when end of file is reached.
*/
-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_allocated_above(BlockDriverState *bs,
+ BlockDriverState *base,
+ bool include_base, int64_t offset,
+ int64_t bytes, int64_t *pnum)
{
int depth;
int ret;
IO_CODE();
- ret = bdrv_common_block_status_above(top, base, include_base, false,
- offset, bytes, pnum, NULL, NULL,
- &depth);
+ ret = bdrv_co_common_block_status_above(bs, base, include_base, false,
+ offset, bytes, pnum, NULL, NULL,
+ &depth);
if (ret < 0) {
return ret;
}
diff --git a/include/block/block-io.h b/include/block/block-io.h
index 0947f83d9ac7..9e179861895c 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -134,16 +134,18 @@ bdrv_block_status_above(BlockDriverState *bs,
BlockDriverState *base,
int coroutine_fn GRAPH_RDLOCK
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 co_wrapper_mixed_bdrv_rdlock
+bdrv_is_allocated(BlockDriverState *bs, int64_t offset,
+ int64_t bytes, int64_t *pnum);
int coroutine_fn GRAPH_RDLOCK
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 co_wrapper_mixed_bdrv_rdlock
+bdrv_is_allocated_above(BlockDriverState *bs, BlockDriverState *base,
+ bool include_base, int64_t offset,
+ int64_t bytes, int64_t *pnum);
int coroutine_fn GRAPH_RDLOCK
bdrv_co_is_zero_fast(BlockDriverState *bs, int64_t offset, int64_t bytes);
--
2.39.2
- [PATCH 0/4] block: clean up coroutine versions of bdrv_{is_allocated, block_status}*, Paolo Bonzini, 2023/04/05
- [PATCH 1/4] block: rename the bdrv_co_block_status static function, Paolo Bonzini, 2023/04/05
- [PATCH 2/4] block: complete public block status API, Paolo Bonzini, 2023/04/05
- [PATCH 3/4] block: switch to co_wrapper for bdrv_is_allocated_*,
Paolo Bonzini <=
- [PATCH 4/4] block: convert more bdrv_is_allocated* and bdrv_block_status* calls to coroutine versions, Paolo Bonzini, 2023/04/05
- Re: [PATCH 0/4] block: clean up coroutine versions of bdrv_{is_allocated, block_status}*, Paolo Bonzini, 2023/04/21