[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 34/51] block: Factor out bdrv_drain_all_begin_nopoll()
From: |
Kevin Wolf |
Subject: |
[PULL 34/51] block: Factor out bdrv_drain_all_begin_nopoll() |
Date: |
Wed, 14 Dec 2022 14:44:36 +0100 |
Provide a separate function that just quiesces the users of a node to
prevent new requests from coming in, but without waiting for the already
in-flight I/O to complete.
This function can be used in contexts where polling is not allowed.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221207131838.239125-2-kwolf@redhat.com>
Reviewed-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block-global-state.h | 1 +
block/io.c | 19 +++++++++++++------
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/include/block/block-global-state.h
b/include/block/block-global-state.h
index 1f8b54f2df..b0a3cfe6b8 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -152,6 +152,7 @@ int bdrv_inactivate_all(void);
int bdrv_flush_all(void);
void bdrv_close_all(void);
void bdrv_drain_all_begin(void);
+void bdrv_drain_all_begin_nopoll(void);
void bdrv_drain_all_end(void);
void bdrv_drain_all(void);
diff --git a/block/io.c b/block/io.c
index f4444b7777..d160d2e273 100644
--- a/block/io.c
+++ b/block/io.c
@@ -466,16 +466,11 @@ static bool bdrv_drain_all_poll(void)
* NOTE: no new block jobs or BlockDriverStates can be created between
* the bdrv_drain_all_begin() and bdrv_drain_all_end() calls.
*/
-void bdrv_drain_all_begin(void)
+void bdrv_drain_all_begin_nopoll(void)
{
BlockDriverState *bs = NULL;
GLOBAL_STATE_CODE();
- if (qemu_in_coroutine()) {
- bdrv_co_yield_to_drain(NULL, true, NULL, true);
- return;
- }
-
/*
* bdrv queue is managed by record/replay,
* waiting for finishing the I/O requests may
@@ -500,6 +495,18 @@ void bdrv_drain_all_begin(void)
bdrv_do_drained_begin(bs, NULL, false);
aio_context_release(aio_context);
}
+}
+
+void bdrv_drain_all_begin(void)
+{
+ BlockDriverState *bs = NULL;
+
+ if (qemu_in_coroutine()) {
+ bdrv_co_yield_to_drain(NULL, true, NULL, true);
+ return;
+ }
+
+ bdrv_drain_all_begin_nopoll();
/* Now poll the in-flight requests */
AIO_WAIT_WHILE(NULL, bdrv_drain_all_poll());
--
2.38.1
- [PULL 30/51] block-coroutine-wrapper.py: support functions without bs arg, (continued)
- [PULL 30/51] block-coroutine-wrapper.py: support functions without bs arg, Kevin Wolf, 2022/12/14
- [PULL 21/51] block-copy: add coroutine_fn annotations, Kevin Wolf, 2022/12/14
- [PULL 20/51] block-io: introduce coroutine_fn duplicates for bdrv_common_block_status_above callers, Kevin Wolf, 2022/12/14
- [PULL 22/51] nbd/server.c: add coroutine_fn annotations, 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
- [PULL 25/51] block: avoid duplicating filename string in bdrv_create, Kevin Wolf, 2022/12/14
- [PULL 29/51] block-coroutine-wrapper.py: introduce co_wrapper, Kevin Wolf, 2022/12/14
- [PULL 27/51] block: bdrv_create_file is a coroutine_fn, Kevin Wolf, 2022/12/14
- [PULL 32/51] block: convert bdrv_create to co_wrapper, Kevin Wolf, 2022/12/14
- [PULL 34/51] block: Factor out bdrv_drain_all_begin_nopoll(),
Kevin Wolf <=
- [PULL 41/51] configure: Enable -Wthread-safety if present, Kevin Wolf, 2022/12/14
- [PULL 38/51] Import clang-tsa.h, Kevin Wolf, 2022/12/14
- [PULL 44/51] block: wrlock in bdrv_replace_child_noperm, Kevin Wolf, 2022/12/14
- [PULL 40/51] clang-tsa: Add macros for shared locks, Kevin Wolf, 2022/12/14
- [PULL 37/51] async: Register/unregister aiocontext in graph lock list, Kevin Wolf, 2022/12/14
- [PULL 45/51] block: remove unnecessary assert_bdrv_graph_writable(), Kevin Wolf, 2022/12/14
- [PULL 49/51] block-coroutine-wrapper.py: introduce annotations that take the graph rdlock, Kevin Wolf, 2022/12/14
- [PULL 16/51] block: Remove ignore_bds_parents parameter from drain_begin/end., Kevin Wolf, 2022/12/14
- [PULL 48/51] Mark assert_bdrv_graph_readable/writable() GRAPH_RD/WRLOCK, Kevin Wolf, 2022/12/14
- [PULL 24/51] block/vmdk: add coroutine_fn annotations, Kevin Wolf, 2022/12/14