[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v5 21/45] block: add bdrv_try_set_aio_context_tran transaction ac
From: |
Vladimir Sementsov-Ogievskiy |
Subject: |
[PATCH v5 21/45] block: add bdrv_try_set_aio_context_tran transaction action |
Date: |
Thu, 31 Mar 2022 00:28:38 +0300 |
To be used in further commit.
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@openvz.org>
---
block.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
diff --git a/block.c b/block.c
index be19964f89..1900cdf277 100644
--- a/block.c
+++ b/block.c
@@ -2907,6 +2907,54 @@ static void bdrv_child_free(BdrvChild *child)
g_free(child);
}
+typedef struct BdrvTrySetAioContextState {
+ BlockDriverState *bs;
+ AioContext *old_ctx;
+} BdrvTrySetAioContextState;
+
+static void bdrv_try_set_aio_context_abort(void *opaque)
+{
+ BdrvTrySetAioContextState *s = opaque;
+
+ if (bdrv_get_aio_context(s->bs) != s->old_ctx) {
+ bdrv_try_set_aio_context(s->bs, s->old_ctx, &error_abort);
+ }
+}
+
+static TransactionActionDrv bdrv_try_set_aio_context_drv = {
+ .abort = bdrv_try_set_aio_context_abort,
+ .clean = g_free,
+};
+
+__attribute__((unused))
+static int bdrv_try_set_aio_context_tran(BlockDriverState *bs,
+ AioContext *new_ctx,
+ Transaction *tran,
+ Error **errp)
+{
+ AioContext *old_ctx = bdrv_get_aio_context(bs);
+ BdrvTrySetAioContextState *s;
+ int ret;
+
+ if (old_ctx == new_ctx) {
+ return 0;
+ }
+
+ ret = bdrv_try_set_aio_context(bs, new_ctx, errp);
+ if (ret < 0) {
+ return ret;
+ }
+
+ s = g_new(BdrvTrySetAioContextState, 1);
+ *s = (BdrvTrySetAioContextState) {
+ .bs = bs,
+ .old_ctx = old_ctx,
+ };
+ tran_add(tran, &bdrv_try_set_aio_context_drv, s);
+
+ return 0;
+}
+
typedef struct BdrvAttachChildCommonState {
BdrvChild *child;
AioContext *old_parent_ctx;
--
2.35.1
- [PATCH v5 35/45] block: make bdrv_find_child() function public, (continued)
- [PATCH v5 35/45] block: make bdrv_find_child() function public, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 09/45] Revert "block: Let replace_child_noperm free children", Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 10/45] Revert "block: Let replace_child_tran keep indirect pointer", Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 13/45] block: Manipulate bs->file / bs->backing pointers in .attach/.detach, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 38/45] qapi: add x-blockdev-replace transaction action, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 41/45] iotests.py: introduce VM.assert_edges_list() method, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 40/45] iotests.py: qemu_img_create: use imgfmt by default, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 06/45] test-bdrv-graph-mod: fix filters to be filters, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 11/45] Revert "block: Restructure remove_file_or_backing_child()", Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 18/45] block: bdrv_refresh_perms(): allow external tran, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 21/45] block: add bdrv_try_set_aio_context_tran transaction action,
Vladimir Sementsov-Ogievskiy <=
- [PATCH v5 22/45] block: implemet bdrv_unref_tran(), Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 23/45] blockdev: refactor transaction to use Transaction API, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 45/45] block/copy-before-write: correct permission scheme, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 03/45] block/blklogwrites: don't care to remove bs->file child on failure, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 12/45] Revert "block: Pass BdrvChild ** to replace_child_noperm", Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 15/45] block: refactor bdrv_remove_file_or_backing_child to bdrv_remove_child, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 19/45] block: refactor bdrv_list_refresh_perms to allow any list of nodes, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 24/45] blockdev: transactions: rename some things, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 26/45] blockdev: transaction: refactor handling transaction properties, Vladimir Sementsov-Ogievskiy, 2022/03/30
- [PATCH v5 25/45] blockdev: qmp_transaction: refactor loop to classic for, Vladimir Sementsov-Ogievskiy, 2022/03/30