aboutsummaryrefslogtreecommitdiff
path: root/block/qcow2.c
diff options
context:
space:
mode:
authorKevin Wolf <kwolf@redhat.com>2023-02-03 16:21:48 +0100
committerKevin Wolf <kwolf@redhat.com>2023-02-23 19:49:14 +0100
commitabaf8b750baef0337efb06c1d3465512b5d9b5dc (patch)
treebc0ba96a776aa07dcb7c1788de7d07009db3c215 /block/qcow2.c
parent9a5a1c621ed72161abcf461d46c7b7b7f97938bf (diff)
block: Mark bdrv_co_pwrite_zeroes() and callers GRAPH_RDLOCK
This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_pwrite_zeroes() need to hold a reader lock for the graph. For some places, we know that they will hold the lock, but we don't have the GRAPH_RDLOCK annotations yet. In this case, add assume_graph_lock() with a FIXME comment. These places will be removed once everything is properly annotated. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Message-Id: <20230203152202.49054-10-kwolf@redhat.com> Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/qcow2.c')
-rw-r--r--block/qcow2.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/block/qcow2.c b/block/qcow2.c
index e06ea7b5ff..89c3edbd61 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -2450,7 +2450,8 @@ static bool merge_cow(uint64_t offset, unsigned bytes,
* Return 1 if the COW regions read as zeroes, 0 if not, < 0 on error.
* Note that returning 0 does not guarantee non-zero data.
*/
-static int coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
+static int coroutine_fn GRAPH_RDLOCK
+is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
{
/*
* This check is designed for optimization shortcut so it must be
@@ -2468,8 +2469,8 @@ static int coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m)
m->cow_end.nb_bytes);
}
-static int coroutine_fn handle_alloc_space(BlockDriverState *bs,
- QCowL2Meta *l2meta)
+static int coroutine_fn GRAPH_RDLOCK
+handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta)
{
BDRVQcow2State *s = bs->opaque;
QCowL2Meta *m;
@@ -2532,12 +2533,10 @@ static int coroutine_fn handle_alloc_space(BlockDriverState *bs,
* l2meta - if not NULL, qcow2_co_pwritev_task() will consume it. Caller must
* not use it somehow after qcow2_co_pwritev_task() call
*/
-static coroutine_fn int qcow2_co_pwritev_task(BlockDriverState *bs,
- uint64_t host_offset,
- uint64_t offset, uint64_t bytes,
- QEMUIOVector *qiov,
- uint64_t qiov_offset,
- QCowL2Meta *l2meta)
+static coroutine_fn GRAPH_RDLOCK
+int qcow2_co_pwritev_task(BlockDriverState *bs, uint64_t host_offset,
+ uint64_t offset, uint64_t bytes, QEMUIOVector *qiov,
+ uint64_t qiov_offset, QCowL2Meta *l2meta)
{
int ret;
BDRVQcow2State *s = bs->opaque;
@@ -2603,7 +2602,11 @@ out_locked:
return ret;
}
-static coroutine_fn int qcow2_co_pwritev_task_entry(AioTask *task)
+/*
+ * This function can count as GRAPH_RDLOCK because qcow2_co_pwritev_part() holds
+ * the graph lock and keeps it until this coroutine has terminated.
+ */
+static coroutine_fn GRAPH_RDLOCK int qcow2_co_pwritev_task_entry(AioTask *task)
{
Qcow2AioTask *t = container_of(task, Qcow2AioTask, task);
@@ -2626,6 +2629,8 @@ static coroutine_fn int qcow2_co_pwritev_part(
QCowL2Meta *l2meta = NULL;
AioTaskPool *aio = NULL;
+ assume_graph_lock(); /* FIXME */
+
trace_qcow2_writev_start_req(qemu_coroutine_self(), offset, bytes);
while (bytes != 0 && aio_task_pool_status(aio) == 0) {
@@ -3974,8 +3979,9 @@ static bool is_zero(BlockDriverState *bs, int64_t offset, int64_t bytes)
return res >= 0 && (res & BDRV_BLOCK_ZERO) && bytes == 0;
}
-static coroutine_fn int qcow2_co_pwrite_zeroes(BlockDriverState *bs,
- int64_t offset, int64_t bytes, BdrvRequestFlags flags)
+static int coroutine_fn GRAPH_RDLOCK
+qcow2_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t bytes,
+ BdrvRequestFlags flags)
{
int ret;
BDRVQcow2State *s = bs->opaque;