From nobody Mon Feb 9 08:09:58 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597336515; cv=none; d=zohomail.com; s=zohoarc; b=IETrqjVdyHPd18PlQIByJqA5pxwiC8za8DoEx9UqljvL15yUUWZqeHYwerBGAppAkchY2zVzj3mmrvBDeKf3j0d0fcmW+yOaUm+WMdTWw9jUHNHBJSUxmGvjTySvElxlfl4XZPLTaCn0H/eYYA3lX2mnRooE5tzrohAGyKATiGc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597336515; h=Content-Type: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=N5n33koo/nU4AJfebC0/VU2gJKoJYZDYyejA0Hlgalo=; b=coJDLvoT5GPGCXl3rWNXpgc2iBc7TowMTmZbyQvzjJM6Cf5oSdiZfgrZhiX1gz1oYFCGsgFTH2L5Ho/6W+X7rcVmepXo0tmeAYnJuBrsxZav0FL0VwR8khwKW5VMCZyD4maE6Qp5LrpV6Wl0wvBqWgcr/Vp0QE/iKjKlggdGFIw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597336515057791.0640097021474; Thu, 13 Aug 2020 09:35:15 -0700 (PDT) Received: from localhost ([::1]:37336 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k6GC9-0002xk-48 for importer@patchew.org; Thu, 13 Aug 2020 12:35:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55630) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k6G7T-0002Xl-6D for qemu-devel@nongnu.org; Thu, 13 Aug 2020 12:30:23 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:60727 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k6G7R-0001N9-3k for qemu-devel@nongnu.org; Thu, 13 Aug 2020 12:30:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-488-4vHalRXDMmG3pZA2aZ8WEQ-1; Thu, 13 Aug 2020 12:30:17 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B6A481014DEC; Thu, 13 Aug 2020 16:30:16 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-113-97.ams2.redhat.com [10.36.113.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 933365C1A3; Thu, 13 Aug 2020 16:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597336220; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N5n33koo/nU4AJfebC0/VU2gJKoJYZDYyejA0Hlgalo=; b=TE0j4/NUnOxk0W0m2JKI5+q+osd5DBlQREGduf4+xwLIGZQS0vbwleAMQ0ljae2g0n3mx4 KkWCsAq+0hqPnA8Gjs2WIh9VzTBm0IZ+aZuQfoV0+SRYvbIKGPAaktZND2RNIeYBM6muaw vInaXOEtsR3DA6bOYIh6uyFORLYlzOc= X-MC-Unique: 4vHalRXDMmG3pZA2aZ8WEQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [RFC PATCH 14/22] block/export: Move AioContext from NBDExport to BlockExport Date: Thu, 13 Aug 2020 18:29:27 +0200 Message-Id: <20200813162935.210070-15-kwolf@redhat.com> In-Reply-To: <20200813162935.210070-1-kwolf@redhat.com> References: <20200813162935.210070-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable 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=205.139.110.120; envelope-from=kwolf@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/13 03:44:21 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, 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_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz --- include/block/export.h | 6 ++++++ nbd/server.c | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/include/block/export.h b/include/block/export.h index f44290a4a2..5459f79469 100644 --- a/include/block/export.h +++ b/include/block/export.h @@ -33,6 +33,12 @@ struct BlockExport { * the export. */ int refcount; + + /* + * The AioContex whose lock needs to be held while calling + * BlockExportDriver callbacks. + */ + AioContext *ctx; }; =20 extern const BlockExportDriver blk_exp_nbd; diff --git a/nbd/server.c b/nbd/server.c index 2bf30bb731..b735a68429 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -92,8 +92,6 @@ struct NBDExport { QTAILQ_HEAD(, NBDClient) clients; QTAILQ_ENTRY(NBDExport) next; =20 - AioContext *ctx; - BlockBackend *eject_notifier_blk; Notifier eject_notifier; =20 @@ -1333,8 +1331,8 @@ static coroutine_fn int nbd_negotiate(NBDClient *clie= nt, Error **errp) } =20 /* Attach the channel to the same AioContext as the export */ - if (client->exp && client->exp->ctx) { - qio_channel_attach_aio_context(client->ioc, client->exp->ctx); + if (client->exp && client->exp->common.ctx) { + qio_channel_attach_aio_context(client->ioc, client->exp->common.ct= x); } =20 assert(!client->optlen); @@ -1466,7 +1464,7 @@ static void blk_aio_attached(AioContext *ctx, void *o= paque) =20 trace_nbd_blk_aio_attached(exp->name, ctx); =20 - exp->ctx =3D ctx; + exp->common.ctx =3D ctx; =20 QTAILQ_FOREACH(client, &exp->clients, next) { qio_channel_attach_aio_context(client->ioc, ctx); @@ -1484,13 +1482,13 @@ static void blk_aio_detach(void *opaque) NBDExport *exp =3D opaque; NBDClient *client; =20 - trace_nbd_blk_aio_detach(exp->name, exp->ctx); + trace_nbd_blk_aio_detach(exp->name, exp->common.ctx); =20 QTAILQ_FOREACH(client, &exp->clients, next) { qio_channel_detach_aio_context(client->ioc); } =20 - exp->ctx =3D NULL; + exp->common.ctx =3D NULL; } =20 static void nbd_eject_notifier(Notifier *n, void *data) @@ -1498,7 +1496,7 @@ static void nbd_eject_notifier(Notifier *n, void *dat= a) NBDExport *exp =3D container_of(n, NBDExport, eject_notifier); AioContext *aio_context; =20 - aio_context =3D exp->ctx; + aio_context =3D exp->common.ctx; aio_context_acquire(aio_context); nbd_export_close(exp); aio_context_release(aio_context); @@ -1534,10 +1532,13 @@ NBDExport *nbd_export_new(BlockDriverState *bs, return NULL; } =20 + ctx =3D bdrv_get_aio_context(bs); + exp =3D g_new0(NBDExport, 1); exp->common =3D (BlockExport) { .drv =3D &blk_exp_nbd, .refcount =3D 1, + .ctx =3D ctx, }; =20 /* @@ -1547,7 +1548,7 @@ NBDExport *nbd_export_new(BlockDriverState *bs, * ctx was acquired in the caller. */ assert(name && strlen(name) <=3D NBD_MAX_STRING_SIZE); - ctx =3D bdrv_get_aio_context(bs); + bdrv_invalidate_cache(bs, NULL); =20 /* Don't allow resize while the NBD server is running, otherwise we do= n't @@ -1622,7 +1623,6 @@ NBDExport *nbd_export_new(BlockDriverState *bs, assert(strlen(exp->export_bitmap_context) < NBD_MAX_STRING_SIZE); } =20 - exp->ctx =3D ctx; blk_add_aio_context_notifier(blk, blk_aio_attached, blk_aio_detach, ex= p); =20 blk_exp_ref(&exp->common); @@ -1653,7 +1653,7 @@ NBDExport *nbd_export_find(const char *name) AioContext * nbd_export_aio_context(NBDExport *exp) { - return exp->ctx; + return exp->common.ctx; } =20 void nbd_export_close(NBDExport *exp) @@ -1738,7 +1738,7 @@ void nbd_export_close_all(void) AioContext *aio_context; =20 QTAILQ_FOREACH_SAFE(exp, &exports, next, next) { - aio_context =3D exp->ctx; + aio_context =3D exp->common.ctx; aio_context_acquire(aio_context); nbd_export_close(exp); aio_context_release(aio_context); @@ -2519,7 +2519,7 @@ static void nbd_client_receive_next_request(NBDClient= *client) if (!client->recv_coroutine && client->nb_requests < MAX_NBD_REQUESTS)= { nbd_client_get(client); client->recv_coroutine =3D qemu_coroutine_create(nbd_trip, client); - aio_co_schedule(client->exp->ctx, client->recv_coroutine); + aio_co_schedule(client->exp->common.ctx, client->recv_coroutine); } } =20 --=20 2.25.4