From nobody Fri Nov 14 00:48:07 2025 Delivered-To: importer@patchew.org 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; 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=1583428516; cv=none; d=zohomail.com; s=zohoarc; b=Skpj4U5Xn8KIxB8aeqPjDgqAyym2xP6W64FltXzVlX2vp8bw+A1DqdI41yoq+96kZ6sb1lu8P0xEE5zH1EPoni5qSpsXLrdfyc3AMKDjHk3jhEtACl4BiR6lljNDdKpcFBqUO8bGzpiFE15Ci/Tb9pz589eMwblnqsO4FHDWD+8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1583428516; 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=X5VFQ32SjFxjxWH3wJ7PPjfM9vFVd7gH5+O/oGnhQVw=; b=a2qw3lxhoYGaHskKSNY74lnnBlN3LCPohR3jEt1fXKMH13gfGX6HIoFtk+pE3lrr5+ujr/YoGEXNYe2reVoxSp4ef6jbH3ruqJu9H2R/ZTs+aEPt+lSbRmqX7UzqPUE8ob0Qf0mXl/yCY7SPh70IUhovRoakCYgP353aPFDk/8A= 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 1583428516051545.546954123005; Thu, 5 Mar 2020 09:15:16 -0800 (PST) Received: from localhost ([::1]:53774 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9u5a-0002Om-Q5 for importer@patchew.org; Thu, 05 Mar 2020 12:15:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:38022) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j9tz6-0000KT-73 for qemu-devel@nongnu.org; Thu, 05 Mar 2020 12:08:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j9tz4-0003KL-Q7 for qemu-devel@nongnu.org; Thu, 05 Mar 2020 12:08:32 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:21999 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j9tz4-0003K4-Mr for qemu-devel@nongnu.org; Thu, 05 Mar 2020 12:08:30 -0500 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-67-fZRoV7a0PXeahsHwZUnUhA-1; Thu, 05 Mar 2020 12:08:27 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 707A5107ACCA; Thu, 5 Mar 2020 17:08:26 +0000 (UTC) Received: from localhost (ovpn-117-104.ams2.redhat.com [10.36.117.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 05BE890779; Thu, 5 Mar 2020 17:08:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1583428110; 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=X5VFQ32SjFxjxWH3wJ7PPjfM9vFVd7gH5+O/oGnhQVw=; b=bSz11OBdwfqvGotV9/lNBfHHtBHsKjWxLLQRuDqqiGKhueUWDuY67cdj6v/jCCyNpClKdn f/tTEFsST10L2ozTD+IVXvXFa3ZMAvUWMVHrl0fWjzhMyMqZqipji982LV2fDk4IYYduBQ 0hq/IJv4Fg6PBMTk19p/S9DKTW016ck= X-MC-Unique: fZRoV7a0PXeahsHwZUnUhA-1 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Subject: [PATCH 4/7] aio-posix: simplify FDMonOps->update() prototype Date: Thu, 5 Mar 2020 17:08:03 +0000 Message-Id: <20200305170806.1313245-5-stefanha@redhat.com> In-Reply-To: <20200305170806.1313245-1-stefanha@redhat.com> References: <20200305170806.1313245-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 207.211.31.120 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: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , Paolo Bonzini 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" The AioHandler *node, bool is_new arguments are more complicated to think about than simply being given AioHandler *old_node, AioHandler *new_node. Furthermore, the new Linux io_uring file descriptor monitoring mechanism added by the new patch requires access to both the old and the new nodes. Make this change now in preparation. Signed-off-by: Stefan Hajnoczi --- include/block/aio.h | 13 ++++++------- util/aio-posix.c | 7 +------ util/fdmon-epoll.c | 21 ++++++++++++--------- util/fdmon-poll.c | 4 +++- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index 90e07d7507..bd76b08f1a 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -57,17 +57,16 @@ typedef struct { /* * update: * @ctx: the AioContext - * @node: the handler - * @is_new: is the file descriptor already being monitored? + * @old_node: the existing handler or NULL if this file descriptor is = being + * monitored for the first time + * @new_node: the new handler or NULL if this file descriptor is being + * removed * - * Add/remove/modify a monitored file descriptor. There are three cas= es: - * 1. node->pfd.events =3D=3D 0 means remove the file descriptor. - * 2. !is_new means modify an already monitored file descriptor. - * 3. is_new means add a new file descriptor. + * Add/remove/modify a monitored file descriptor. * * Called with ctx->list_lock acquired. */ - void (*update)(AioContext *ctx, AioHandler *node, bool is_new); + void (*update)(AioContext *ctx, AioHandler *old_node, AioHandler *new_= node); =20 /* * wait: diff --git a/util/aio-posix.c b/util/aio-posix.c index 4d97b4c7de..3b9aad4ca7 100644 --- a/util/aio-posix.c +++ b/util/aio-posix.c @@ -139,12 +139,7 @@ void aio_set_fd_handler(AioContext *ctx, atomic_set(&ctx->poll_disable_cnt, atomic_read(&ctx->poll_disable_cnt) + poll_disable_change); =20 - if (new_node) { - ctx->fdmon_ops->update(ctx, new_node, is_new); - } else if (node) { - /* Unregister deleted fd_handler */ - ctx->fdmon_ops->update(ctx, node, false); - } + ctx->fdmon_ops->update(ctx, node, new_node); qemu_lockcnt_unlock(&ctx->list_lock); aio_notify(ctx); =20 diff --git a/util/fdmon-epoll.c b/util/fdmon-epoll.c index 29c1454469..d56b69468b 100644 --- a/util/fdmon-epoll.c +++ b/util/fdmon-epoll.c @@ -30,21 +30,24 @@ static inline int epoll_events_from_pfd(int pfd_events) (pfd_events & G_IO_ERR ? EPOLLERR : 0); } =20 -static void fdmon_epoll_update(AioContext *ctx, AioHandler *node, bool is_= new) +static void fdmon_epoll_update(AioContext *ctx, + AioHandler *old_node, + AioHandler *new_node) { - struct epoll_event event; + struct epoll_event event =3D { + .data.ptr =3D new_node, + .events =3D new_node ? epoll_events_from_pfd(new_node->pfd.events)= : 0, + }; int r; - int ctl; =20 - if (!node->pfd.events) { - ctl =3D EPOLL_CTL_DEL; + if (!new_node) { + r =3D epoll_ctl(ctx->epollfd, EPOLL_CTL_DEL, old_node->pfd.fd, &ev= ent); + } else if (!old_node) { + r =3D epoll_ctl(ctx->epollfd, EPOLL_CTL_ADD, new_node->pfd.fd, &ev= ent); } else { - event.data.ptr =3D node; - event.events =3D epoll_events_from_pfd(node->pfd.events); - ctl =3D is_new ? EPOLL_CTL_ADD : EPOLL_CTL_MOD; + r =3D epoll_ctl(ctx->epollfd, EPOLL_CTL_MOD, new_node->pfd.fd, &ev= ent); } =20 - r =3D epoll_ctl(ctx->epollfd, ctl, node->pfd.fd, &event); if (r) { fdmon_epoll_disable(ctx); } diff --git a/util/fdmon-poll.c b/util/fdmon-poll.c index 67992116b8..28114a0f39 100644 --- a/util/fdmon-poll.c +++ b/util/fdmon-poll.c @@ -93,7 +93,9 @@ static int fdmon_poll_wait(AioContext *ctx, AioHandlerLis= t *ready_list, return ret; } =20 -static void fdmon_poll_update(AioContext *ctx, AioHandler *node, bool is_n= ew) +static void fdmon_poll_update(AioContext *ctx, + AioHandler *old_node, + AioHandler *new_node) { /* Do nothing, AioHandler already contains the state we'll need */ } --=20 2.24.1