[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 15/23] block: Mark preadv_snapshot/snapshot_block_status GRAPH_RD
From: |
Kevin Wolf |
Subject: |
[PATCH 15/23] block: Mark preadv_snapshot/snapshot_block_status GRAPH_RDLOCK |
Date: |
Fri, 3 Feb 2023 16:21:54 +0100 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block_int-common.h | 12 +++++++-----
include/block/block_int-io.h | 8 ++++----
block/copy-before-write.c | 6 ++----
block/io.c | 2 ++
block/snapshot-access.c | 4 ++--
5 files changed, 17 insertions(+), 15 deletions(-)
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 29b230cc0b..7d8309ba5a 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -624,11 +624,13 @@ struct BlockDriver {
* - receive the snapshot's actual length (which may differ from bs's
* length)
*/
- int coroutine_fn (*bdrv_co_preadv_snapshot)(BlockDriverState *bs,
- int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset);
- int coroutine_fn (*bdrv_co_snapshot_block_status)(BlockDriverState *bs,
- bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
- int64_t *map, BlockDriverState **file);
+ int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_preadv_snapshot)(
+ BlockDriverState *bs, int64_t offset, int64_t bytes,
+ QEMUIOVector *qiov, size_t qiov_offset);
+
+ int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_snapshot_block_status)(
+ BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
+ int64_t *pnum, int64_t *map, BlockDriverState **file);
int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_pdiscard_snapshot)(
BlockDriverState *bs, int64_t offset, int64_t bytes);
diff --git a/include/block/block_int-io.h b/include/block/block_int-io.h
index 5788bd66ba..612e5ddf99 100644
--- a/include/block/block_int-io.h
+++ b/include/block/block_int-io.h
@@ -35,11 +35,11 @@
* the I/O API.
*/
-int coroutine_fn bdrv_co_preadv_snapshot(BdrvChild *child,
+int coroutine_fn GRAPH_RDLOCK bdrv_co_preadv_snapshot(BdrvChild *child,
int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset);
-int coroutine_fn bdrv_co_snapshot_block_status(BlockDriverState *bs,
- bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum,
- int64_t *map, BlockDriverState **file);
+int coroutine_fn GRAPH_RDLOCK bdrv_co_snapshot_block_status(
+ BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes,
+ int64_t *pnum, int64_t *map, BlockDriverState **file);
int coroutine_fn GRAPH_RDLOCK bdrv_co_pdiscard_snapshot(BlockDriverState *bs,
int64_t offset, int64_t bytes);
diff --git a/block/copy-before-write.c b/block/copy-before-write.c
index e223e37300..646d8227a4 100644
--- a/block/copy-before-write.c
+++ b/block/copy-before-write.c
@@ -256,7 +256,7 @@ cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq
*req)
g_free(req);
}
-static coroutine_fn int
+static int coroutine_fn GRAPH_RDLOCK
cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset)
{
@@ -264,8 +264,6 @@ cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t
offset, int64_t bytes,
BdrvChild *file;
int ret;
- assume_graph_lock(); /* FIXME */
-
/* TODO: upgrade to async loop using AioTask */
while (bytes) {
int64_t cur_bytes;
@@ -290,7 +288,7 @@ cbw_co_preadv_snapshot(BlockDriverState *bs, int64_t
offset, int64_t bytes,
return 0;
}
-static int coroutine_fn
+static int coroutine_fn GRAPH_RDLOCK
cbw_co_snapshot_block_status(BlockDriverState *bs,
bool want_zero, int64_t offset, int64_t bytes,
int64_t *pnum, int64_t *map,
diff --git a/block/io.c b/block/io.c
index b060561929..af9a0cc964 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3529,6 +3529,7 @@ bdrv_co_preadv_snapshot(BdrvChild *child, int64_t offset,
int64_t bytes,
BlockDriver *drv = bs->drv;
int ret;
IO_CODE();
+ assert_bdrv_graph_readable();
if (!drv) {
return -ENOMEDIUM;
@@ -3554,6 +3555,7 @@ bdrv_co_snapshot_block_status(BlockDriverState *bs,
BlockDriver *drv = bs->drv;
int ret;
IO_CODE();
+ assert_bdrv_graph_readable();
if (!drv) {
return -ENOMEDIUM;
diff --git a/block/snapshot-access.c b/block/snapshot-access.c
index 009cc4aea0..67ea339da9 100644
--- a/block/snapshot-access.c
+++ b/block/snapshot-access.c
@@ -26,7 +26,7 @@
#include "qemu/cutils.h"
#include "block/block_int.h"
-static coroutine_fn int
+static int coroutine_fn GRAPH_RDLOCK
snapshot_access_co_preadv_part(BlockDriverState *bs,
int64_t offset, int64_t bytes,
QEMUIOVector *qiov, size_t qiov_offset,
@@ -39,7 +39,7 @@ snapshot_access_co_preadv_part(BlockDriverState *bs,
return bdrv_co_preadv_snapshot(bs->file, offset, bytes, qiov, qiov_offset);
}
-static int coroutine_fn
+static int coroutine_fn GRAPH_RDLOCK
snapshot_access_co_block_status(BlockDriverState *bs,
bool want_zero, int64_t offset,
int64_t bytes, int64_t *pnum,
--
2.38.1
- [PATCH 02/23] mirror: Fix access of uninitialised fields during start, (continued)
- [PATCH 02/23] mirror: Fix access of uninitialised fields during start, Kevin Wolf, 2023/02/03
- [PATCH 05/23] block: Mark bdrv_co_ioctl() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 08/23] block: Mark bdrv_co_pdiscard() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 09/23] block: Mark bdrv_co_pwrite_zeroes() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 10/23] block: Mark read/write in block/io.c GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 12/23] block: Mark bdrv_co_pwrite_sync() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 07/23] block: Mark bdrv_co_flush() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 11/23] block: Mark public read/write functions GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 13/23] block: Mark bdrv_co_do_pwrite_zeroes() GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 15/23] block: Mark preadv_snapshot/snapshot_block_status GRAPH_RDLOCK,
Kevin Wolf <=
- [PATCH 14/23] block: Mark bdrv_co_copy_range() GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 17/23] block: Mark bdrv_co_io_(un)plug() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 18/23] block: Mark bdrv_co_is_inserted() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 16/23] block: Mark bdrv_co_create() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 19/23] block: Mark bdrv_co_eject/lock_medium() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 20/23] block: Mark bdrv_(un)register_buf() GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 21/23] block: Mark bdrv_co_delete_file() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 22/23] block: Mark bdrv_*_dirty_bitmap() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- [PATCH 23/23] block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/03
- Re: [PATCH 00/23] block: Lock the graph, part 2 (BlockDriver callbacks), Emanuele Giuseppe Esposito, 2023/02/17