[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 19/33] block: introduce bdrv_activate
From: |
Emanuele Giuseppe Esposito |
Subject: |
[PATCH v6 19/33] block: introduce bdrv_activate |
Date: |
Fri, 21 Jan 2022 12:05:30 -0500 |
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>
---
block.c | 7 ++++++-
block/block-backend.c | 2 +-
block/export/export.c | 2 +-
block/parallels.c | 2 +-
include/block/block-global-state.h | 2 +-
tests/unit/test-block-iothread.c | 2 +-
6 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 0e119a0860..73c4e0a5a5 100644
--- a/block.c
+++ b/block.c
@@ -6549,6 +6549,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;
@@ -6636,7 +6641,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 048ba83f37..a962fc407a 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -1940,7 +1940,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/include/block/block-global-state.h
b/include/block/block-global-state.h
index 419fe8427f..a98113189e 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -143,8 +143,8 @@ BlockDriverState *check_to_replace_node(BlockDriverState
*parent_bs,
/* async block I/O */
void bdrv_aio_cancel(BlockAIOCB *acb);
+int bdrv_activate(BlockDriverState *bs, Error **errp);
void bdrv_invalidate_cache_all(Error **errp);
-
int bdrv_inactivate_all(void);
int bdrv_flush_all(void);
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.31.1
- [PATCH v6 18/33] block/copy-before-write.h: global state API + assertions, (continued)
- [PATCH v6 18/33] block/copy-before-write.h: global state API + assertions, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 24/33] block_int-common.h: assertions in the callers of BlockDriver function pointers, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 16/33] assertions for blockdev.h global state API, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 23/33] block_int-common.h: split function pointers in BlockDriver, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 22/33] block/coroutines: I/O API, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 20/33] block: rename bdrv_invalidate_cache_all, blk_invalidate_cache and test_sync_op_invalidate_cache, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 19/33] block: introduce bdrv_activate,
Emanuele Giuseppe Esposito <=
- [PATCH v6 17/33] include/block/snapshot: global state API + assertions, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 21/33] block: move BQL logic of bdrv_co_invalidate_cache in bdrv_activate, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 31/33] include/qemu/job.h: introduce job->pre_run() and use it in amend, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 26/33] block_int-common.h: assertions in the callers of BdrvChildClass function pointers, Emanuele Giuseppe Esposito, 2022/01/21
- [PATCH v6 28/33] job.h: split function pointers in JobDriver, Emanuele Giuseppe Esposito, 2022/01/21