[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/29] block: Mark bdrv_co_io_(un)plug() and callers GRAPH_RDLOCK
From: |
Kevin Wolf |
Subject: |
[PULL 17/29] block: Mark bdrv_co_io_(un)plug() and callers GRAPH_RDLOCK |
Date: |
Thu, 23 Feb 2023 19:51:34 +0100 |
This adds GRAPH_RDLOCK annotations to declare that callers of
bdrv_co_io_plug() and bdrv_co_io_unplug() need to hold a reader lock for
the graph.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20230203152202.49054-18-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block-io.h | 4 ++--
include/block/block_int-common.h | 5 +++--
block/block-backend.c | 2 ++
block/io.c | 2 ++
4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/include/block/block-io.h b/include/block/block-io.h
index c551742a86..b8f99741a3 100644
--- a/include/block/block-io.h
+++ b/include/block/block-io.h
@@ -233,8 +233,8 @@ void coroutine_fn bdrv_co_leave(BlockDriverState *bs,
AioContext *old_ctx);
AioContext *child_of_bds_get_parent_aio_context(BdrvChild *c);
-void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs);
-void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs);
+void coroutine_fn GRAPH_RDLOCK bdrv_co_io_plug(BlockDriverState *bs);
+void coroutine_fn GRAPH_RDLOCK bdrv_co_io_unplug(BlockDriverState *bs);
bool coroutine_fn bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs,
const char *name,
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index 6b8fd22c71..61f894bcf6 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -735,8 +735,9 @@ struct BlockDriver {
BlkdebugEvent event);
/* io queue for linux-aio */
- void coroutine_fn (*bdrv_co_io_plug)(BlockDriverState *bs);
- void coroutine_fn (*bdrv_co_io_unplug)(BlockDriverState *bs);
+ void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_io_plug)(BlockDriverState
*bs);
+ void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_io_unplug)(
+ BlockDriverState *bs);
/**
* bdrv_drain_begin is called if implemented in the beginning of a
diff --git a/block/block-backend.c b/block/block-backend.c
index fdb1e1d5f7..3661a066b3 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -2328,6 +2328,7 @@ void coroutine_fn blk_co_io_plug(BlockBackend *blk)
{
BlockDriverState *bs = blk_bs(blk);
IO_CODE();
+ GRAPH_RDLOCK_GUARD();
if (bs) {
bdrv_co_io_plug(bs);
@@ -2338,6 +2339,7 @@ void coroutine_fn blk_co_io_unplug(BlockBackend *blk)
{
BlockDriverState *bs = blk_bs(blk);
IO_CODE();
+ GRAPH_RDLOCK_GUARD();
if (bs) {
bdrv_co_io_unplug(bs);
diff --git a/block/io.c b/block/io.c
index d9c1594960..b5459c2f41 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3153,6 +3153,7 @@ void coroutine_fn bdrv_co_io_plug(BlockDriverState *bs)
{
BdrvChild *child;
IO_CODE();
+ assert_bdrv_graph_readable();
QLIST_FOREACH(child, &bs->children, next) {
bdrv_co_io_plug(child->bs);
@@ -3170,6 +3171,7 @@ void coroutine_fn bdrv_co_io_unplug(BlockDriverState *bs)
{
BdrvChild *child;
IO_CODE();
+ assert_bdrv_graph_readable();
assert(bs->io_plugged);
if (qatomic_fetch_dec(&bs->io_plugged) == 1) {
--
2.39.2
- [PULL 20/29] block: Mark bdrv_(un)register_buf() GRAPH_RDLOCK, (continued)
- [PULL 20/29] block: Mark bdrv_(un)register_buf() GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 13/29] block: Mark bdrv_co_do_pwrite_zeroes() GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 21/29] block: Mark bdrv_co_delete_file() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 22/29] block: Mark bdrv_*_dirty_bitmap() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 18/29] block: Mark bdrv_co_is_inserted() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 24/29] scsi: protect req->aiocb with AioContext lock, Kevin Wolf, 2023/02/23
- [PULL 26/29] virtio-scsi: reset SCSI devices from main loop thread, Kevin Wolf, 2023/02/23
- [PULL 27/29] block/rbd: Remove redundant stack variable passphrase_len, Kevin Wolf, 2023/02/23
- [PULL 25/29] dma-helpers: prevent dma_blk_cb() vs dma_aio_cancel() race, Kevin Wolf, 2023/02/23
- [PULL 23/29] block: Mark bdrv_co_refresh_total_sectors() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- [PULL 17/29] block: Mark bdrv_co_io_(un)plug() and callers GRAPH_RDLOCK,
Kevin Wolf <=
- [PULL 28/29] block/rbd: Add luks-any encryption opening option, Kevin Wolf, 2023/02/23
- [PULL 29/29] block/rbd: Add support for layered encryption, Kevin Wolf, 2023/02/23
- [PULL 16/29] block: Mark bdrv_co_create() and callers GRAPH_RDLOCK, Kevin Wolf, 2023/02/23
- Re: [PULL 00/29] Block layer patches, Peter Maydell, 2023/02/24