From: Emanuele Giuseppe Esposito <eesposit@redhat.com>
To: qemu-block@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Hanna Reitz <hreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, John Snow <jsnow@redhat.com>,
Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
Markus Armbruster <armbru@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
qemu-devel@nongnu.org,
Emanuele Giuseppe Esposito <eesposit@redhat.com>
Subject: [PATCH v2 09/11] block: remove all unused ->can_set_aio_ctx and ->set_aio_ctx callbacks
Date: Mon, 25 Jul 2022 08:21:18 -0400 [thread overview]
Message-ID: <20220725122120.309236-10-eesposit@redhat.com> (raw)
In-Reply-To: <20220725122120.309236-1-eesposit@redhat.com>
Together with all _can_set_ and _set_ APIs, as they are not needed
anymore.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
block.c | 196 -----------------------------
block/block-backend.c | 33 -----
blockjob.c | 35 ------
include/block/block-global-state.h | 9 --
include/block/block_int-common.h | 4 -
5 files changed, 277 deletions(-)
diff --git a/block.c b/block.c
index 9b47aacad2..c066b41c8c 100644
--- a/block.c
+++ b/block.c
@@ -1247,20 +1247,6 @@ static bool bdrv_child_cb_change_aio_ctx(BdrvChild *child, AioContext *ctx,
return bdrv_change_aio_context(bs, ctx, visited, tran, errp);
}
-static bool bdrv_child_cb_can_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- BlockDriverState *bs = child->opaque;
- return bdrv_can_set_aio_context(bs, ctx, ignore, errp);
-}
-
-static void bdrv_child_cb_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore)
-{
- BlockDriverState *bs = child->opaque;
- return bdrv_set_aio_context_ignore(bs, ctx, ignore);
-}
-
/*
* Returns the options and flags that a temporary snapshot should get, based on
* the originally requested flags (the originally requested image will have
@@ -1501,8 +1487,6 @@ const BdrvChildClass child_of_bds = {
.attach = bdrv_child_cb_attach,
.detach = bdrv_child_cb_detach,
.inactivate = bdrv_child_cb_inactivate,
- .can_set_aio_ctx = bdrv_child_cb_can_set_aio_ctx,
- .set_aio_ctx = bdrv_child_cb_set_aio_ctx,
.change_aio_ctx = bdrv_child_cb_change_aio_ctx,
.update_filename = bdrv_child_cb_update_filename,
.get_parent_aio_context = child_of_bds_get_parent_aio_context,
@@ -7334,125 +7318,6 @@ static void bdrv_attach_aio_context(BlockDriverState *bs,
bs->walking_aio_notifiers = false;
}
-/*
- * Changes the AioContext used for fd handlers, timers, and BHs by this
- * BlockDriverState and all its children and parents.
- *
- * Must be called from the main AioContext.
- *
- * The caller must own the AioContext lock for the old AioContext of bs, but it
- * must not own the AioContext lock for new_context (unless new_context is the
- * same as the current context of bs).
- *
- * @ignore will accumulate all visited BdrvChild objects. The caller is
- * responsible for freeing the list afterwards.
- */
-void bdrv_set_aio_context_ignore(BlockDriverState *bs,
- AioContext *new_context, GSList **ignore)
-{
- AioContext *old_context = bdrv_get_aio_context(bs);
- GSList *children_to_process = NULL;
- GSList *parents_to_process = NULL;
- GSList *entry;
- BdrvChild *child, *parent;
-
- g_assert(qemu_get_current_aio_context() == qemu_get_aio_context());
- GLOBAL_STATE_CODE();
-
- if (old_context == new_context) {
- return;
- }
-
- bdrv_drained_begin(bs);
-
- QLIST_FOREACH(child, &bs->children, next) {
- if (g_slist_find(*ignore, child)) {
- continue;
- }
- *ignore = g_slist_prepend(*ignore, child);
- children_to_process = g_slist_prepend(children_to_process, child);
- }
-
- QLIST_FOREACH(parent, &bs->parents, next_parent) {
- if (g_slist_find(*ignore, parent)) {
- continue;
- }
- *ignore = g_slist_prepend(*ignore, parent);
- parents_to_process = g_slist_prepend(parents_to_process, parent);
- }
-
- for (entry = children_to_process;
- entry != NULL;
- entry = g_slist_next(entry)) {
- child = entry->data;
- bdrv_set_aio_context_ignore(child->bs, new_context, ignore);
- }
- g_slist_free(children_to_process);
-
- for (entry = parents_to_process;
- entry != NULL;
- entry = g_slist_next(entry)) {
- parent = entry->data;
- assert(parent->klass->set_aio_ctx);
- parent->klass->set_aio_ctx(parent, new_context, ignore);
- }
- g_slist_free(parents_to_process);
-
- bdrv_detach_aio_context(bs);
-
- /* Acquire the new context, if necessary */
- if (qemu_get_aio_context() != new_context) {
- aio_context_acquire(new_context);
- }
-
- bdrv_attach_aio_context(bs, new_context);
-
- /*
- * If this function was recursively called from
- * bdrv_set_aio_context_ignore(), there may be nodes in the
- * subtree that have not yet been moved to the new AioContext.
- * Release the old one so bdrv_drained_end() can poll them.
- */
- if (qemu_get_aio_context() != old_context) {
- aio_context_release(old_context);
- }
-
- bdrv_drained_end(bs);
-
- if (qemu_get_aio_context() != old_context) {
- aio_context_acquire(old_context);
- }
- if (qemu_get_aio_context() != new_context) {
- aio_context_release(new_context);
- }
-}
-
-static bool bdrv_parent_can_set_aio_context(BdrvChild *c, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- GLOBAL_STATE_CODE();
- if (g_slist_find(*ignore, c)) {
- return true;
- }
- *ignore = g_slist_prepend(*ignore, c);
-
- /*
- * A BdrvChildClass that doesn't handle AioContext changes cannot
- * tolerate any AioContext changes
- */
- if (!c->klass->can_set_aio_ctx) {
- char *user = bdrv_child_user_desc(c);
- error_setg(errp, "Changing iothreads is not supported by %s", user);
- g_free(user);
- return false;
- }
- if (!c->klass->can_set_aio_ctx(c, ctx, ignore, errp)) {
- assert(!errp || *errp);
- return false;
- }
- return true;
-}
-
typedef struct BdrvStateSetAioContext {
AioContext *new_ctx;
BlockDriverState *bs;
@@ -7486,17 +7351,6 @@ static bool bdrv_parent_change_aio_context(BdrvChild *c, AioContext *ctx,
return true;
}
-bool bdrv_child_can_set_aio_context(BdrvChild *c, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- GLOBAL_STATE_CODE();
- if (g_slist_find(*ignore, c)) {
- return true;
- }
- *ignore = g_slist_prepend(*ignore, c);
- return bdrv_can_set_aio_context(c->bs, ctx, ignore, errp);
-}
-
bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
GHashTable *visited, Transaction *tran,
Error **errp)
@@ -7509,33 +7363,6 @@ bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
return bdrv_change_aio_context(c->bs, ctx, visited, tran, errp);
}
-/* @ignore will accumulate all visited BdrvChild object. The caller is
- * responsible for freeing the list afterwards. */
-bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- BdrvChild *c;
-
- if (bdrv_get_aio_context(bs) == ctx) {
- return true;
- }
-
- GLOBAL_STATE_CODE();
-
- QLIST_FOREACH(c, &bs->parents, next_parent) {
- if (!bdrv_parent_can_set_aio_context(c, ctx, ignore, errp)) {
- return false;
- }
- }
- QLIST_FOREACH(c, &bs->children, next) {
- if (!bdrv_child_can_set_aio_context(c, ctx, ignore, errp)) {
- return false;
- }
- }
-
- return true;
-}
-
static void bdrv_drained_end_clean(void *opaque)
{
BdrvStateSetAioContext *state = (BdrvStateSetAioContext *) opaque;
@@ -7615,29 +7442,6 @@ static bool bdrv_change_aio_context(BlockDriverState *bs, AioContext *ctx,
return true;
}
-int bdrv_child_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
- BdrvChild *ignore_child, Error **errp)
-{
- GSList *ignore;
- bool ret;
-
- GLOBAL_STATE_CODE();
-
- ignore = ignore_child ? g_slist_prepend(NULL, ignore_child) : NULL;
- ret = bdrv_can_set_aio_context(bs, ctx, &ignore, errp);
- g_slist_free(ignore);
-
- if (!ret) {
- return -EPERM;
- }
-
- ignore = ignore_child ? g_slist_prepend(NULL, ignore_child) : NULL;
- bdrv_set_aio_context_ignore(bs, ctx, &ignore);
- g_slist_free(ignore);
-
- return 0;
-}
-
/*
* Change bs's and recursively all of its parents' and children's AioContext
* to the given new context, returning an error if that isn't possible.
diff --git a/block/block-backend.c b/block/block-backend.c
index 3046b4cc54..a27b8b7a89 100644
--- a/block/block-backend.c
+++ b/block/block-backend.c
@@ -134,10 +134,6 @@ static void blk_root_drained_end(BdrvChild *child, int *drained_end_counter);
static void blk_root_change_media(BdrvChild *child, bool load);
static void blk_root_resize(BdrvChild *child);
-static bool blk_root_can_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore, Error **errp);
-static void blk_root_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore);
static bool blk_root_change_aio_ctx(BdrvChild *child, AioContext *ctx,
GHashTable *visited, Transaction *tran,
Error **errp);
@@ -337,8 +333,6 @@ static const BdrvChildClass child_root = {
.attach = blk_root_attach,
.detach = blk_root_detach,
- .can_set_aio_ctx = blk_root_can_set_aio_ctx,
- .set_aio_ctx = blk_root_set_aio_ctx,
.change_aio_ctx = blk_root_change_aio_ctx,
.get_parent_aio_context = blk_root_get_parent_aio_context,
@@ -2264,33 +2258,6 @@ static bool blk_root_change_aio_ctx(BdrvChild *child, AioContext *ctx,
return true;
}
-static bool blk_root_can_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- BlockBackend *blk = child->opaque;
-
- if (blk->allow_aio_context_change) {
- return true;
- }
-
- /* Only manually created BlockBackends that are not attached to anything
- * can change their AioContext without updating their user. */
- if (!blk->name || blk->dev) {
- /* TODO Add BB name/QOM path */
- error_setg(errp, "Cannot change iothread of active block backend");
- return false;
- }
-
- return true;
-}
-
-static void blk_root_set_aio_ctx(BdrvChild *child, AioContext *ctx,
- GSList **ignore)
-{
- BlockBackend *blk = child->opaque;
- blk_do_set_aio_context(blk, ctx, false, &error_abort);
-}
-
void blk_add_aio_context_notifier(BlockBackend *blk,
void (*attached_aio_context)(AioContext *new_context, void *opaque),
void (*detach_aio_context)(void *opaque), void *opaque)
diff --git a/blockjob.c b/blockjob.c
index 704bab060f..dadb2feca4 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -170,39 +170,6 @@ static bool child_job_change_aio_ctx(BdrvChild *c, AioContext *ctx,
return true;
}
-static bool child_job_can_set_aio_ctx(BdrvChild *c, AioContext *ctx,
- GSList **ignore, Error **errp)
-{
- BlockJob *job = c->opaque;
- GSList *l;
-
- for (l = job->nodes; l; l = l->next) {
- BdrvChild *sibling = l->data;
- if (!bdrv_child_can_set_aio_context(sibling, ctx, ignore, errp)) {
- return false;
- }
- }
- return true;
-}
-
-static void child_job_set_aio_ctx(BdrvChild *c, AioContext *ctx,
- GSList **ignore)
-{
- BlockJob *job = c->opaque;
- GSList *l;
-
- for (l = job->nodes; l; l = l->next) {
- BdrvChild *sibling = l->data;
- if (g_slist_find(*ignore, sibling)) {
- continue;
- }
- *ignore = g_slist_prepend(*ignore, sibling);
- bdrv_set_aio_context_ignore(sibling->bs, ctx, ignore);
- }
-
- job_set_aio_context(&job->job, ctx);
-}
-
static AioContext *child_job_get_parent_aio_context(BdrvChild *c)
{
BlockJob *job = c->opaque;
@@ -216,8 +183,6 @@ static const BdrvChildClass child_job = {
.drained_begin = child_job_drained_begin,
.drained_poll = child_job_drained_poll,
.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,
diff --git a/include/block/block-global-state.h b/include/block/block-global-state.h
index 1bd445b507..54fd008442 100644
--- a/include/block/block-global-state.h
+++ b/include/block/block-global-state.h
@@ -217,18 +217,9 @@ void coroutine_fn bdrv_co_lock(BlockDriverState *bs);
*/
void coroutine_fn bdrv_co_unlock(BlockDriverState *bs);
-void bdrv_set_aio_context_ignore(BlockDriverState *bs,
- AioContext *new_context, GSList **ignore);
int bdrv_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
Error **errp);
-int bdrv_child_try_set_aio_context(BlockDriverState *bs, AioContext *ctx,
- BdrvChild *ignore_child, Error **errp);
-bool bdrv_child_can_set_aio_context(BdrvChild *c, AioContext *ctx,
- GSList **ignore, Error **errp);
-bool bdrv_can_set_aio_context(BlockDriverState *bs, AioContext *ctx,
- GSList **ignore, Error **errp);
AioContext *bdrv_child_get_parent_aio_context(BdrvChild *c);
-
bool bdrv_child_change_aio_context(BdrvChild *c, AioContext *ctx,
GHashTable *visited, Transaction *tran,
Error **errp);
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index c639873487..8f3102cc3d 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -892,10 +892,6 @@ struct BdrvChildClass {
int (*update_filename)(BdrvChild *child, BlockDriverState *new_base,
const char *filename, Error **errp);
- bool (*can_set_aio_ctx)(BdrvChild *child, AioContext *ctx,
- GSList **ignore, Error **errp);
- void (*set_aio_ctx)(BdrvChild *child, AioContext *ctx, GSList **ignore);
-
bool (*change_aio_ctx)(BdrvChild *child, AioContext *ctx,
GHashTable *visited, Transaction *tran,
Error **errp);
--
2.31.1
next prev parent reply other threads:[~2022-07-25 12:31 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-25 12:21 [PATCH v2 00/11] Refactor bdrv_try_set_aio_context using transactions Emanuele Giuseppe Esposito
2022-07-25 12:21 ` [PATCH v2 01/11] block.c: assert bs->aio_context is written under BQL and drains Emanuele Giuseppe Esposito
2022-10-07 14:42 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 02/11] block: use transactions as a replacement of ->{can_}set_aio_context() Emanuele Giuseppe Esposito
2022-10-07 15:49 ` Kevin Wolf
2022-10-24 14:44 ` Emanuele Giuseppe Esposito
2022-07-25 12:21 ` [PATCH v2 03/11] bdrv_change_aio_context: use hash table instead of list of visited nodes Emanuele Giuseppe Esposito
2022-10-07 15:56 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 04/11] bdrv_child_try_change_aio_context: add transaction parameter Emanuele Giuseppe Esposito
2022-10-07 16:10 ` Kevin Wolf
2022-10-24 14:52 ` Emanuele Giuseppe Esposito
2022-07-25 12:21 ` [PATCH v2 05/11] blockjob: implement .change_aio_ctx in child_job Emanuele Giuseppe Esposito
2022-10-10 10:46 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 06/11] block: implement .change_aio_ctx in child_of_bds Emanuele Giuseppe Esposito
2022-10-10 10:47 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 07/11] block-backend: implement .change_aio_ctx in child_root Emanuele Giuseppe Esposito
2022-10-10 10:50 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 08/11] block: use the new _change_ API instead of _can_set_ and _set_ Emanuele Giuseppe Esposito
2022-10-10 12:56 ` Kevin Wolf
2022-07-25 12:21 ` Emanuele Giuseppe Esposito [this message]
2022-10-10 12:56 ` [PATCH v2 09/11] block: remove all unused ->can_set_aio_ctx and ->set_aio_ctx callbacks Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 10/11] block: rename bdrv_child_try_change_aio_context in bdrv_try_change_aio_context Emanuele Giuseppe Esposito
2022-10-10 12:56 ` Kevin Wolf
2022-07-25 12:21 ` [PATCH v2 11/11] block: remove bdrv_try_set_aio_context and replace it with bdrv_try_change_aio_context Emanuele Giuseppe Esposito
2022-10-10 12:56 ` Kevin Wolf
2022-07-26 14:24 ` [PATCH v2 00/11] Refactor bdrv_try_set_aio_context using transactions Vladimir Sementsov-Ogievskiy
2022-07-26 14:27 ` Emanuele Giuseppe Esposito
2022-07-27 16:13 ` Vladimir Sementsov-Ogievskiy
2022-08-05 13:22 ` Emanuele Giuseppe Esposito
2022-08-05 13:36 ` Emanuele Giuseppe Esposito
2022-08-05 14:41 ` Vladimir Sementsov-Ogievskiy
2022-08-05 14:35 ` Vladimir Sementsov-Ogievskiy
2022-08-05 14:57 ` Emanuele Giuseppe Esposito
2022-08-06 15:32 ` Vladimir Sementsov-Ogievskiy
2022-08-10 10:22 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220725122120.309236-10-eesposit@redhat.com \
--to=eesposit@redhat.com \
--cc=armbru@redhat.com \
--cc=hreitz@redhat.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
--cc=vsementsov@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).