From nobody Tue Apr 15 13:28:24 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1666898846; cv=none; d=zohomail.com; s=zohoarc; b=cDLYDizsRExmf4APK6XThG6PpvldKMeEwkIvQ1so+dqUG6wcTx0UWNtLorHDcD2rqslpAEN8pCUkL+BIKzopUl2Y4JwlW4BwqZQABPN1cuBDKmnDgmfJ+Wm2i1flYXASKVHB5e+eXh4zsPQh/LCIg3hqamPAk7jSGpH2vaxE7/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1666898846; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qkifYX0JHHubAeKGaht3u+d3rGgILyq/uBdKORfimU0=; b=RfNK+kc8jyQnpKR1JqpHtoph15F7AZUDTreljwxw6BM9R0b9XqgTICFbYdERaqIkR6B//vw22l5QWCCyguCeDL07NCzPBIjC7vjdz8LS3ZBilTl36bAH9cLUOBV8RNjrRmJl1vG+RJFutREL3jRBgS7X4hBMz86Zxb++TcIZm+E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1666898846923902.5761906353181; Thu, 27 Oct 2022 12:27:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oo7hx-0004hh-F2; Thu, 27 Oct 2022 14:34:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7gV-0001sb-Nz for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:33:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oo7gJ-0002VN-IF for qemu-devel@nongnu.org; Thu, 27 Oct 2022 14:32:54 -0400 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-263-fFeFYKg-Pvaf7uYT5ZiE3g-1; Thu, 27 Oct 2022 14:32:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AECF5811E84; Thu, 27 Oct 2022 18:32:40 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E9AE21121320; Thu, 27 Oct 2022 18:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666895562; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qkifYX0JHHubAeKGaht3u+d3rGgILyq/uBdKORfimU0=; b=RATAjPSd9jT2oxXxCPHmJ5uCDY2u2EPc14+EKsFqHYqnHN6GEHTKSKo94lnH39fsWVkWHe QFmLkZGrVZLmKGAzPUxzKyGvD75rGonvzT70C0vtWSB2ParqP9juJJsSiqGWqwcK4ILX/L Hb5cM34N+6++LXPNVtOHpZ1uMoNa7Ts= X-MC-Unique: fFeFYKg-Pvaf7uYT5ZiE3g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 30/58] block: remove all unused ->can_set_aio_ctx and ->set_aio_ctx callbacks Date: Thu, 27 Oct 2022 20:31:18 +0200 Message-Id: <20221027183146.463129-31-kwolf@redhat.com> In-Reply-To: <20221027183146.463129-1-kwolf@redhat.com> References: <20221027183146.463129-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.515, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Qemu-devel" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1666898847772100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Together with all _can_set_ and _set_ APIs, as they are not needed anymore. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Message-Id: <20221025084952.2139888-9-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 9 -- include/block/block_int-common.h | 4 - block.c | 196 ----------------------------- block/block-backend.c | 33 ----- blockjob.c | 35 ------ 5 files changed, 277 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index e7372ec541..03d4ade7c2 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -220,18 +220,9 @@ void coroutine_fn bdrv_co_lock(BlockDriverState *bs); */ void coroutine_fn bdrv_co_unlock(BlockDriverState *bs); =20 -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-com= mon.h index 7ccbbdae05..c756b838e8 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -906,10 +906,6 @@ struct BdrvChildClass { int (*update_filename)(BdrvChild *child, BlockDriverState *new_base, const char *filename, Error **errp); =20 - 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); diff --git a/block.c b/block.c index c35249e8c3..353240eecd 100644 --- a/block.c +++ b/block.c @@ -1250,20 +1250,6 @@ static bool bdrv_child_cb_change_aio_ctx(BdrvChild *= child, AioContext *ctx, return bdrv_change_aio_context(bs, ctx, visited, tran, errp); } =20 -static bool bdrv_child_cb_can_set_aio_ctx(BdrvChild *child, AioContext *ct= x, - GSList **ignore, Error **errp) -{ - BlockDriverState *bs =3D 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 =3D child->opaque; - return bdrv_set_aio_context_ignore(bs, ctx, ignore); -} - /* * Returns the options and flags that a temporary snapshot should get, bas= ed on * the originally requested flags (the originally requested image will have @@ -1540,8 +1526,6 @@ const BdrvChildClass child_of_bds =3D { .attach =3D bdrv_child_cb_attach, .detach =3D bdrv_child_cb_detach, .inactivate =3D bdrv_child_cb_inactivate, - .can_set_aio_ctx =3D bdrv_child_cb_can_set_aio_ctx, - .set_aio_ctx =3D bdrv_child_cb_set_aio_ctx, .change_aio_ctx =3D bdrv_child_cb_change_aio_ctx, .update_filename =3D bdrv_child_cb_update_filename, .get_parent_aio_context =3D child_of_bds_get_parent_aio_context, @@ -7205,125 +7189,6 @@ static void bdrv_attach_aio_context(BlockDriverStat= e *bs, bs->walking_aio_notifiers =3D false; } =20 -/* - * 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, b= ut 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 =3D bdrv_get_aio_context(bs); - GSList *children_to_process =3D NULL; - GSList *parents_to_process =3D NULL; - GSList *entry; - BdrvChild *child, *parent; - - g_assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); - GLOBAL_STATE_CODE(); - - if (old_context =3D=3D new_context) { - return; - } - - bdrv_drained_begin(bs); - - QLIST_FOREACH(child, &bs->children, next) { - if (g_slist_find(*ignore, child)) { - continue; - } - *ignore =3D g_slist_prepend(*ignore, child); - children_to_process =3D g_slist_prepend(children_to_process, child= ); - } - - QLIST_FOREACH(parent, &bs->parents, next_parent) { - if (g_slist_find(*ignore, parent)) { - continue; - } - *ignore =3D g_slist_prepend(*ignore, parent); - parents_to_process =3D g_slist_prepend(parents_to_process, parent); - } - - for (entry =3D children_to_process; - entry !=3D NULL; - entry =3D g_slist_next(entry)) { - child =3D entry->data; - bdrv_set_aio_context_ignore(child->bs, new_context, ignore); - } - g_slist_free(children_to_process); - - for (entry =3D parents_to_process; - entry !=3D NULL; - entry =3D g_slist_next(entry)) { - parent =3D 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() !=3D 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() !=3D old_context) { - aio_context_release(old_context); - } - - bdrv_drained_end(bs); - - if (qemu_get_aio_context() !=3D old_context) { - aio_context_acquire(old_context); - } - if (qemu_get_aio_context() !=3D 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 =3D 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 =3D 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; @@ -7357,17 +7222,6 @@ static bool bdrv_parent_change_aio_context(BdrvChild= *c, AioContext *ctx, return true; } =20 -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 =3D 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) @@ -7380,33 +7234,6 @@ bool bdrv_child_change_aio_context(BdrvChild *c, Aio= Context *ctx, return bdrv_change_aio_context(c->bs, ctx, visited, tran, errp); } =20 -/* @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) =3D=3D 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_set_aio_context_clean(void *opaque) { BdrvStateSetAioContext *state =3D (BdrvStateSetAioContext *) opaque; @@ -7499,29 +7326,6 @@ static bool bdrv_change_aio_context(BlockDriverState= *bs, AioContext *ctx, return true; } =20 -int bdrv_child_try_set_aio_context(BlockDriverState *bs, AioContext *ctx, - BdrvChild *ignore_child, Error **errp) -{ - GSList *ignore; - bool ret; - - GLOBAL_STATE_CODE(); - - ignore =3D ignore_child ? g_slist_prepend(NULL, ignore_child) : NULL; - ret =3D bdrv_can_set_aio_context(bs, ctx, &ignore, errp); - g_slist_free(ignore); - - if (!ret) { - return -EPERM; - } - - ignore =3D 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 AioConte= xt * 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 ff417dbff9..a91c8d3916 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); =20 -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 =3D { .attach =3D blk_root_attach, .detach =3D blk_root_detach, =20 - .can_set_aio_ctx =3D blk_root_can_set_aio_ctx, - .set_aio_ctx =3D blk_root_set_aio_ctx, .change_aio_ctx =3D blk_root_change_aio_ctx, =20 .get_parent_aio_context =3D blk_root_get_parent_aio_context, @@ -2233,33 +2227,6 @@ static bool blk_root_change_aio_ctx(BdrvChild *child= , AioContext *ctx, return true; } =20 -static bool blk_root_can_set_aio_ctx(BdrvChild *child, AioContext *ctx, - GSList **ignore, Error **errp) -{ - BlockBackend *blk =3D child->opaque; - - if (blk->allow_aio_context_change) { - return true; - } - - /* Only manually created BlockBackends that are not attached to anythi= ng - * 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 =3D 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 5a783b75c6..2d86014fa5 100644 --- a/blockjob.c +++ b/blockjob.c @@ -170,39 +170,6 @@ static bool child_job_change_aio_ctx(BdrvChild *c, Aio= Context *ctx, return true; } =20 -static bool child_job_can_set_aio_ctx(BdrvChild *c, AioContext *ctx, - GSList **ignore, Error **errp) -{ - BlockJob *job =3D c->opaque; - GSList *l; - - for (l =3D job->nodes; l; l =3D l->next) { - BdrvChild *sibling =3D 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 =3D c->opaque; - GSList *l; - - for (l =3D job->nodes; l; l =3D l->next) { - BdrvChild *sibling =3D l->data; - if (g_slist_find(*ignore, sibling)) { - continue; - } - *ignore =3D 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 =3D c->opaque; @@ -216,8 +183,6 @@ static const BdrvChildClass child_job =3D { .drained_begin =3D child_job_drained_begin, .drained_poll =3D child_job_drained_poll, .drained_end =3D child_job_drained_end, - .can_set_aio_ctx =3D child_job_can_set_aio_ctx, - .set_aio_ctx =3D child_job_set_aio_ctx, .change_aio_ctx =3D child_job_change_aio_ctx, .stay_at_node =3D true, .get_parent_aio_context =3D child_job_get_parent_aio_context, --=20 2.37.3