[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/50] block: introduce bdrv_activate
From: |
Kevin Wolf |
Subject: |
[PULL 03/50] block: introduce bdrv_activate |
Date: |
Fri, 4 Mar 2022 17:46:24 +0100 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
This function is currently just a wrapper for bdrv_invalidate_cache(),
but in future will contain the code of bdrv_co_invalidate_cache() that
has to always be protected by BQL, and leave the rest in the I/O
coroutine.
Replace all bdrv_invalidate_cache() invokations with bdrv_activate().
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220209105452.1694545-4-eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
include/block/block.h | 1 +
block.c | 7 ++++++-
block/block-backend.c | 2 +-
block/export/export.c | 2 +-
block/parallels.c | 2 +-
tests/unit/test-block-iothread.c | 2 +-
6 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/include/block/block.h b/include/block/block.h
index e1713ee306..18cd336911 100644
--- a/include/block/block.h
+++ b/include/block/block.h
@@ -494,6 +494,7 @@ int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf);
int generated_co_wrapper bdrv_invalidate_cache(BlockDriverState *bs,
Error **errp);
void bdrv_invalidate_cache_all(Error **errp);
+int bdrv_activate(BlockDriverState *bs, Error **errp);
int bdrv_inactivate_all(void);
/* Ensure contents are flushed to disk. */
diff --git a/block.c b/block.c
index b54d59d1fa..7746727a47 100644
--- a/block.c
+++ b/block.c
@@ -6393,6 +6393,11 @@ void bdrv_init_with_whitelist(void)
bdrv_init();
}
+int bdrv_activate(BlockDriverState *bs, Error **errp)
+{
+ return bdrv_invalidate_cache(bs, errp);
+}
+
int coroutine_fn bdrv_co_invalidate_cache(BlockDriverState *bs, Error **errp)
{
BdrvChild *child, *parent;
@@ -6478,7 +6483,7 @@ void bdrv_invalidate_cache_all(Error **errp)
int ret;
aio_context_acquire(aio_context);
- ret = bdrv_invalidate_cache(bs, errp);
+ ret = bdrv_activate(bs, errp);
aio_context_release(aio_context);
if (ret < 0) {
bdrv_next_cleanup(&it);
diff --git a/block/block-backend.c b/block/block-backend.c
index 4ff6b4d785..c516113a36 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1889,7 +1889,7 @@ void blk_invalidate_cache(BlockBackend *blk, Error **errp)
return;
}
- bdrv_invalidate_cache(bs, errp);
+ bdrv_activate(bs, errp);
}
bool blk_is_inserted(BlockBackend *blk)
diff --git a/block/export/export.c b/block/export/export.c
index 6d3b9964c8..7253af3bc3 100644
--- a/block/export/export.c
+++ b/block/export/export.c
@@ -139,7 +139,7 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error
**errp)
* access since the export could be available before migration handover.
* ctx was acquired in the caller.
*/
- bdrv_invalidate_cache(bs, NULL);
+ bdrv_activate(bs, NULL);
perm = BLK_PERM_CONSISTENT_READ;
if (export->writable) {
diff --git a/block/parallels.c b/block/parallels.c
index 6ebad2a2bb..e58c828422 100644
--- a/block/parallels.c
+++ b/block/parallels.c
@@ -873,7 +873,7 @@ static int parallels_open(BlockDriverState *bs, QDict
*options, int flags,
s->bat_dirty_bmap =
bitmap_new(DIV_ROUND_UP(s->header_size, s->bat_dirty_block));
- /* Disable migration until bdrv_invalidate_cache method is added */
+ /* Disable migration until bdrv_activate method is added */
error_setg(&s->migration_blocker, "The Parallels format used by node '%s' "
"does not support live migration",
bdrv_get_device_or_node_name(bs));
diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothread.c
index aea660aeed..378a7b7869 100644
--- a/tests/unit/test-block-iothread.c
+++ b/tests/unit/test-block-iothread.c
@@ -282,7 +282,7 @@ static void test_sync_op_check(BdrvChild *c)
static void test_sync_op_invalidate_cache(BdrvChild *c)
{
/* Early success: Image is not inactive */
- bdrv_invalidate_cache(c->bs, NULL);
+ bdrv_activate(c->bs, NULL);
}
--
2.35.1
- [PULL 08/50] rcu: use coroutine TLS macros, (continued)
- [PULL 08/50] rcu: use coroutine TLS macros, Kevin Wolf, 2022/03/04
- [PULL 09/50] cpus: use coroutine TLS macros for iothread_locked, Kevin Wolf, 2022/03/04
- [PULL 10/50] os-posix: Add os_set_daemonize(), Kevin Wolf, 2022/03/04
- [PULL 12/50] qsd: Add --daemonize, Kevin Wolf, 2022/03/04
- [PULL 11/50] qsd: Add pre-init argument parsing pass, Kevin Wolf, 2022/03/04
- [PULL 07/50] util/async: replace __thread with QEMU TLS macros, Kevin Wolf, 2022/03/04
- [PULL 16/50] include/block/block: split header into I/O and global state API, Kevin Wolf, 2022/03/04
- [PULL 13/50] iotests/185: Add post-READY quit tests, Kevin Wolf, 2022/03/04
- [PULL 14/50] main-loop.h: introduce qemu_in_main_thread(), Kevin Wolf, 2022/03/04
- [PULL 15/50] main loop: macros to mark GS and I/O functions, Kevin Wolf, 2022/03/04
- [PULL 03/50] block: introduce bdrv_activate,
Kevin Wolf <=
- [PULL 17/50] assertions for block global state API, Kevin Wolf, 2022/03/04
- [PULL 02/50] crypto: distinguish between main loop and I/O in block_crypto_amend_options_generic_luks, Kevin Wolf, 2022/03/04
- [PULL 19/50] block/export/fuse.c: allow writable exports to take RESIZE permission, Kevin Wolf, 2022/03/04
- [PULL 27/50] block: introduce assert_bdrv_graph_writable, Kevin Wolf, 2022/03/04
- [PULL 20/50] include/sysemu/block-backend: split header into I/O and global state (GS) API, Kevin Wolf, 2022/03/04
- [PULL 32/50] assertions for blockjob.h global state API, Kevin Wolf, 2022/03/04
- [PULL 18/50] IO_CODE and IO_OR_GS_CODE for block I/O API, Kevin Wolf, 2022/03/04
- [PULL 35/50] include/block/snapshot: global state API + assertions, Kevin Wolf, 2022/03/04
- [PULL 33/50] include/sysemu/blockdev.h: global state API, Kevin Wolf, 2022/03/04
- [PULL 34/50] assertions for blockdev.h global state API, Kevin Wolf, 2022/03/04