[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 26/58] blockjob: implement .change_aio_ctx in child_job
From: |
Kevin Wolf |
Subject: |
[PULL 26/58] blockjob: implement .change_aio_ctx in child_job |
Date: |
Thu, 27 Oct 2022 20:31:14 +0200 |
From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
child_job_change_aio_ctx() is very similar to
child_job_can_set_aio_ctx(), but it implements a new transaction
so that if all check pass, the new transaction's .commit()
will take care of changin the BlockJob AioContext.
child_job_set_aio_ctx_commit() is similar to child_job_set_aio_ctx(),
but it doesn't need to invoke the recursion, as this is already
taken care by child_job_change_aio_ctx().
Note: bdrv_child_try_change_aio_context() is not called by
anyone at this point.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Message-Id: <20221025084952.2139888-5-eesposit@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
blockjob.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/blockjob.c b/blockjob.c
index bdf20a0e35..5a783b75c6 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -126,6 +126,50 @@ static void child_job_drained_end(BdrvChild *c, int
*drained_end_counter)
job_resume(&job->job);
}
+typedef struct BdrvStateChildJobContext {
+ AioContext *new_ctx;
+ BlockJob *job;
+} BdrvStateChildJobContext;
+
+static void child_job_set_aio_ctx_commit(void *opaque)
+{
+ BdrvStateChildJobContext *s = opaque;
+ BlockJob *job = s->job;
+
+ job_set_aio_context(&job->job, s->new_ctx);
+}
+
+static TransactionActionDrv change_child_job_context = {
+ .commit = child_job_set_aio_ctx_commit,
+ .clean = g_free,
+};
+
+static bool child_job_change_aio_ctx(BdrvChild *c, AioContext *ctx,
+ GHashTable *visited, Transaction *tran,
+ Error **errp)
+{
+ BlockJob *job = c->opaque;
+ BdrvStateChildJobContext *s;
+ GSList *l;
+
+ for (l = job->nodes; l; l = l->next) {
+ BdrvChild *sibling = l->data;
+ if (!bdrv_child_change_aio_context(sibling, ctx, visited,
+ tran, errp)) {
+ return false;
+ }
+ }
+
+ s = g_new(BdrvStateChildJobContext, 1);
+ *s = (BdrvStateChildJobContext) {
+ .new_ctx = ctx,
+ .job = job,
+ };
+
+ tran_add(tran, &change_child_job_context, s);
+ return true;
+}
+
static bool child_job_can_set_aio_ctx(BdrvChild *c, AioContext *ctx,
GSList **ignore, Error **errp)
{
@@ -174,6 +218,7 @@ static const BdrvChildClass child_job = {
.drained_end = child_job_drained_end,
.can_set_aio_ctx = child_job_can_set_aio_ctx,
.set_aio_ctx = child_job_set_aio_ctx,
+ .change_aio_ctx = child_job_change_aio_ctx,
.stay_at_node = true,
.get_parent_aio_context = child_job_get_parent_aio_context,
};
--
2.37.3
- [PULL 11/58] test-bdrv-graph-mod: update test_parallel_perm_update test case, (continued)
- [PULL 11/58] test-bdrv-graph-mod: update test_parallel_perm_update test case, Kevin Wolf, 2022/10/27
- [PULL 09/58] block: introduce bdrv_open_file_child() helper, Kevin Wolf, 2022/10/27
- [PULL 14/58] block: document connection between child roles and bs->backing/bs->file, Kevin Wolf, 2022/10/27
- [PULL 18/58] Revert "block: Restructure remove_file_or_backing_child()", Kevin Wolf, 2022/10/27
- [PULL 16/58] Revert "block: Let replace_child_noperm free children", Kevin Wolf, 2022/10/27
- [PULL 17/58] Revert "block: Let replace_child_tran keep indirect pointer", Kevin Wolf, 2022/10/27
- [PULL 19/58] Revert "block: Pass BdrvChild ** to replace_child_noperm", Kevin Wolf, 2022/10/27
- [PULL 15/58] block/snapshot: stress that we fallback to primary child, Kevin Wolf, 2022/10/27
- [PULL 06/58] block/io_uring: revert "Use io_uring_register_ring_fd() to skip fd operations", Kevin Wolf, 2022/10/27
- [PULL 20/58] block: Manipulate bs->file / bs->backing pointers in .attach/.detach, Kevin Wolf, 2022/10/27
- [PULL 26/58] blockjob: implement .change_aio_ctx in child_job,
Kevin Wolf <=
- [PULL 36/58] monitor: add missing coroutine_fn annotation, Kevin Wolf, 2022/10/27
- [PULL 29/58] block: use the new _change_ API instead of _can_set_ and _set_, Kevin Wolf, 2022/10/27
- [PULL 30/58] block: remove all unused ->can_set_aio_ctx and ->set_aio_ctx callbacks, Kevin Wolf, 2022/10/27
- [PULL 33/58] block/nfs: Fix 32-bit Windows build, Kevin Wolf, 2022/10/27
- [PULL 41/58] block: add missing coroutine_fn annotation to BlockDriverState callbacks, Kevin Wolf, 2022/10/27
- [PULL 25/58] bdrv_change_aio_context: use hash table instead of list of visited nodes, Kevin Wolf, 2022/10/27
- [PULL 35/58] block: remove incorrect coroutine_fn annotation, Kevin Wolf, 2022/10/27
- [PULL 37/58] ssh: add missing coroutine_fn annotation, Kevin Wolf, 2022/10/27
- [PULL 47/58] commit: switch to *_co_* functions, Kevin Wolf, 2022/10/27
- [PULL 45/58] qcow2: manually add more coroutine_fn annotations, Kevin Wolf, 2022/10/27