From nobody Fri Apr 11 22:47:15 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=1665140217; cv=none; d=zohomail.com; s=zohoarc; b=hkxNkNM+N2QQDsFdTGg2lMIcMrwrqUfffyojHPDNOQ52nsFoyEyhy7DYtli249MJyMIAyY+psoDz07uwdvyMlUZkVUCrxxJRuQDLgkIj3Rz/Bq6SIqQZxImy5DXp7PSq3L+0YyhIQc+NSuDNbRFQxDhM88jyrtnm51dw3hA1PG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665140217; 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=HYk2jP3gwMWLWOqCMmqtTDNqJqGs7xLs74vG7fNqpB8=; b=dHjxS/0WMVQm5AuZdn5budyNiHSEciCLoDRCnQPfX13TFTZrl8EdoLWzBHIYniLVHqCuzMlcQ1tG5Ik/nZN5a27M3z8cpA/R/79clZOq0ST0AIT+CWZrxJHu73DcizvlzoRiWfSEUzTaMr2L1sfTqbh0r91vTGBw56W6D0bSmb8= 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 1665140217104626.4776837371754; Fri, 7 Oct 2022 03:56:57 -0700 (PDT) Received: from localhost ([::1]:52886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogl2G-0000b2-0Z for importer@patchew.org; Fri, 07 Oct 2022 06:56:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45378) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktj-0005NI-Lq for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48785) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkth-00034c-5v for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:07 -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-21-eC_I1ShPPz2ysP5ehIsvPw-1; Fri, 07 Oct 2022 06:48:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AC4AF862FE2; Fri, 7 Oct 2022 10:48:01 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id E8D572028DC1; Fri, 7 Oct 2022 10:48:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139683; 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=HYk2jP3gwMWLWOqCMmqtTDNqJqGs7xLs74vG7fNqpB8=; b=UV+M45BeIySwV18n9SMO1SunbF94DqR3XReoTM5ev4HGwDiQ7u1DHKlL0GAS7kH6dDYpAt 8brZlpmaW1GnLHdBScPTQtGaDI6/INFrQQ1Lh80z3JfHvQxATdHujCjEYOQJIBo6I5rumo itTbflXEst9Oz5iv6ueA+d2rVEob3ac= X-MC-Unique: eC_I1ShPPz2ysP5ehIsvPw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 01/50] Revert "qapi: fix examples of blockdev-add with qcow2" Date: Fri, 7 Oct 2022 12:47:03 +0200 Message-Id: <20221007104752.141361-2-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665140218865100001 Content-Type: text/plain; charset="utf-8" From: Markus Armbruster This reverts commit b6522938327141235b97ab38e40c6c4512587373. Kevin Wolf NAKed this patch, because: 'file' is a required member (defined in BlockdevOptionsGenericFormat), removing it makes the example invalid. 'data-file' is only an additional optional member to be used for external data files (i.e. when the guest data is kept separate from the metadata in the .qcow2 file). However, it had already been merged then. Revert. Signed-off-by: Markus Armbruster Message-Id: <20220930171908.846769-1-armbru@redhat.com> Reviewed-by: Victor Toso Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- qapi/block-core.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qapi/block-core.json b/qapi/block-core.json index f21fa235f2..882b266532 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -1541,8 +1541,8 @@ # -> { "execute": "blockdev-add", # "arguments": { "driver": "qcow2", # "node-name": "node1534", -# "data-file": { "driver": "file", -# "filename": "hd1.qcow2" }, +# "file": { "driver": "file", +# "filename": "hd1.qcow2" }, # "backing": null } } # # <- { "return": {} } @@ -4378,7 +4378,7 @@ # "arguments": { # "driver": "qcow2", # "node-name": "test1", -# "data-file": { +# "file": { # "driver": "file", # "filename": "test.qcow2" # } @@ -4395,7 +4395,7 @@ # "cache": { # "direct": true # }, -# "data-file": { +# "file": { # "driver": "file", # "filename": "/tmp/test.qcow2" # }, @@ -4477,7 +4477,7 @@ # "arguments": { # "driver": "qcow2", # "node-name": "node0", -# "data-file": { +# "file": { # "driver": "file", # "filename": "test.qcow2" # } --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141586; cv=none; d=zohomail.com; s=zohoarc; b=gRC6T54kxWZ0VLhJ4/E76ZxociNBkiwLbkx5EU6X4zfFOmhHgjx2Q2nvYv09SLKrFidFhSKeaDXlyPYLjPJMWM647BvYtrnnFZVe6CueoGYg4ZIMLvwlAZyr3zue0Pd0Ow/cGKaUFeioQCAxs4lqYm7duNQnKy9i3qAr/kL8KcE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141586; 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=KH9ecPfpCDGtNqTteMztaemnMjGKkKmgqXChdWnE9Ro=; b=XsiORn6Q9OTfxA287jplXKnaHMc/gwJh7ZzWByptOrF8ug8cukI29QX0xzkfXzIZdFLhBBz6hpH5I8d/GjXQloSstFQaSlhfyWYB3byCiyQB4a95/R0V11krp9QprW0OK7xgwnCRdtylvEoLToM4nCPn3hpSN84qobIH0YaIaR0= 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 166514158689873.10092011603592; Fri, 7 Oct 2022 04:19:46 -0700 (PDT) Received: from localhost ([::1]:55456 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglOL-0003Iw-DW for importer@patchew.org; Fri, 07 Oct 2022 07:19:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45376) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktj-0005Ld-CP for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58311) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkth-00034g-0p for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:06 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-37-ZePZvM9DN7GSVyklyvZLuQ-1; Fri, 07 Oct 2022 06:48:03 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A46D0382624C; Fri, 7 Oct 2022 10:48:02 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id E44A62028DC1; Fri, 7 Oct 2022 10:48:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139684; 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=KH9ecPfpCDGtNqTteMztaemnMjGKkKmgqXChdWnE9Ro=; b=OmuO5PvHqlky91WLQtirsoqMLKcnlY6EaEawzUB88W48EQiGXUf1ipWZfHCeyIHs6u/LQ+ h/SdB5BS3f3FS+merHTlGN5+ZjvJHJEnEnIgOFQ3zguqTnmDhCT4/7XQIvKgZwLKchta50 vY4Xf/hheuQPlK1q0M6LANffFxaKSRg= X-MC-Unique: ZePZvM9DN7GSVyklyvZLuQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 02/50] coroutine: Drop coroutine_fn annotation from qemu_coroutine_self() Date: Fri, 7 Oct 2022 12:47:04 +0200 Message-Id: <20221007104752.141361-3-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141589099100001 Content-Type: text/plain; charset="utf-8" From: Alberto Faria qemu_coroutine_self() can be called from outside coroutine context, returning the leader coroutine, and several such invocations currently exist (mostly in qcow2 tracing calls). Signed-off-by: Alberto Faria Message-Id: <20221005175209.975797-1-afaria@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf --- include/qemu/coroutine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 08c5bb3c76..414b677302 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -97,7 +97,7 @@ AioContext *coroutine_fn qemu_coroutine_get_aio_context(C= oroutine *co); /** * Get the currently executing coroutine */ -Coroutine *coroutine_fn qemu_coroutine_self(void); +Coroutine *qemu_coroutine_self(void); =20 /** * Return whether or not currently inside a coroutine --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141201; cv=none; d=zohomail.com; s=zohoarc; b=Xfri9Tab1N29Ct3hW4/rDNjvnix94FTY4lGiqEIGnNYQptNOHvWVFwQQZhA5s5xciWdHtx267jNZcLq/9i+x5yJd7PJ4MMo5tK0yuBLRI9ELBSLxk1jAv/X6iz8S2AaTTjzz6jCMH195uPUVlpMJrh7JoZhsXePkEBCLpWQQAPI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141201; 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=rPGLStqfSRWeoJcwTxaRu0W43qQhKFRZOxVoH3u8sXw=; b=I2+etY/qGlaP94mSMkZNrCPg3DtzC1IO8VmpjF+earKMylhWA4XWl148ssUnJXooeXr7l1D4aK1XeaLty0DWFMWMPpUxNXE60bmu4PkK3MyzGzHDDJlNMpSsMqKqamZhqaaMY7zW6pE3CM3Hsm5hUx+rruez+Y4Qc6vGliW3Eb4= 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 1665141201960810.3299694239118; Fri, 7 Oct 2022 04:13:21 -0700 (PDT) Received: from localhost ([::1]:34836 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglI8-0006Is-Qq for importer@patchew.org; Fri, 07 Oct 2022 07:13:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34506) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkts-0005PK-6h for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57747) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktp-00036F-0I for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:15 -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-85-pmoya3qrMnm-JjGpgQOGTA-1; Fri, 07 Oct 2022 06:48:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A0889811E87; Fri, 7 Oct 2022 10:48:03 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id DD7122024CBB; Fri, 7 Oct 2022 10:48:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139689; 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=rPGLStqfSRWeoJcwTxaRu0W43qQhKFRZOxVoH3u8sXw=; b=ORiw7a5zIcqnSzWsNbnEp2wdpRJfCA+wQoQADaOlN0qe92O3dMOMMZ8MfYkM/f8PQ9rO74 5o/6seHPpGreDIP7uUjhHjCjf4s+zTr1gfVa+29QtFOrf2uPD0Yl+ghprgCEkbMZsVmotP Pw3X4rK20YtFnLoqsxZFv6s3CXeyZT8= X-MC-Unique: pmoya3qrMnm-JjGpgQOGTA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 03/50] block/nvme: separate nvme_get_free_req cases for coroutine/non-coroutine context Date: Fri, 7 Oct 2022 12:47:05 +0200 Message-Id: <20221007104752.141361-4-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141204253100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini nvme_get_free_req has very difference semantics when called in coroutine context (where it waits) and in non-coroutine context (where it doesn't). Split the two cases to make it clear what is being requested. Cc: qemu-block@nongnu.org Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-2-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/nvme.c | 48 ++++++++++++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 01fb28aa63..0870f87bc6 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -293,34 +293,42 @@ static void nvme_kick(NVMeQueuePair *q) q->need_kick =3D 0; } =20 -/* Find a free request element if any, otherwise: - * a) if in coroutine context, try to wait for one to become available; - * b) if not in coroutine, return NULL; - */ -static NVMeRequest *nvme_get_free_req(NVMeQueuePair *q) +static NVMeRequest *nvme_get_free_req_nofail_locked(NVMeQueuePair *q) { NVMeRequest *req; =20 - qemu_mutex_lock(&q->lock); - - while (q->free_req_head =3D=3D -1) { - if (qemu_in_coroutine()) { - trace_nvme_free_req_queue_wait(q->s, q->index); - qemu_co_queue_wait(&q->free_req_queue, &q->lock); - } else { - qemu_mutex_unlock(&q->lock); - return NULL; - } - } - req =3D &q->reqs[q->free_req_head]; q->free_req_head =3D req->free_req_next; req->free_req_next =3D -1; - - qemu_mutex_unlock(&q->lock); return req; } =20 +/* Return a free request element if any, otherwise return NULL. */ +static NVMeRequest *nvme_get_free_req_nowait(NVMeQueuePair *q) +{ + QEMU_LOCK_GUARD(&q->lock); + if (q->free_req_head =3D=3D -1) { + return NULL; + } + return nvme_get_free_req_nofail_locked(q); +} + +/* + * Wait for a free request to become available if necessary, then + * return it. + */ +static coroutine_fn NVMeRequest *nvme_get_free_req(NVMeQueuePair *q) +{ + QEMU_LOCK_GUARD(&q->lock); + + while (q->free_req_head =3D=3D -1) { + trace_nvme_free_req_queue_wait(q->s, q->index); + qemu_co_queue_wait(&q->free_req_queue, &q->lock); + } + + return nvme_get_free_req_nofail_locked(q); +} + /* With q->lock */ static void nvme_put_free_req_locked(NVMeQueuePair *q, NVMeRequest *req) { @@ -506,7 +514,7 @@ static int nvme_admin_cmd_sync(BlockDriverState *bs, Nv= meCmd *cmd) AioContext *aio_context =3D bdrv_get_aio_context(bs); NVMeRequest *req; int ret =3D -EINPROGRESS; - req =3D nvme_get_free_req(q); + req =3D nvme_get_free_req_nowait(q); if (!req) { return -EBUSY; } --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141924; cv=none; d=zohomail.com; s=zohoarc; b=lfd06YZiWN8ZOuf3HZFFabNut9IRpqfXficzYXE3ysRq9+ugb+URRzyL3nX0fj5QdxM38Mld1wx8M+IxSdDUcXbtjEnOJso42wxodutOs/B8JeJJJ/nzm5rfKtKEVpR6v3wOx4rjpuIu2H1K/hwPFgVFKih8zBnj9R/6SVyt52k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141924; 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=v8xvN39iU961FppPbmR0E62c3pd08SKYbcd6d0IDE0I=; b=DwkLyl1VP9db4H33xaAI1ihuZrIL8u+g4gpXMBRnTp01ZAYCgeYl9469amblMhoqRuAwRQgtHk4Wp5NU3tYeUCJLpIQEkvM7ulfDjwXPRDXiIR0YcwGVbncgAlqcuHw71RUqb4nNlEPdivlrh0RyxX/9EgtGFYuizTM+8ASEaI8= 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 166514192472010.356389160862363; Fri, 7 Oct 2022 04:25:24 -0700 (PDT) Received: from localhost ([::1]:39370 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglTn-0005yB-Fs for importer@patchew.org; Fri, 07 Oct 2022 07:25:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45394) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktq-0005PC-Rv for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:32421) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkto-00035j-W8 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:14 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-609-BB-zxB2YNLqsjzaisxcTtw-1; Fri, 07 Oct 2022 06:48:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9C3F03826244; Fri, 7 Oct 2022 10:48:04 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id D854D2028DC1; Fri, 7 Oct 2022 10:48:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139688; 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=v8xvN39iU961FppPbmR0E62c3pd08SKYbcd6d0IDE0I=; b=U/Pi26WE9gC55vhWlSkBkZU03r1nBDOv7/Uw3+oqwnQzcYinOE3AEeWK3DTpoFWfp8BLE+ RqJLCKXkm1Cijfr3WCmUA9HtOdgpruh768X/benSUz3/PMDrD966sa34KX9Oqt3/8RF/9D GGbaNmauEUtEqTVCCjHA8/DACXA0Pvk= X-MC-Unique: BB-zxB2YNLqsjzaisxcTtw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 04/50] block: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:06 +0200 Message-Id: <20221007104752.141361-5-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141925792100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-3-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 7 ++++--- block/block-backend.c | 10 +++++----- block/io.c | 22 +++++++++++----------- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/block.c b/block.c index bc85f46eed..9b0fae5c1e 100644 --- a/block.c +++ b/block.c @@ -631,9 +631,10 @@ static int64_t create_file_fallback_truncate(BlockBack= end *blk, * Helper function for bdrv_create_file_fallback(): Zero the first * sector to remove any potentially pre-existing image header. */ -static int create_file_fallback_zero_first_sector(BlockBackend *blk, - int64_t current_size, - Error **errp) +static int coroutine_fn +create_file_fallback_zero_first_sector(BlockBackend *blk, + int64_t current_size, + Error **errp) { int64_t bytes_to_clear; int ret; diff --git a/block/block-backend.c b/block/block-backend.c index d4a5df2ac2..aa4adf06ae 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1546,7 +1546,7 @@ static BlockAIOCB *blk_aio_prwv(BlockBackend *blk, in= t64_t offset, return &acb->common; } =20 -static void blk_aio_read_entry(void *opaque) +static void coroutine_fn blk_aio_read_entry(void *opaque) { BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; @@ -1558,7 +1558,7 @@ static void blk_aio_read_entry(void *opaque) blk_aio_complete(acb); } =20 -static void blk_aio_write_entry(void *opaque) +static void coroutine_fn blk_aio_write_entry(void *opaque) { BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; @@ -1669,7 +1669,7 @@ int coroutine_fn blk_co_ioctl(BlockBackend *blk, unsi= gned long int req, return ret; } =20 -static void blk_aio_ioctl_entry(void *opaque) +static void coroutine_fn blk_aio_ioctl_entry(void *opaque) { BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; @@ -1703,7 +1703,7 @@ blk_co_do_pdiscard(BlockBackend *blk, int64_t offset,= int64_t bytes) return bdrv_co_pdiscard(blk->root, offset, bytes); } =20 -static void blk_aio_pdiscard_entry(void *opaque) +static void coroutine_fn blk_aio_pdiscard_entry(void *opaque) { BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; @@ -1747,7 +1747,7 @@ static int coroutine_fn blk_co_do_flush(BlockBackend = *blk) return bdrv_co_flush(blk_bs(blk)); } =20 -static void blk_aio_flush_entry(void *opaque) +static void coroutine_fn blk_aio_flush_entry(void *opaque) { BlkAioEmAIOCB *acb =3D opaque; BlkRwCo *rwco =3D &acb->rwco; diff --git a/block/io.c b/block/io.c index c3200bcdff..d30073036e 100644 --- a/block/io.c +++ b/block/io.c @@ -751,11 +751,11 @@ static void coroutine_fn tracked_request_end(BdrvTrac= kedRequest *req) /** * Add an active request to the tracked requests list */ -static void tracked_request_begin(BdrvTrackedRequest *req, - BlockDriverState *bs, - int64_t offset, - int64_t bytes, - enum BdrvTrackedRequestType type) +static void coroutine_fn tracked_request_begin(BdrvTrackedRequest *req, + BlockDriverState *bs, + int64_t offset, + int64_t bytes, + enum BdrvTrackedRequestType= type) { bdrv_check_request(offset, bytes, &error_abort); =20 @@ -794,7 +794,7 @@ static bool tracked_request_overlaps(BdrvTrackedRequest= *req, } =20 /* Called with self->bs->reqs_lock held */ -static BdrvTrackedRequest * +static coroutine_fn BdrvTrackedRequest * bdrv_find_conflicting_request(BdrvTrackedRequest *self) { BdrvTrackedRequest *req; @@ -1635,10 +1635,10 @@ static bool bdrv_init_padding(BlockDriverState *bs, return true; } =20 -static int bdrv_padding_rmw_read(BdrvChild *child, - BdrvTrackedRequest *req, - BdrvRequestPadding *pad, - bool zero_middle) +static coroutine_fn int bdrv_padding_rmw_read(BdrvChild *child, + BdrvTrackedRequest *req, + BdrvRequestPadding *pad, + bool zero_middle) { QEMUIOVector local_qiov; BlockDriverState *bs =3D child->bs; @@ -3159,7 +3159,7 @@ out: return ret; } =20 -int bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf) +int coroutine_fn bdrv_co_ioctl(BlockDriverState *bs, int req, void *buf) { BlockDriver *drv =3D bs->drv; CoroutineIOCompletion co =3D { --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141228; cv=none; d=zohomail.com; s=zohoarc; b=IF7jJz1uDoaIYO+DXn6H80Tf6VVmDbVqBXQ4YD3LFMqzXLe9SGonZSQ2u09e0K6AQgZUIxeTn9IxQ2Xdhvnpxuj17kjmCyBt99xwbmBntxLmKf8cDcB+X+S1vP0is16YB9AtM3GoxgrVAm5AcM97xzgD0kjretgKwZjczKpoLQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141228; 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=DYQmifpXabA4X2AnkNxjTfP5E8KXDHOPRVp/pQZDFrw=; b=mQND+jNbNjtawB99BOSdWYTTO2HgULPnh1/1skieABTsKp0Q4vHOoTupXpyEK4mW8d+vDQX8qAcQx0mBAM61d0Vje1bA1mMFA6+wlGimM4uYgPIqW+Xdy1lL4dzjheLuoR+cx2QGXZooATkl80ikEC7JTKTkdASDm7T57LFKBng= 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 1665141228338358.806374515064; Fri, 7 Oct 2022 04:13:48 -0700 (PDT) Received: from localhost ([::1]:35098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglIZ-00076Q-Br for importer@patchew.org; Fri, 07 Oct 2022 07:13:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45384) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktl-0005Os-4v for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:15 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59193) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktj-00035G-KE for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:08 -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-590-pS0qCCEmPrCBeqPd68IfKA-1; Fri, 07 Oct 2022 06:48:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 96FEF101A528; Fri, 7 Oct 2022 10:48:05 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id D4A322024CBB; Fri, 7 Oct 2022 10:48:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139687; 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=DYQmifpXabA4X2AnkNxjTfP5E8KXDHOPRVp/pQZDFrw=; b=E2YZBxuqnkERdzpaPk5xAu3iiVr2S08/x7+6OBKUWKKeoBbQd4e4/Zsfr+aTtg6qUUcvTZ R4UlmOUSfgueYVSJosMGemWJZ9xkQQledVEgOEf/QkoSgUWGJTm23nDeDlKPzKv3fjid29 s6wUOPBSavjgfd5EvO+u/JFTAmnamh8= X-MC-Unique: pS0qCCEmPrCBeqPd68IfKA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 05/50] qcow2: remove incorrect coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:07 +0200 Message-Id: <20221007104752.141361-6-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141230277100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini This is incorrect because qcow2_mark_clean() calls qcow2_flush_caches(). qcow2_mark_clean() is called from non-coroutine context in qcow2_inactivate() and qcow2_amend_options(). Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-4-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/qcow2.h | 4 ++-- block/qcow2-refcount.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index ba436a8d0d..c8d9e8ea79 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -874,8 +874,8 @@ void qcow2_free_any_cluster(BlockDriverState *bs, uint6= 4_t l2_entry, int qcow2_update_snapshot_refcount(BlockDriverState *bs, int64_t l1_table_offset, int l1_size, int addend); =20 -int coroutine_fn qcow2_flush_caches(BlockDriverState *bs); -int coroutine_fn qcow2_write_caches(BlockDriverState *bs); +int qcow2_flush_caches(BlockDriverState *bs); +int qcow2_write_caches(BlockDriverState *bs); int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix); =20 diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index c4d99817b6..1a6277c783 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1206,7 +1206,7 @@ void qcow2_free_any_cluster(BlockDriverState *bs, uin= t64_t l2_entry, } } =20 -int coroutine_fn qcow2_write_caches(BlockDriverState *bs) +int qcow2_write_caches(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; int ret; @@ -1226,7 +1226,7 @@ int coroutine_fn qcow2_write_caches(BlockDriverState = *bs) return 0; } =20 -int coroutine_fn qcow2_flush_caches(BlockDriverState *bs) +int qcow2_flush_caches(BlockDriverState *bs) { int ret =3D qcow2_write_caches(bs); if (ret < 0) { --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665140277; cv=none; d=zohomail.com; s=zohoarc; b=hoGxWh9ffzanQchTPplIJWnCF7ZaLtcoqGvBGBv1RFyvcvthZxqkjjouzq8iSC8Aq/10FluHnKZ47zEAcMv1746zb6oSPmMVRtxRVh2pAKK2VmJfdAj/Qe3VWjMyB7FQ04+rZZWG9Bz5QK+tgOTy6E+jlt9iBt3p8JjA2QhNyl8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665140277; 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=iMx0BlH40I5oytPM1g8+WFNlkj+8vJwA5jh1izJZAZY=; b=Bs/V1onFAQtsguAuvBoCg2DhSvYNasdfguhslqy7Xd2KDY/S7thtwwXEgz52RsopcD+NIdXV1yWgxjSy55DFIQx3AGZFrk7VPziKjW7NTf4g7HuDKDXTQjydwO6hcS3XFFOuoUNe10gCmmFLk5GelG93/9kYe2zEwQKyz7I7XO8= 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 1665140277437414.5894186298216; Fri, 7 Oct 2022 03:57:57 -0700 (PDT) Received: from localhost ([::1]:47460 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogl3D-0001j9-Dk for importer@patchew.org; Fri, 07 Oct 2022 06:57:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34520) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktt-0005PW-Ok for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37394) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktp-00036M-CA for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:17 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-19-YNRH_wx9PcuDQs2jkYpPOA-1; Fri, 07 Oct 2022 06:48:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9468F1C0515C; Fri, 7 Oct 2022 10:48:06 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id CFE372024CBB; Fri, 7 Oct 2022 10:48:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139690; 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=iMx0BlH40I5oytPM1g8+WFNlkj+8vJwA5jh1izJZAZY=; b=UHd3HunOR0VQ9LS3a0Ythks6Uw3zM4WnsBRMxbKAZaIsEwfADD2G6Vc0zkCLp61FeXXXtW lFizuuBsCtwVwphHzlNrv5q57hyIruB+0PsCcCm3D9VkHe/uoCOEl/7Dd5KaiVJ5P2+jcF Uj4InNnmgeNkLs3ncAgaRKJqlkhf8Ls= X-MC-Unique: YNRH_wx9PcuDQs2jkYpPOA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 06/50] nbd: remove incorrect coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:08 +0200 Message-Id: <20221007104752.141361-7-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665140277998100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini nbd_co_establish_connection_cancel() cancels a coroutine but is not called from coroutine context itself, for example in nbd_cancel_in_flight() and in timer callbacks reconnect_delay_timer_cb() and open_timer_cb(). Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-5-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/nbd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/block/nbd.h b/include/block/nbd.h index c74b7a9d2e..4ede3b2bd0 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -424,6 +424,6 @@ QIOChannel *coroutine_fn nbd_co_establish_connection(NBDClientConnection *conn, NBDExportInfo *info, bool blocking, Error **errp); =20 -void coroutine_fn nbd_co_establish_connection_cancel(NBDClientConnection *= conn); +void nbd_co_establish_connection_cancel(NBDClientConnection *conn); =20 #endif --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665142186; cv=none; d=zohomail.com; s=zohoarc; b=beiRPFf6ZHbyRUNkFRgx5KcO2GYEAuHMFQoOXaHrqKDjmuvLqJl5K1qYeOs913C4N4ReGWeSdebJ/cWGYg0Mo2WC78gaOHw9RFepkC9wY0OYCqX876HwdacgT8Oeal1Bd+RLR0ZzeRP9RuWCRzJQYQmROwfGXJ0z5ZlUX1uofD8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665142186; 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=NUvz7xynFawGgr2XSghEm6iDllUZfUc8HxABBcVLalA=; b=lYWojJ5ZfmIFZc7xxtIkUUBDgAOlUKvik4kUhdiLpL/kwbB/pejB4eMNQhXR9Rw6Jyf2eERbXblLfpbP0swyyvoyh+CMsgB2MheKoxjFFLmFJdWlX9vKIae2gthhOQHeU/EiM+uL1MIHUymKPPxGlr6+j3hrM31avXcueVv3WPs= 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 1665142186591448.5221151965594; Fri, 7 Oct 2022 04:29:46 -0700 (PDT) Received: from localhost ([::1]:58868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglY1-0001z7-CP for importer@patchew.org; Fri, 07 Oct 2022 07:29:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktt-0005PY-QF for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53362) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktp-00036V-Cc for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:17 -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-170-SQ-5RE07N4mM1w93SSvP0w-1; Fri, 07 Oct 2022 06:48:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90E07185A78F; Fri, 7 Oct 2022 10:48:07 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id CDE9A2024CBB; Fri, 7 Oct 2022 10:48:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139690; 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=NUvz7xynFawGgr2XSghEm6iDllUZfUc8HxABBcVLalA=; b=XReaYHQfCGKRyytpS8qaST7G1E+Lg6AeldfE3uBnuH/3rzAzdoH44kJcOfYYOIM/T2T8pu KevPJ5cWJNLq21hpsJbXQQiBIaU7iTEi1A14FJb+mPUoRBA3APxgK3Bvf4TfSmgp2i0tST fWD7uNpDJQaQKEMf3rbfPgwuMfraAEQ= X-MC-Unique: SQ-5RE07N4mM1w93SSvP0w-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 07/50] coroutine: remove incorrect coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:09 +0200 Message-Id: <20221007104752.141361-8-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665142187017100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini qemu_coroutine_get_aio_context inspects a coroutine, but it does not have to be called from the coroutine itself (or from any coroutine). Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-6-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/qemu/coroutine.h | 2 +- util/qemu-coroutine.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/coroutine.h b/include/qemu/coroutine.h index 414b677302..aae33cce17 100644 --- a/include/qemu/coroutine.h +++ b/include/qemu/coroutine.h @@ -92,7 +92,7 @@ void coroutine_fn qemu_coroutine_yield(void); /** * Get the AioContext of the given coroutine */ -AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co); +AioContext *qemu_coroutine_get_aio_context(Coroutine *co); =20 /** * Get the currently executing coroutine diff --git a/util/qemu-coroutine.c b/util/qemu-coroutine.c index 4a8bd63ef0..356b746f0b 100644 --- a/util/qemu-coroutine.c +++ b/util/qemu-coroutine.c @@ -213,7 +213,7 @@ bool qemu_coroutine_entered(Coroutine *co) return co->caller; } =20 -AioContext *coroutine_fn qemu_coroutine_get_aio_context(Coroutine *co) +AioContext *qemu_coroutine_get_aio_context(Coroutine *co) { return co->ctx; } --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665143037; cv=none; d=zohomail.com; s=zohoarc; b=WOFTQdEwE1wye2HxD1d29bZDW6hbQvsHEww6yuH6U3jNXslSw/6Am4Rx7RjhsTztQDdo68GU9+v8u1CxTpC8CtBVbHmWAZiR7T6Io2a7dENIka8Dti7ND4rlmjCOEvJEwUD+j9CfFO5Hn1QbX7zOOuDuvbRDSdltUmOswpYA4qE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143037; 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=9FrOCpNbSrm/fB1htVisXzeVq/NUpDkNFztzawrYxLA=; b=NyOieGPyiRfZzpmTNCLVJ29dgfnjytEf75X7Y7N2g/UVnseB95s5nfmwLzX5p+Dn1u8cm96YA0AnB6FfDt7sX1nuKTNWL+X2I8yZYNn3j6DIiZA7sLgtE61iwWYldi41Xivhm26eD2KVcsy8hskjcZzhcNcLb9B079CyF+jEEq4= 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 1665143037756780.7896580619084; Fri, 7 Oct 2022 04:43:57 -0700 (PDT) Received: from localhost ([::1]:41510 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogllk-0002JD-Ht for importer@patchew.org; Fri, 07 Oct 2022 07:43:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktt-0005PX-Pg for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29547) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktp-00036f-C4 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:17 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-301-2NAPaHAxP_iZsrCcsgYPpQ-1; Fri, 07 Oct 2022 06:48:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E8AE3826244; Fri, 7 Oct 2022 10:48:08 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id C86432024CBB; Fri, 7 Oct 2022 10:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139692; 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=9FrOCpNbSrm/fB1htVisXzeVq/NUpDkNFztzawrYxLA=; b=NYBQCyKFrmiljk/FXUulCI948JKyzIuCcjgURJqE/ZRtkUu6c3YCNA/OEYij6oE48fY+6G pHqou5GR2v/cXskKUGE/vdJvc6rDf+GTiLO1OHkKv5tdZOJWc+DuxgJ+BMZtO8rv/gy9iC bhO8djeCCdFR20lMzb4O9Jg980Q4dJo= X-MC-Unique: 2NAPaHAxP_iZsrCcsgYPpQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 08/50] blkverify: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:10 +0200 Message-Id: <20221007104752.141361-9-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143038062100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-8-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/blkverify.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blkverify.c b/block/blkverify.c index e4a37af3b2..020b1ae7b6 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -258,7 +258,7 @@ blkverify_co_pwritev(BlockDriverState *bs, int64_t offs= et, int64_t bytes, return blkverify_co_prwv(bs, &r, offset, bytes, qiov, qiov, flags, tru= e); } =20 -static int blkverify_co_flush(BlockDriverState *bs) +static int coroutine_fn blkverify_co_flush(BlockDriverState *bs) { BDRVBlkverifyState *s =3D bs->opaque; =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665142309; cv=none; d=zohomail.com; s=zohoarc; b=jk9qdSqPG4XOPY0hB1bGkNmrVe5l05qY4NFUIoM9jjrRZY0zdVY8GDWs7avwyTWbLBuDj7dQXZn+ULc3KJR+jjhCdfhmr3nf7BLlEACDmzb+4loIxYMAWzP7Ta2xpgH0HJAIM8FC68kM85LDMFjIu0qE4iHnjZYRpTKV5Z+6LVk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665142309; 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=BPvqrzSQ8Ew+2BiialqzhyDw+N0EXMDvXACwut/L4/8=; b=AUYbN92wJAd+W1F9f5mbvgWl0lqVKHLWCLeGvsPBZv4caeviUo2xWf5Haa9xVTjSQsxBkCX0TbIwqIROKBQfBi81ufrTykA9j60tyBqBrlq3HN9cspHAmblJbW8ZDud1E05BGe/stdFoaLfNxmhvktXlV+g/8/BOPnT0XWzUu0w= 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 1665142309271588.3033518302022; Fri, 7 Oct 2022 04:31:49 -0700 (PDT) Received: from localhost ([::1]:52280 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogla0-0003mD-8g for importer@patchew.org; Fri, 07 Oct 2022 07:31:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34526) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktu-0005PZ-Aj for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51557) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktp-00036o-IC for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:18 -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-307-OvW-2Jc-NEiR3wg0wSzFUg-1; Fri, 07 Oct 2022 06:48:09 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8715985A5A6; Fri, 7 Oct 2022 10:48:09 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id C679A2028DC1; Fri, 7 Oct 2022 10:48:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139693; 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=BPvqrzSQ8Ew+2BiialqzhyDw+N0EXMDvXACwut/L4/8=; b=IMLUFJ+jVhkf6tJyAJ77pz4pYIbrf/PGJgPGEpuriAP7Nb9XxmWfOskzgYSAHYhj2oqXHz gOEGzBGmXJOCTmXSxNfyKiKMuhJGia5Naza/cVMwVGss74B6dkPwmTtJ+ialkF+Xxnn3/P JtSuynZwB6wG9BIYrw0A8zq3MP9Axeo= X-MC-Unique: OvW-2Jc-NEiR3wg0wSzFUg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 09/50] file-posix: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:11 +0200 Message-Id: <20221007104752.141361-10-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665142310860100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-9-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/file-posix.c b/block/file-posix.c index 66fdb07820..ad3021938b 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -2180,7 +2180,7 @@ static void raw_aio_unplug(BlockDriverState *bs) #endif } =20 -static int raw_co_flush_to_disk(BlockDriverState *bs) +static int coroutine_fn raw_co_flush_to_disk(BlockDriverState *bs) { BDRVRawState *s =3D bs->opaque; RawPosixAIOData acb; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665140824; cv=none; d=zohomail.com; s=zohoarc; b=Uvuej5K4cfJT9vDxL/STu+WilFBOu8/Eh31Ml6zNgoDL9wDwcwLxQyUS4qDMBP24VguJVsGQwXak2Bll1vA3e803fl1LMWJEZQgNhkuH8kHyym+AYsCBhIzRJcTD9XdZ1zkbqV8XEvDuQoFq7lnZ9QAP1j/x/qhQ2VhkzxeOmZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665140824; 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=0lnpcvVks2bsy6qvNvZjYGGTISVVcqMyRRyF850AK9U=; b=Eo5b5leS7n+5R1DS2TQFri2FXNoTmKn19FyEjOM7LvX1lt2hJP1MMntXIy/6HZevHsNp08t1DEcMfX4xQm/gS8+NVHXe9/ODBkBz5QxKfhHzcyoBTEpnHjlnvqKdDaapu5a8+FTz/x6hU1o5ziSv+r8qE5FMAB/t2J3wM5OV2z8= 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 1665140824578512.8935622087926; Fri, 7 Oct 2022 04:07:04 -0700 (PDT) Received: from localhost ([::1]:49618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglC2-0007wj-Pf for importer@patchew.org; Fri, 07 Oct 2022 07:07:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34528) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktu-0005Pa-I1 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktq-00037A-Hu for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:18 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-60-m06fXfdxM6-xa4bIu0VCHw-1; Fri, 07 Oct 2022 06:48:10 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 838481C0515C; Fri, 7 Oct 2022 10:48:10 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id C1F2F2024CBB; Fri, 7 Oct 2022 10:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139694; 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=0lnpcvVks2bsy6qvNvZjYGGTISVVcqMyRRyF850AK9U=; b=HrXuHYFXqrzUUO2/8aNmGIi241flo5XX8czgW7esxdco/hNYI/rjzVaBN+Xo6GRBLzsK1b Ag1TpX+3IdvbJ4kZMNID1rhQN4CGnMuD2xnW6vRhzUtagjyhX3tDRjlwHSYVBxDuk8rCbs IRA02x+YX46d3iJtFozJtcNdwBcrXt4= X-MC-Unique: m06fXfdxM6-xa4bIu0VCHw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 10/50] iscsi: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:12 +0200 Message-Id: <20221007104752.141361-11-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665140826479100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-10-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/iscsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/iscsi.c b/block/iscsi.c index 612de127e5..a316d46d96 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -290,7 +290,8 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int st= atus, } } =20 -static void iscsi_co_init_iscsitask(IscsiLun *iscsilun, struct IscsiTask *= iTask) +static void coroutine_fn +iscsi_co_init_iscsitask(IscsiLun *iscsilun, struct IscsiTask *iTask) { *iTask =3D (struct IscsiTask) { .co =3D qemu_coroutine_self(), --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665150106; cv=none; d=zohomail.com; s=zohoarc; b=L55vyMvbXH1pfS/i+ybG3IBEjGXxSQtrqzu2oET3k4Bhb5RFwQBgXpCOqpDpn8XY03V39bmLKepczhXKix7Bcv60npm7cqy67YTrSCK5uptm7XOnI1HyKTV8cqax6VWfWcEDaDwhVfqyiaJkjOcgU+FnAa4SFgFsuNi1ONUMxj8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665150106; 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=u4wCFvOt+rD+e3MDeKssgn7N9YIon/VYxnZe0kqeidk=; b=Emoeg8AiCCgNC9Nrn1ccftPEwxmrRO0tEpyz+sdTOO3MvezxJeKvKzEfFHntG6vHEG0QwhrTrDyDI0zjGHcQISH4csIO3N9rK86wPAo/zgeL4sATncozg+4L2diIR+snV/80wIz5RuzwFxfbCKp6HJIPhKFax9ltPTB950uuuJU= 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 166515010698149.59374271118702; Fri, 7 Oct 2022 06:41:46 -0700 (PDT) Received: from localhost ([::1]:39184 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ognbl-0005Ao-MU for importer@patchew.org; Fri, 07 Oct 2022 09:41:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36944) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkwM-0006z3-E3 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:50:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:35370) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkwJ-0003eL-Ar for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:50:49 -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-499-99xQiCXYN1GNMK1QTOjSvw-1; Fri, 07 Oct 2022 06:48:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E346101A528; Fri, 7 Oct 2022 10:48:11 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id BBDF92028DC1; Fri, 7 Oct 2022 10:48:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139846; 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=u4wCFvOt+rD+e3MDeKssgn7N9YIon/VYxnZe0kqeidk=; b=buWM/oNapBldCj4cod5uaS512F4oQCtF1/Myyx+g3zHVzBEcPubKoVZD5wmB29mD3Rz96d XZbZU0mvXXia3r800uRl6jUPmJ+lUUlXkwHLiSICdpuuHHpcbUPM4gBMqWu7FRORiPnVBB 6SUz8HJduJto39gmBFDcwee6LuBheIM= X-MC-Unique: 99xQiCXYN1GNMK1QTOjSvw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 11/50] nbd: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:13 +0200 Message-Id: <20221007104752.141361-12-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665150108225100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Reviewed-by: Eric Blake Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-11-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/nbd.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index 97683cce27..494b9d683e 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -983,11 +983,12 @@ static void nbd_iter_request_error(NBDReplyChunkIter = *iter, int ret) * nbd_reply_chunk_iter_receive * The pointer stored in @payload requires g_free() to free it. */ -static bool nbd_reply_chunk_iter_receive(BDRVNBDState *s, - NBDReplyChunkIter *iter, - uint64_t handle, - QEMUIOVector *qiov, NBDReply *rep= ly, - void **payload) +static bool coroutine_fn nbd_reply_chunk_iter_receive(BDRVNBDState *s, + NBDReplyChunkIter *i= ter, + uint64_t handle, + QEMUIOVector *qiov, + NBDReply *reply, + void **payload) { int ret, request_ret; NBDReply local_reply; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665143001; cv=none; d=zohomail.com; s=zohoarc; b=OYE7p0jXytricq7VdR87Oz7vgc5iBC+QIY7ZZ5avA2jEAcg4fCcjdgjpC5HfqMvpSe8hYtUFAqxmFU+KwC0ZPIozxrauoJucV2c4cuB9w2TojMPTEtFQEs8AHQ6Pb0kjx3rwFxVqWIAkmSMq8q/y6C+ut5OAXrr5UtHqWhITCa0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143001; 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=F/m6XiR4xy558MVoxxEIZFCbuqaz5zxU7RZkBEcCmhc=; b=YF8pje8WSk+OgE1Lk1ZNbvHm7n+Gjjui0b0c5MbaQxe+S1cTe47Vh4/UEBENGAmBsx/MoEQvyU9vk7YkWrA+GgmXHimfVrd+OWz+5zIvmFVEIgIHuMDC8WQGBIRPBfROGLTxMmPNlg5afJNvUoComYES69GntAORyzL4RMVx244= 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 166514300131358.21378858952801; Fri, 7 Oct 2022 04:43:21 -0700 (PDT) Received: from localhost ([::1]:60758 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogll9-0001Er-CT for importer@patchew.org; Fri, 07 Oct 2022 07:43:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktv-0005Ps-Nh for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:57541) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkts-00037r-H2 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -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-654-82ZXC3QFNXeKPwz_O1Q5yA-1; Fri, 07 Oct 2022 06:48:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7BE0A811E81; Fri, 7 Oct 2022 10:48:12 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5FA82024CBB; Fri, 7 Oct 2022 10:48:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139695; 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=F/m6XiR4xy558MVoxxEIZFCbuqaz5zxU7RZkBEcCmhc=; b=KHWKiDes36YNLvhDQCy+5tWWY0r43h+mb9ircoaxDXiBS+8tKUF7uD8bDqqIzZ5YmHmwV/ LqUWeBoFUG+cCPUKWfP7gjS61g7P2Vc3RSpCzVAokXJZPpPiBY2ouWGeGOE7wEkWGzxTmt jIgrT1NoM9f2gQ/xJ9DY1TawGf+piX0= X-MC-Unique: 82ZXC3QFNXeKPwz_O1Q5yA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 12/50] nfs: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:14 +0200 Message-Id: <20221007104752.141361-13-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143002109100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-12-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/nfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/nfs.c b/block/nfs.c index 444c40b458..596ebe98cb 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -223,7 +223,7 @@ static void nfs_process_write(void *arg) qemu_mutex_unlock(&client->mutex); } =20 -static void nfs_co_init_task(BlockDriverState *bs, NFSRPC *task) +static void coroutine_fn nfs_co_init_task(BlockDriverState *bs, NFSRPC *ta= sk) { *task =3D (NFSRPC) { .co =3D qemu_coroutine_self(), --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665143797; cv=none; d=zohomail.com; s=zohoarc; b=XgMhSMSNZ/NSG/8x54CarYh10WYp1/zq94X7K6Zi8Sa7C2fhfDaT1b3YggUq5IvDS45QQ8xAfvySTH+8GO+BZA5ZrcfouTVKw7lYI3BCZQfxVhhvoV8Tj4M0scBTj+1K+tIwJSRYpEwK37/vLxyW3F9/LsBDIZf4Jil7IWF64dQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143797; 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=qsjWkEsfi4xcTFnxbn5WE5nKSsgvC1iq0YaZMih4Rpg=; b=CMlJWueYEyxufideaFXvHBsKs72/nWI5ooKExr1/RZ15oA6tMc7iPsrLn0GxBZw383ien5rdv0gMTAGwcdlN9nEE/HnV9OVWoH0ptR7CEgGo3A290E7O4jP3qQJG0CapaltUGOeY+L30vTFOuQppST1PJjdYscdz1/k45xHfs2k= 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 1665143797658691.0493921261944; Fri, 7 Oct 2022 04:56:37 -0700 (PDT) Received: from localhost ([::1]:41210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglxz-0001dn-Qk for importer@patchew.org; Fri, 07 Oct 2022 07:56:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34534) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktv-0005Pp-Ea for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:58303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktr-00037U-Pj for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -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-335-7KjxJlJbOnu-FIZhTOXWqQ-1; Fri, 07 Oct 2022 06:48:13 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77C3C185A78B; Fri, 7 Oct 2022 10:48:13 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id B46742028DC1; Fri, 7 Oct 2022 10:48:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139695; 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=qsjWkEsfi4xcTFnxbn5WE5nKSsgvC1iq0YaZMih4Rpg=; b=C5oCaMH4GcaE1+b0vcIbFKevye2/He857j9u0RgroECafPKTnkYHlkKrqC0l3NZGDvtTAZ JgOLQZACGR8YZrwq7FFNQAuhyv93O22zuf6VlMtf0ZV28Y+HApQX6HqqDUdGaaM+JFu08L zUOCHlMVLV6sTyfJR7Nc3rYCLo6K+lI= X-MC-Unique: 7KjxJlJbOnu-FIZhTOXWqQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 13/50] nvme: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:15 +0200 Message-Id: <20221007104752.141361-14-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143799219100002 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-13-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/nvme.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index 0870f87bc6..2b24f95164 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -1242,8 +1242,10 @@ static inline bool nvme_qiov_aligned(BlockDriverStat= e *bs, return true; } =20 -static int nvme_co_prw(BlockDriverState *bs, uint64_t offset, uint64_t byt= es, - QEMUIOVector *qiov, bool is_write, int flags) +static coroutine_fn int nvme_co_prw(BlockDriverState *bs, + uint64_t offset, uint64_t bytes, + QEMUIOVector *qiov, bool is_write, + int flags) { BDRVNVMeState *s =3D bs->opaque; int r; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665146382; cv=none; d=zohomail.com; s=zohoarc; b=XlBissnbeoYiSRCk2oZFWg1nqTa1KbJti/iL6+X5Fon3+w1CdHH/sR9Rb6AmWkKXonnKxPO6LoFz7IeBp01glpF4zwVd+gCd2aYhG0V5YFmLIDXWPpkGN+Hqbi+OOt0NOuiOjcKlCuJDXdVi8niSAqYNhpY82qxYozLNr0JZREM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146382; 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=dSY5/HBZRKVF7uQ3p8yfrydRMua5O5KVJzGnHNAih+U=; b=jM8Niee5ShIBslHL9Ki6NcTZxB+4gEuoT/bzElsBks6wHzPp/DOYTDthZXWwNvTPH47sKNU5E+PVRlPZgddIKtpo1N2jcGQ2AyW4J4iyEAgjCUhYsxJljFx93RlQeFOqmkhfIungeS8roUVcAE4r0pgc1ui9OxYIXxWClTJHqgk= 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 1665146382546624.4179461894261; Fri, 7 Oct 2022 05:39:42 -0700 (PDT) Received: from localhost ([::1]:36488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmdh-0008DT-Fw for importer@patchew.org; Fri, 07 Oct 2022 08:39:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34544) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktw-0005Px-Mn for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24273) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktu-00038i-Dq for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:20 -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-364-kGmP0kyxNXGqCHOccLvddg-1; Fri, 07 Oct 2022 06:48:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7104985A5B6; Fri, 7 Oct 2022 10:48:14 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFAB52024CBB; Fri, 7 Oct 2022 10:48:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139697; 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=dSY5/HBZRKVF7uQ3p8yfrydRMua5O5KVJzGnHNAih+U=; b=ToS2FsxeITedsquBx+QuiIafuHJDWkWpPYchP4qHXqHAc3yeGfC+3lRVy3ODM+3l+bxy7E VWJSr/AXk7vz2wix/ZxhW1H06YgcByWNvddS9YGaJbIiz3rbxZSgpRyER+TJnu0LIk4XKa YLwM854vnffbqmJN801aPH+2Hq7mvis= X-MC-Unique: kGmP0kyxNXGqCHOccLvddg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 14/50] parallels: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:16 +0200 Message-Id: <20221007104752.141361-15-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146383687100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-14-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/parallels.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index a229c06f25..c1523e7dab 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -165,8 +165,9 @@ static int64_t block_status(BDRVParallelsState *s, int6= 4_t sector_num, return start_off; } =20 -static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, int *pnum) +static coroutine_fn int64_t allocate_clusters(BlockDriverState *bs, + int64_t sector_num, + int nb_sectors, int *pnum) { int ret =3D 0; BDRVParallelsState *s =3D bs->opaque; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665147216; cv=none; d=zohomail.com; s=zohoarc; b=fIWLIK8rwyKzbyyv/ovn+4tGBDcG2+XrKRnbBJqbKhP7GPof0T+YIlC2cbIa5EKCHCNSzp/hgCQkcbrK3vBTZqaZNa4xIyrq4tdKfQ4GmTzTlYbh7pU/3lEJlda8eOkDpOz4sv4HIPyPw1q1kCmUUnQ2F2AQhZeYr+MWu3pvncg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665147216; 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=yYq6AUjF6RyWbI1+7EjMXYegwudi1dUzZnyyCVAEGuk=; b=P/xxtoNKUQhhEwMvBOgX4+A0qkrOmxEtNbym7bNNaMrFU9Ok/S6sLLVGRau2sitgyX8905ice6V1soE2NEpC+A4HrgQRpOnxjdksOXjblszN0QuQl1VWnnbv72G27tAylG365PBLiotFtcc0mXZvwWfmnlrzqLCwO4useFRmYAM= 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 1665147216079101.4398428488729; Fri, 7 Oct 2022 05:53:36 -0700 (PDT) Received: from localhost ([::1]:53914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmr8-0003ou-8h for importer@patchew.org; Fri, 07 Oct 2022 08:53:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktw-0005Pw-4s for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23523) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktt-00038E-Gv for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:19 -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-122-QAkkqdGvPZ-CGOIVQ87UXg-1; Fri, 07 Oct 2022 06:48:15 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A7C695E3A5; Fri, 7 Oct 2022 10:48:15 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8FA32028DC1; Fri, 7 Oct 2022 10:48:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139696; 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=yYq6AUjF6RyWbI1+7EjMXYegwudi1dUzZnyyCVAEGuk=; b=Rh9CoGIa52A1p4Trr5BQQNDLLN6Yp7lYVBvxihxwuS///St4RNBA4pRikbVzkNXbZIQArv klGLOX7B3ggmLXo8YWviieBRlo26GfMdYesdsCVyIb0CCds/H3yIAZjYG3Rz3ipWUqz3J8 QCOihTa3lvtdl3tfRvG9v3fSCTJa+vs= X-MC-Unique: QAkkqdGvPZ-CGOIVQ87UXg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 15/50] qcow2: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:17 +0200 Message-Id: <20221007104752.141361-16-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665147217548100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-15-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/qcow2.h | 15 ++++++++------- block/qcow2-cluster.c | 21 ++++++++++++--------- block/qcow2-refcount.c | 2 +- block/qcow2.c | 5 +++-- 4 files changed, 24 insertions(+), 19 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index c8d9e8ea79..3e7c5e80b6 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -895,7 +895,7 @@ int qcow2_change_refcount_order(BlockDriverState *bs, i= nt refcount_order, void *cb_opaque, Error **errp); int qcow2_shrink_reftable(BlockDriverState *bs); int64_t qcow2_get_last_cluster(BlockDriverState *bs, int64_t size); -int qcow2_detect_metadata_preallocation(BlockDriverState *bs); +int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs); =20 /* qcow2-cluster.c functions */ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, @@ -908,9 +908,9 @@ int qcow2_encrypt_sectors(BDRVQcow2State *s, int64_t se= ctor_num, int qcow2_get_host_offset(BlockDriverState *bs, uint64_t offset, unsigned int *bytes, uint64_t *host_offset, QCow2SubclusterType *subcluster_type); -int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, - unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m); +int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t of= fset, + unsigned int *bytes, + uint64_t *host_offset, QCowL2Meta= **m); int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs, uint64_t offset, int compressed_size, @@ -918,13 +918,14 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriver= State *bs, void qcow2_parse_compressed_l2_entry(BlockDriverState *bs, uint64_t l2_ent= ry, uint64_t *coffset, int *csize); =20 -int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m); +int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs, + QCowL2Meta *m); void qcow2_alloc_cluster_abort(BlockDriverState *bs, QCowL2Meta *m); int qcow2_cluster_discard(BlockDriverState *bs, uint64_t offset, uint64_t bytes, enum qcow2_discard_type type, bool full_discard); -int qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, int flags); +int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t o= ffset, + uint64_t bytes, int flags); =20 int qcow2_expand_zero_clusters(BlockDriverState *bs, BlockDriverAmendStatusCB *status_cb, diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index fd32316d6f..0f293950a1 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -884,7 +884,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverSt= ate *bs, return 0; } =20 -static int perform_cow(BlockDriverState *bs, QCowL2Meta *m) +static int coroutine_fn perform_cow(BlockDriverState *bs, QCowL2Meta *m) { BDRVQcow2State *s =3D bs->opaque; Qcow2COWRegion *start =3D &m->cow_start; @@ -1024,7 +1024,8 @@ fail: return ret; } =20 -int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m) +int coroutine_fn qcow2_alloc_cluster_link_l2(BlockDriverState *bs, + QCowL2Meta *m) { BDRVQcow2State *s =3D bs->opaque; int i, j =3D 0, l2_index, ret; @@ -1397,8 +1398,9 @@ static int count_single_write_clusters(BlockDriverSta= te *bs, int nb_clusters, * information on cluster allocation may be invalid now. The cal= ler * must start over anyway, so consider *cur_bytes undefined. */ -static int handle_dependencies(BlockDriverState *bs, uint64_t guest_offset, - uint64_t *cur_bytes, QCowL2Meta **m) +static int coroutine_fn handle_dependencies(BlockDriverState *bs, + uint64_t guest_offset, + uint64_t *cur_bytes, QCowL2Met= a **m) { BDRVQcow2State *s =3D bs->opaque; QCowL2Meta *old_alloc; @@ -1772,9 +1774,10 @@ out: * * Return 0 on success and -errno in error cases */ -int qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t offset, - unsigned int *bytes, uint64_t *host_offset, - QCowL2Meta **m) +int coroutine_fn qcow2_alloc_host_offset(BlockDriverState *bs, uint64_t of= fset, + unsigned int *bytes, + uint64_t *host_offset, + QCowL2Meta **m) { BDRVQcow2State *s =3D bs->opaque; uint64_t start, remaining; @@ -2105,8 +2108,8 @@ out: return ret; } =20 -int qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, int flags) +int coroutine_fn qcow2_subcluster_zeroize(BlockDriverState *bs, uint64_t o= ffset, + uint64_t bytes, int flags) { BDRVQcow2State *s =3D bs->opaque; uint64_t end_offset =3D offset + bytes; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 1a6277c783..1fbb07ca77 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -3706,7 +3706,7 @@ int64_t qcow2_get_last_cluster(BlockDriverState *bs, = int64_t size) return -EIO; } =20 -int qcow2_detect_metadata_preallocation(BlockDriverState *bs) +int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs) { BDRVQcow2State *s =3D bs->opaque; int64_t i, end_cluster, cluster_count =3D 0, threshold; diff --git a/block/qcow2.c b/block/qcow2.c index 6c8c8b2b5a..b57f7cc8ee 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2448,7 +2448,7 @@ static bool merge_cow(uint64_t offset, unsigned bytes, * Return 1 if the COW regions read as zeroes, 0 if not, < 0 on error. * Note that returning 0 does not guarantee non-zero data. */ -static int is_zero_cow(BlockDriverState *bs, QCowL2Meta *m) +static int coroutine_fn is_zero_cow(BlockDriverState *bs, QCowL2Meta *m) { /* * This check is designed for optimization shortcut so it must be @@ -2466,7 +2466,8 @@ static int is_zero_cow(BlockDriverState *bs, QCowL2Me= ta *m) m->cow_end.nb_bytes); } =20 -static int handle_alloc_space(BlockDriverState *bs, QCowL2Meta *l2meta) +static int coroutine_fn handle_alloc_space(BlockDriverState *bs, + QCowL2Meta *l2meta) { BDRVQcow2State *s =3D bs->opaque; QCowL2Meta *m; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665140821; cv=none; d=zohomail.com; s=zohoarc; b=kcN2aPgqbkt+2L5/GDh3xqxpzQ3F2HDRVxkroD/9iIRwroos4gxAx2y+3fJUgxBKDWQFnKwGTfXpF3vlEo3jEPmJJIAPaD1NXXIXSu7EwxZsB28NS2wwqW4eO8WsHpRpntd5KNB69BSBg1lwwOkcfHhZiICGA5Ce60AGk5YiSxs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665140821; 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=VbGNOJtmGcJZVbdtIp/SMVAjuVFmTs6b8bZWQZgV0HQ=; b=lFaimZqYFuT5xTKxFLh8svAWzyC4QHNTgDAO26uq/wOLabbGLNU6ivXwc+7z5hmrSyHK44UuSoZYBuY7LZuDf1TiJffo3PCrsokcr9ntGOwwNCepUiJb6en5lHUuCxRCFe1aKznRsRTfntIOpitry9uqD0LKJ6Nx4gYW5pilkpY= 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 1665140821492671.8586062030914; Fri, 7 Oct 2022 04:07:01 -0700 (PDT) Received: from localhost ([::1]:49616 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglBu-0007vU-Ap for importer@patchew.org; Fri, 07 Oct 2022 07:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34546) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktx-0005Py-0C for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54206) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktu-00038m-Fc for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:20 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-13-ZJDqSsOPM-ul1JB4CMc9cA-1; Fri, 07 Oct 2022 06:48:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 628643826253; Fri, 7 Oct 2022 10:48:16 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id A19052024CBB; Fri, 7 Oct 2022 10:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139697; 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=VbGNOJtmGcJZVbdtIp/SMVAjuVFmTs6b8bZWQZgV0HQ=; b=dvZLNGCMdY0grEhjXPRBW2iWB5BOMRJMWIN+3lyOQYJK0I6APh7+UVIYEZwrRoYjMjDrhW Fp1gUJvmPRmRxNvGqwCpp5U5NF7tJVqiCn00mO51Gmdl8suEh1PKHonWDVPZ455MuEG2fH 3T2jJuTDIrpidVaN6+R02vs+/w8GmT4= X-MC-Unique: ZJDqSsOPM-ul1JB4CMc9cA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 16/50] copy-before-write: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:18 +0200 Message-Id: <20221007104752.141361-17-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665140822628100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-16-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/copy-before-write.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/copy-before-write.c b/block/copy-before-write.c index c24b8dd117..afbdd04489 100644 --- a/block/copy-before-write.c +++ b/block/copy-before-write.c @@ -203,9 +203,9 @@ static int coroutine_fn cbw_co_flush(BlockDriverState *= bs) * It's guaranteed that guest writes will not interact in the region until * cbw_snapshot_read_unlock() called. */ -static BlockReq *cbw_snapshot_read_lock(BlockDriverState *bs, - int64_t offset, int64_t bytes, - int64_t *pnum, BdrvChild **file) +static coroutine_fn BlockReq * +cbw_snapshot_read_lock(BlockDriverState *bs, int64_t offset, int64_t bytes, + int64_t *pnum, BdrvChild **file) { BDRVCopyBeforeWriteState *s =3D bs->opaque; BlockReq *req =3D g_new(BlockReq, 1); @@ -240,7 +240,8 @@ static BlockReq *cbw_snapshot_read_lock(BlockDriverStat= e *bs, return req; } =20 -static void cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req) +static coroutine_fn void +cbw_snapshot_read_unlock(BlockDriverState *bs, BlockReq *req) { BDRVCopyBeforeWriteState *s =3D bs->opaque; =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665143798; cv=none; d=zohomail.com; s=zohoarc; b=RhIqujHswL1qpAzAjgjpXXr/tQKQ6jr+KCXTHR/CCWCfa+pKpXb1D13AhjgMIr0yTNpOSPcnRpntBsPZnEVFNxs9hslsk6Iur+3yRXqrklTUIktktNNuWg8SLbtzCrrTUwlt82POTwYTG11lZjdIjseJhPfxsZQ/dgrx2Rt5KH8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143798; 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=/BjBunRbfBG9hEWnT+6LzJvDBcKvQN6pPA6rPAwFx78=; b=R/lE2d61caWPd/1gamDqfoW3KglxPSHun4wtJUAwFZEA6N9EnMap5zB9bvbUNccKbBTzNynb7jtNVWuDbbdRzjXk4Xbg7pQcLFZhWXKHzX82vOJDfkK0acmDEHzq8X+9x8leX+6IzDTbn++RzOdFzAS+3Bo3OniK75PJZ7tsoZM= 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 1665143798501831.5837165657225; Fri, 7 Oct 2022 04:56:38 -0700 (PDT) Received: from localhost ([::1]:51442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogly0-0001m3-8T for importer@patchew.org; Fri, 07 Oct 2022 07:56:36 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34548) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktx-0005Pz-1v for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:21809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktv-00039G-HJ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:20 -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-213-_TyJDjMNM-ex1JpPGYxU5w-1; Fri, 07 Oct 2022 06:48:17 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5F15D862FDF; Fri, 7 Oct 2022 10:48:17 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99E1C2024CBB; Fri, 7 Oct 2022 10:48:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139698; 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=/BjBunRbfBG9hEWnT+6LzJvDBcKvQN6pPA6rPAwFx78=; b=TKepQdEgJyhRlyGwfM+V+Xl9GqtigEl0nG2Dz6zFKkd5z/OvUhrPybjGVkvW8KFXiX+re0 jEe8coFGz7py2D/xB7cHp7KTVEGku5j0r4vqGXLdHE7G6gxr14qfm03I7c5Y78pSAvVHSB ApLe+Mwium1vxAJuTvGN5qmzY5Vh5c8= X-MC-Unique: _TyJDjMNM-ex1JpPGYxU5w-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 17/50] curl: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:19 +0200 Message-Id: <20221007104752.141361-18-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143799207100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-17-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/curl.c b/block/curl.c index 1e0f609579..cba4c4cac7 100644 --- a/block/curl.c +++ b/block/curl.c @@ -855,7 +855,7 @@ out_noclean: return -EINVAL; } =20 -static void curl_setup_preadv(BlockDriverState *bs, CURLAIOCB *acb) +static void coroutine_fn curl_setup_preadv(BlockDriverState *bs, CURLAIOCB= *acb) { CURLState *state; int running; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665142286; cv=none; d=zohomail.com; s=zohoarc; b=OjVfpvOJnport9l7ZeI17aMqMKUrJ3eHN1bWaRdpGrFOCywbCkjVg+2JorIuQbVgrGI3erHhUFenJpBR64lEQJa8hu4l0bXgaQN48ypRafOMuh3gPmOuBdC62WZVXXilgRa4qnlxSLm11aSd2dMiudgxHROg0sUCkSNQby/6kZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665142286; 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=q5ovy9QylmpGx/UXJlu9Ds7mgbe7YegFqU4ze0cE1iw=; b=n/Kcy6Jyk/QBBiU1g1PYi45Bzn92pHiFiIqwHUarLfoah/msAfpgSdbXHy3LVmGX2o8+/O+TmQHyLZpOdMThyjAi4O1Do6EMBz14O08UvENJsKrALA/empd/Lcg9o2vVBckmcbPJga+NG+hIeg4FmC8ACMuQTQhjHwDKz897HT4= 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 1665142286233431.31957952001096; Fri, 7 Oct 2022 04:31:26 -0700 (PDT) Received: from localhost ([::1]:52134 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglZb-00035u-Md for importer@patchew.org; Fri, 07 Oct 2022 07:31:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34560) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktz-0005QH-Pz for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:48572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkty-0003AT-77 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-224-bmrYGjpwP7WSwyhE8bqM-Q-1; Fri, 07 Oct 2022 06:48:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55DF32A59555; Fri, 7 Oct 2022 10:48:18 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 959B22028DC1; Fri, 7 Oct 2022 10:48:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139701; 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=q5ovy9QylmpGx/UXJlu9Ds7mgbe7YegFqU4ze0cE1iw=; b=DdOq+PBznPodT11kUk14HVwPNgvqs+Ob2b6rEQJEBwTD7IUCVfbbuXSDMQM/7KaHM1iJdM OwzQSR+S40hZ4zwypib6VSwYwZEMhiXLSNxe4N3mpWrTP5y3l54nhBE4wMF6URK7/crOwn 69+F3q1J8nBVZvDKZ27EMBeuVZM4hZQ= X-MC-Unique: bmrYGjpwP7WSwyhE8bqM-Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 18/50] qed: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:20 +0200 Message-Id: <20221007104752.141361-19-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665142286897100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-18-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/qed.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qed.c b/block/qed.c index 324ca0e95a..bda00e6257 100644 --- a/block/qed.c +++ b/block/qed.c @@ -254,7 +254,7 @@ static CachedL2Table *qed_new_l2_table(BDRVQEDState *s) return l2_table; } =20 -static bool qed_plug_allocating_write_reqs(BDRVQEDState *s) +static bool coroutine_fn qed_plug_allocating_write_reqs(BDRVQEDState *s) { qemu_co_mutex_lock(&s->table_lock); =20 @@ -273,7 +273,7 @@ static bool qed_plug_allocating_write_reqs(BDRVQEDState= *s) return true; } =20 -static void qed_unplug_allocating_write_reqs(BDRVQEDState *s) +static void coroutine_fn qed_unplug_allocating_write_reqs(BDRVQEDState *s) { qemu_co_mutex_lock(&s->table_lock); assert(s->allocating_write_reqs_plugged); --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141233; cv=none; d=zohomail.com; s=zohoarc; b=mFHVpYfziv0vt4+i1aSUQPgDs87/0thCKcrVPd9GRazztQpcqh30+Jo8wRxqM0G5DZOJH1dBuOcmF2VjbwcSAg/MF7I2PWoiEQ3HYiVjBxfycCXCPGJNdHtsu+SzmknZgbMfiHaUs9Qp9GJXoxlLzFyDKBrcuP5UjdPEOG4X2DA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141233; 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=dOooDqfRcR5P5jQ2HfzI++ZcYUJNWybSLieOnCIkpxQ=; b=Ljl0B9OdoJZs+kHpmJxb6McPio9fOnohwE+LYjy97Sf9/u3N5VpVoo9WB7I5fiTJKghW3IE7e/wrV06J7fl4uqVgLDVDvH5WyO8Nq/mLXXvLJW3kjPW/IW8hZtXFqdK/+jfchm8bivroSdOcHJchUdT6KjphtFZtRY8H9S6F/Ec= 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 1665141233613386.0546706175512; Fri, 7 Oct 2022 04:13:53 -0700 (PDT) Received: from localhost ([::1]:43426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglIe-0007GG-GF for importer@patchew.org; Fri, 07 Oct 2022 07:13:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkty-0005Q5-Ru for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktx-0003A4-AE for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:22 -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-18-Dj8KOSJ9PEGbI2JHFYTojw-1; Fri, 07 Oct 2022 06:48:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4F59C85A5B6; Fri, 7 Oct 2022 10:48:19 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CFB82024CBB; Fri, 7 Oct 2022 10:48:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139700; 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=dOooDqfRcR5P5jQ2HfzI++ZcYUJNWybSLieOnCIkpxQ=; b=Rpu7DjwIFOTGLfP8tmKh37rl2ifaKaftLBYqgnHFXoVGe20lPkgqzaFWROduWo53FqBtrx 6/e/sQqX42laitH7q1vKN2rydww9yDmwM+cXSQ667Bfm7oWgqwvUO2n3C8OZ7MkKTE4x9S lQ7XPHt1UdhVQIbP3ZIYVcHWIaC3k1w= X-MC-Unique: Dj8KOSJ9PEGbI2JHFYTojw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 19/50] quorum: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:21 +0200 Message-Id: <20221007104752.141361-20-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141234301100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-19-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/quorum.c | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index f33f30d36b..970f63d9f9 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -161,11 +161,10 @@ static bool quorum_64bits_compare(QuorumVoteValue *a,= QuorumVoteValue *b) return a->l =3D=3D b->l; } =20 -static QuorumAIOCB *quorum_aio_get(BlockDriverState *bs, - QEMUIOVector *qiov, - uint64_t offset, - uint64_t bytes, - int flags) +static QuorumAIOCB *coroutine_fn quorum_aio_get(BlockDriverState *bs, + QEMUIOVector *qiov, + uint64_t offset, uint64_t = bytes, + int flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D g_new(QuorumAIOCB, 1); @@ -273,7 +272,7 @@ static void quorum_report_bad_versions(BDRVQuorumState = *s, } } =20 -static void quorum_rewrite_entry(void *opaque) +static void coroutine_fn quorum_rewrite_entry(void *opaque) { QuorumCo *co =3D opaque; QuorumAIOCB *acb =3D co->acb; @@ -574,7 +573,7 @@ free_exit: quorum_free_vote_list(&acb->votes); } =20 -static void read_quorum_children_entry(void *opaque) +static void coroutine_fn read_quorum_children_entry(void *opaque) { QuorumCo *co =3D opaque; QuorumAIOCB *acb =3D co->acb; @@ -602,7 +601,7 @@ static void read_quorum_children_entry(void *opaque) } } =20 -static int read_quorum_children(QuorumAIOCB *acb) +static int coroutine_fn read_quorum_children(QuorumAIOCB *acb) { BDRVQuorumState *s =3D acb->bs->opaque; int i; @@ -643,7 +642,7 @@ static int read_quorum_children(QuorumAIOCB *acb) return acb->vote_ret; } =20 -static int read_fifo_child(QuorumAIOCB *acb) +static int coroutine_fn read_fifo_child(QuorumAIOCB *acb) { BDRVQuorumState *s =3D acb->bs->opaque; int n, ret; @@ -664,8 +663,10 @@ static int read_fifo_child(QuorumAIOCB *acb) return ret; } =20 -static int quorum_co_preadv(BlockDriverState *bs, int64_t offset, int64_t = bytes, - QEMUIOVector *qiov, BdrvRequestFlags flags) +static int coroutine_fn quorum_co_preadv(BlockDriverState *bs, + int64_t offset, int64_t bytes, + QEMUIOVector *qiov, + BdrvRequestFlags flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); @@ -684,7 +685,7 @@ static int quorum_co_preadv(BlockDriverState *bs, int64= _t offset, int64_t bytes, return ret; } =20 -static void write_quorum_entry(void *opaque) +static void coroutine_fn write_quorum_entry(void *opaque) { QuorumCo *co =3D opaque; QuorumAIOCB *acb =3D co->acb; @@ -715,9 +716,9 @@ static void write_quorum_entry(void *opaque) } } =20 -static int quorum_co_pwritev(BlockDriverState *bs, int64_t offset, - int64_t bytes, QEMUIOVector *qiov, - BdrvRequestFlags flags) +static int coroutine_fn quorum_co_pwritev(BlockDriverState *bs, int64_t of= fset, + int64_t bytes, QEMUIOVector *qio= v, + BdrvRequestFlags flags) { BDRVQuorumState *s =3D bs->opaque; QuorumAIOCB *acb =3D quorum_aio_get(bs, qiov, offset, bytes, flags); @@ -746,8 +747,9 @@ static int quorum_co_pwritev(BlockDriverState *bs, int6= 4_t offset, return ret; } =20 -static int quorum_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, - int64_t bytes, BdrvRequestFlags flags) +static int coroutine_fn quorum_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int64_t by= tes, + BdrvRequestFlags flags) =20 { return quorum_co_pwritev(bs, offset, bytes, NULL, --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665145307; cv=none; d=zohomail.com; s=zohoarc; b=CHpDEoWX1YhBZTxAap4EG0gW76Ore8TJwb425dgoNNKG/aKqQqfn0zRc0OEmrfQYMZXkfJTecO5XuxQEnh1wnQtEgBJsA8oTYrptKiGwDbk9GAbb3kCls/awTj26nWqWCS6wxDMmwCGlmvvO1cjlZoismJRXK5Yz3zC02sPPRXg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145307; 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=Htveg6gTrOP5OBad8snCISDy/Ag0ms2wIfLgzkTNx5I=; b=aYS8Osw6AVF5+ns2SOhM6YphHsEL05cm5O0WJPsa+9kAehyaZ2A39XY/V4iy7+HK64MLgMZ5wfKTHJsfGYpTHlOvxk6RnkbjJwrcQC5M+uBxeCmT4D3fVwvt7yPeHvT11FnK8ADTywMjylal7V3S5xjUpJvl4WF1Ge+HuXOcf1Y= 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 1665145307933169.8122000010402; Fri, 7 Oct 2022 05:21:47 -0700 (PDT) Received: from localhost ([::1]:56952 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmMF-0006st-3S for importer@patchew.org; Fri, 07 Oct 2022 08:21:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogktz-0005QI-SB for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:30371) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkty-0003AW-At for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:23 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-83-Dtose3joOyGRZGaa1cd9Rg-1; Fri, 07 Oct 2022 06:48:20 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4B2E92A59555; Fri, 7 Oct 2022 10:48:20 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86A8D2024CBB; Fri, 7 Oct 2022 10:48:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139701; 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=Htveg6gTrOP5OBad8snCISDy/Ag0ms2wIfLgzkTNx5I=; b=NxphEwW/WLxFqv2rT7EFO4t4I5cwCKk+Ts1i9Vq7Tn6lN4uOektVVzn/Poyw096IaG6cj0 xLnR5DdNjlrYUQZ7UlWSLQLwJnxxctAv5ZJ3iHu72s4T60vbFeysCC0gLPy3RMJr1ieetU WnqdjoAj+nz6xSc+r3+o5UW96tVJiZM= X-MC-Unique: Dtose3joOyGRZGaa1cd9Rg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 20/50] throttle: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:22 +0200 Message-Id: <20221007104752.141361-21-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145308241100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-20-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/throttle.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/throttle.c b/block/throttle.c index 6e8d52fa24..ddd450593a 100644 --- a/block/throttle.c +++ b/block/throttle.c @@ -162,7 +162,7 @@ static int coroutine_fn throttle_co_pwritev_compressed(= BlockDriverState *bs, BDRV_REQ_WRITE_COMPRESSED); } =20 -static int throttle_co_flush(BlockDriverState *bs) +static int coroutine_fn throttle_co_flush(BlockDriverState *bs) { return bdrv_co_flush(bs->file->bs); } --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665146690; cv=none; d=zohomail.com; s=zohoarc; b=YPhzJXD1yBm2SxLgqlHc+DzJaARPi6TnzPU8XpHgRe/IFYHN8A9iMN2JiSsCD2lZ9zqWjHJoxQOUa4np0gOH6tVSBm8yg2iR7xi87o42WD/numtNCWZf90GBbRSOHsXEris6mvAvz7EV3iQqj6QLlA5He5s8UGuayTPx++7ztgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146690; 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=Vw+MUy67SFA/hYZ0rxltmZQHX2FtXDcp19zIq56PZxY=; b=TFfF06HAWv1VfJV4D6ShOIcGC4ufAX+jRd4NLN+216tNEsQwpjKkQ7cUXrmJND97+I9/OnSKseBDHKk4VXWkhd41G5qv7UOi0Lc80dFJZJzG2ZwQjzJBo8V9J3Ru2y0NJU+svmrc7o2CiZNX0+vVhXHa7Ue5UkTtQHMDGUKZa0E= 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 166514669032669.43201643313614; Fri, 7 Oct 2022 05:44:50 -0700 (PDT) Received: from localhost ([::1]:39986 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmif-0005xX-9O for importer@patchew.org; Fri, 07 Oct 2022 08:44:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku2-0005QS-Sp for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku1-0003BO-Fi for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:26 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-392-KaGKqticPRqXJ-WtG0s0LQ-1; Fri, 07 Oct 2022 06:48:21 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 455D93826243; Fri, 7 Oct 2022 10:48:21 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8361C2028DC1; Fri, 7 Oct 2022 10:48:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139704; 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=Vw+MUy67SFA/hYZ0rxltmZQHX2FtXDcp19zIq56PZxY=; b=RCPFshvmGfZrBHrT64xtjcly3GE+kQhsgP4skcGKXPwCEBr1JA4RADZoz4+1PPPhUShFqC i2oODxxkQXISrdAVF9VmPdcZhiKt3THJ2PE1QE/iVNqT8TJQg0XYSR+VaMB4g1xAB85ae+ KhiGEVtGE7hbq/ONCwJn2DG6H2nBKAU= X-MC-Unique: KaGKqticPRqXJ-WtG0s0LQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 21/50] vmdk: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:23 +0200 Message-Id: <20221007104752.141361-22-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146691696100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-21-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/vmdk.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/block/vmdk.c b/block/vmdk.c index fe07a54866..f7d8856dfb 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1787,10 +1787,11 @@ static int coroutine_fn vmdk_co_block_status(BlockD= riverState *bs, return ret; } =20 -static int vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, - int64_t offset_in_cluster, QEMUIOVector *qiov, - uint64_t qiov_offset, uint64_t n_bytes, - uint64_t offset) +static int coroutine_fn +vmdk_write_extent(VmdkExtent *extent, int64_t cluster_offset, + int64_t offset_in_cluster, QEMUIOVector *qiov, + uint64_t qiov_offset, uint64_t n_bytes, + uint64_t offset) { int ret; VmdkGrainMarker *data =3D NULL; @@ -1868,9 +1869,10 @@ static int vmdk_write_extent(VmdkExtent *extent, int= 64_t cluster_offset, return ret; } =20 -static int vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, - int64_t offset_in_cluster, QEMUIOVector *qiov, - int bytes) +static int coroutine_fn +vmdk_read_extent(VmdkExtent *extent, int64_t cluster_offset, + int64_t offset_in_cluster, QEMUIOVector *qiov, + int bytes) { int ret; int cluster_bytes, buf_bytes; @@ -2015,9 +2017,9 @@ fail: * * Returns: error code with 0 for success. */ -static int vmdk_pwritev(BlockDriverState *bs, uint64_t offset, - uint64_t bytes, QEMUIOVector *qiov, - bool zeroed, bool zero_dry_run) +static int coroutine_fn vmdk_pwritev(BlockDriverState *bs, uint64_t offset, + uint64_t bytes, QEMUIOVector *qiov, + bool zeroed, bool zero_dry_run) { BDRVVmdkState *s =3D bs->opaque; VmdkExtent *extent =3D NULL; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141798; cv=none; d=zohomail.com; s=zohoarc; b=dcxunZ0kjNi58Rjx0wyipCPYL1JnyEFeRsgnHqgpUAk2QM4mAmy2+DDgpvW+QXTorkfeuavtLbKNK8pHls8w4k5/D4YuhxGWbnHGHVbyS+XTAzIqdIwqE5TYclozMmRtAlIGDTagoD3/2/CjQJyJ/S1uxahAq5GeDyz7gCeC3CE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141798; 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=+S0QT68/DP0lbqF7eqjuwLL2QtPKlHmKMq56SFSU5TM=; b=GN33RXSbpBQacOV31BcmfWB+/B63LZJYgQ2BXJ7Z7ggMAOF/Nb849vI2bpM1obnmubKEKoTVXr6t3vhX/2JoKlEFa8a6fAFHwwM+DJFQeDjKkCrbvbrp3gJESqCIXp6MgJdua4Ms7gABwOY+yGjB4wzUrwHNw0DywdozjF1Uj5g= 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 1665141798939999.9113696134668; Fri, 7 Oct 2022 04:23:18 -0700 (PDT) Received: from localhost ([::1]:54714 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglRh-00052w-SR for importer@patchew.org; Fri, 07 Oct 2022 07:23:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44604) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku3-0005RB-OQ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52420) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku2-0003Bi-AO for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:27 -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-516-_YlNDMavMbizG3WV4GhUlQ-1; Fri, 07 Oct 2022 06:48:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 41657862FE1; Fri, 7 Oct 2022 10:48:22 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E5CC200BC6D; Fri, 7 Oct 2022 10:48:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139705; 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=+S0QT68/DP0lbqF7eqjuwLL2QtPKlHmKMq56SFSU5TM=; b=U0+NcY3AcAIBKGb95csvm1qJezE2sx9WJZRedui2z5g4pA42yiDRLH7juIUvDa1WFb5Yk4 fOYzuqZoNRpGoFXPZd9lwYJsyvZalYOqYyp7aizEaNUx5k2Dhy3i6FjckITRSCg0bLDRhp mrGfzQka8d/wS6tVYxvXrfisRQPuvuI= X-MC-Unique: _YlNDMavMbizG3WV4GhUlQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 22/50] job: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:24 +0200 Message-Id: <20221007104752.141361-23-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141800599100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-22-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/qemu/job.h | 2 +- job.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index c105b31076..397ac39608 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -436,7 +436,7 @@ void coroutine_fn job_pause_point(Job *job); * * Yield the job coroutine. */ -void job_yield(Job *job); +void coroutine_fn job_yield(Job *job); =20 /** * @job: The job that calls the function. diff --git a/job.c b/job.c index 075c6f3a20..20f0d8b2cd 100644 --- a/job.c +++ b/job.c @@ -525,7 +525,7 @@ void coroutine_fn job_pause_point(Job *job) } } =20 -void job_yield(Job *job) +void coroutine_fn job_yield(Job *job) { assert(job->busy); =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665146312; cv=none; d=zohomail.com; s=zohoarc; b=QBH1DnI/p8v10KJni96FPYAZC/NY/wZEfOHCCFhsL3L1R0yihbwgjWimFGYIZPH8hWqbCW0pQed5883BHnBcuJr7srDUtzghuZ28V165UssSm7hMkrFyuKKutxsAV4367inLAuDJJjNF2m7VF6niO3IgiZUZuZcRLFg5NtTK+x0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146312; 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=87SwFUkE+1+ARHEzx7Jc86JUCWRXmX6Ofwc5myiLOns=; b=Tpb1R0GNyOi4MYTEZIAoc/eGrYd22yOg3jFOIUCpMGVBNbXVMgdvk7kyakzqD8Q6kBhZGBa041gF8ez6ZXset8yAgZtNdiHSULvDV36MTU/a5MRudmGn+1v1ZihS4THK+577fyEaIeRETAMb32wbx0jtFODZTJcs3++sjhOeSls= 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 166514631201238.34239380781469; Fri, 7 Oct 2022 05:38:32 -0700 (PDT) Received: from localhost ([::1]:39886 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmcY-0005Cs-UZ for importer@patchew.org; Fri, 07 Oct 2022 08:38:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44608) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku5-0005Rm-A0 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:39390) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku3-0003C5-68 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:28 -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-458-9TfQGSV6OpGd9xOXh8jcbg-1; Fri, 07 Oct 2022 06:48:23 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3BCEC811E81; Fri, 7 Oct 2022 10:48:23 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A83D2028DC1; Fri, 7 Oct 2022 10:48:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139706; 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=87SwFUkE+1+ARHEzx7Jc86JUCWRXmX6Ofwc5myiLOns=; b=SjoyfidK1coVyaZqfTQhVUsEl8ZiHYp60KLfPFnCX5WLuIh3LM6LWenLHBsQJ4tMdeUump ur7mMefMIig53dqwiE3pPCZk+8F7ceHDG8KM4+dO8gdXDV2XQRWE3y3fDJoIqWVeMMT+2t XhlgDnmy6qEQMplelNaf2VzqvJKbv+Q= X-MC-Unique: 9TfQGSV6OpGd9xOXh8jcbg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 23/50] coroutine-lock: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:25 +0200 Message-Id: <20221007104752.141361-24-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146313183100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-23-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- util/qemu-coroutine-lock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/util/qemu-coroutine-lock.c b/util/qemu-coroutine-lock.c index 9ad24ab1af..15c82d9348 100644 --- a/util/qemu-coroutine-lock.c +++ b/util/qemu-coroutine-lock.c @@ -135,7 +135,7 @@ typedef struct CoWaitRecord { QSLIST_ENTRY(CoWaitRecord) next; } CoWaitRecord; =20 -static void push_waiter(CoMutex *mutex, CoWaitRecord *w) +static void coroutine_fn push_waiter(CoMutex *mutex, CoWaitRecord *w) { w->co =3D qemu_coroutine_self(); QSLIST_INSERT_HEAD_ATOMIC(&mutex->from_push, w, next); @@ -332,7 +332,7 @@ void qemu_co_rwlock_init(CoRwlock *lock) } =20 /* Releases the internal CoMutex. */ -static void qemu_co_rwlock_maybe_wake_one(CoRwlock *lock) +static void coroutine_fn qemu_co_rwlock_maybe_wake_one(CoRwlock *lock) { CoRwTicket *tkt =3D QSIMPLEQ_FIRST(&lock->tickets); Coroutine *co =3D NULL; @@ -365,7 +365,7 @@ static void qemu_co_rwlock_maybe_wake_one(CoRwlock *loc= k) } } =20 -void qemu_co_rwlock_rdlock(CoRwlock *lock) +void coroutine_fn qemu_co_rwlock_rdlock(CoRwlock *lock) { Coroutine *self =3D qemu_coroutine_self(); =20 @@ -390,7 +390,7 @@ void qemu_co_rwlock_rdlock(CoRwlock *lock) self->locks_held++; } =20 -void qemu_co_rwlock_unlock(CoRwlock *lock) +void coroutine_fn qemu_co_rwlock_unlock(CoRwlock *lock) { Coroutine *self =3D qemu_coroutine_self(); =20 @@ -408,7 +408,7 @@ void qemu_co_rwlock_unlock(CoRwlock *lock) qemu_co_rwlock_maybe_wake_one(lock); } =20 -void qemu_co_rwlock_downgrade(CoRwlock *lock) +void coroutine_fn qemu_co_rwlock_downgrade(CoRwlock *lock) { qemu_co_mutex_lock(&lock->mutex); assert(lock->owners =3D=3D -1); @@ -418,7 +418,7 @@ void qemu_co_rwlock_downgrade(CoRwlock *lock) qemu_co_rwlock_maybe_wake_one(lock); } =20 -void qemu_co_rwlock_wrlock(CoRwlock *lock) +void coroutine_fn qemu_co_rwlock_wrlock(CoRwlock *lock) { Coroutine *self =3D qemu_coroutine_self(); =20 @@ -438,7 +438,7 @@ void qemu_co_rwlock_wrlock(CoRwlock *lock) self->locks_held++; } =20 -void qemu_co_rwlock_upgrade(CoRwlock *lock) +void coroutine_fn qemu_co_rwlock_upgrade(CoRwlock *lock) { qemu_co_mutex_lock(&lock->mutex); assert(lock->owners > 0); --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665144368; cv=none; d=zohomail.com; s=zohoarc; b=XXb/PK4fVKSoG8UMnPYMuqj+w9xb47SSBvJcx+Trh8bHlFblbRFVR9phShT8JrumsZLS+9pwmC/E1ulZ2YVSiDpctSb+72+hssPSKY3kJJnY2gP49Og0AIhrZeE4CKJu/wvZcqWKlpkUHfY/SG52TByb83QaPoKuOTtIK2GXZLA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665144368; 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=LQ2hTjqwfX+63WO/urc0I8KAft3sfJgVBpYvz5/VcmI=; b=cz6Sx6gGAFQ+eic93as4y64/tMnx0L5Cs8nba7kD6CKi5yrVxWiTWTEduBM5nOHCV/1IvPhonkQJrqcWSV0oWeQl3EkDz3IBXvIst2eloJelG3neyLRbM0ohOmv0Iaq1u6un2RwZycNFFsYCKv3KiAgiOqrw4KCoKnxIjqigkpw= 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 1665144368561717.234201780923; Fri, 7 Oct 2022 05:06:08 -0700 (PDT) Received: from localhost ([::1]:42404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogm7C-0008OQ-Vp for importer@patchew.org; Fri, 07 Oct 2022 08:06:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku3-0005RC-Rv for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:54331) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku2-0003Bp-Cu for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:27 -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-401-Rk46bky-P1217U80RhrZ7g-1; Fri, 07 Oct 2022 06:48:24 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 37584101A528; Fri, 7 Oct 2022 10:48:24 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 772C52024CBB; Fri, 7 Oct 2022 10:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139705; 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=LQ2hTjqwfX+63WO/urc0I8KAft3sfJgVBpYvz5/VcmI=; b=b0sqoIj2lzoRqQjZ6/2Uxpoix7oLYCTCVkwXB7ip3tnCjT1bmmRZ2e48kuGRt9u0ztp6le UHcnkW/GgvMMs9dE6Asa9By1lWA+ZRZVPpzEJV1FT8vLYMh9Kk3N6fRXdWFHp9UVaHUpfp yF/UDDptbWkGPeYL6JI/GrTTnIN/o7c= X-MC-Unique: Rk46bky-P1217U80RhrZ7g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 24/50] raw-format: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:26 +0200 Message-Id: <20221007104752.141361-25-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665144369598100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-24-pbonzini@redhat.com> [kwolf: Fixed up coding style] Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/raw-format.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/raw-format.c b/block/raw-format.c index c7278e348e..f337ac7569 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -411,7 +411,8 @@ static void raw_lock_medium(BlockDriverState *bs, bool = locked) bdrv_lock_medium(bs->file->bs, locked); } =20 -static int raw_co_ioctl(BlockDriverState *bs, unsigned long int req, void = *buf) +static int coroutine_fn raw_co_ioctl(BlockDriverState *bs, + unsigned long int req, void *buf) { BDRVRawState *s =3D bs->opaque; if (s->offset || s->has_size) { --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665141995; cv=none; d=zohomail.com; s=zohoarc; b=m7qfp+vFw6s9/mHztgrGELwAP46r/d/CjS6lM9DllIvnIir3Fd+yI3cTSg0qWLSaQP1v2qh92qQnEb7Z+Bt51HFWz3fIFsNovdru2T7QYi56IFVogdzdeSSbtymHgIlNk/n/XjJ1SPJoURewEkwf/LneVNSZWa5Ayl0ccmzXCCM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665141995; 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=PNjC7REejBl0RJBZCEgd0Opnj3zP+Nr6L9QKK3iK0Ns=; b=NqISGz8v5Rg9KkKc8JUqmYGJa5h/ZdGSTyWifY7gKgrN3DwGFwFZIuC4khF1DGBzRCrLvJGje6zvQQ6ghn0yCzJU80DeJ2Jatu6jIRg1u1xehd9yHd1mOB1nG4husuTopV+O4NvE6qPeOMmyzCSVo2RBJ1c0P9cLIwXKgk8D0wg= 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 1665141995360529.385215347175; Fri, 7 Oct 2022 04:26:35 -0700 (PDT) Received: from localhost ([::1]:34678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglUw-0007V8-Bh for importer@patchew.org; Fri, 07 Oct 2022 07:26:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54206) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuE-0005in-Jz for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22255) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku5-0003Ce-25 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:38 -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-526-Ih8G82wGO5apOscJOVfIMw-1; Fri, 07 Oct 2022 06:48:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 305E6862FE0; Fri, 7 Oct 2022 10:48:25 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6EE412028DC1; Fri, 7 Oct 2022 10:48:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139708; 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=PNjC7REejBl0RJBZCEgd0Opnj3zP+Nr6L9QKK3iK0Ns=; b=QUElCPjfdTej6281jiYYBs1Yuo/xsB8Vd9mjSRz3l2diJ+P1vBuy7A0d/6ZYIwEw1xbvmK NaBtbV0OdK0AskcrqWasNGrfioYRe7KndPL8TXez6ILz5u5pLfPp+yOmjQk0fRZ+LZiqy9 sLriVF4rXWqlSS+UG3epJOIBkArew0g= X-MC-Unique: Ih8G82wGO5apOscJOVfIMw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 25/50] 9p: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:27 +0200 Message-Id: <20221007104752.141361-26-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665141995994100001 From: Marc-Andr=C3=A9 Lureau Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Signed-off-by: Marc-Andr=C3=A9 Lureau Acked-by: Greg Kurz Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-25-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- hw/9pfs/9p.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/9pfs/9p.h b/hw/9pfs/9p.h index 994f952600..a523ac34a9 100644 --- a/hw/9pfs/9p.h +++ b/hw/9pfs/9p.h @@ -424,21 +424,24 @@ typedef struct V9fsGetlock extern int open_fd_hw; extern int total_open_fd; =20 -static inline void v9fs_path_write_lock(V9fsState *s) +static inline void coroutine_fn +v9fs_path_write_lock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { qemu_co_rwlock_wrlock(&s->rename_lock); } } =20 -static inline void v9fs_path_read_lock(V9fsState *s) +static inline void coroutine_fn +v9fs_path_read_lock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { qemu_co_rwlock_rdlock(&s->rename_lock); } } =20 -static inline void v9fs_path_unlock(V9fsState *s) +static inline void coroutine_fn +v9fs_path_unlock(V9fsState *s) { if (s->ctx.export_flags & V9FS_PATHNAME_FSCONTEXT) { qemu_co_rwlock_unlock(&s->rename_lock); --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665145796; cv=none; d=zohomail.com; s=zohoarc; b=gzV7LNntQscYdkQS7uapSWFWBO9zHqf5ooF2vcBhQHRI/hKjsHFKOgCViDqSIETCfr7TrW09keRsu9p8yxvjxvRbMaOzmWJHZcVdO7a6z5RBHsWlm8IS27fXfVGKTH6gaNTr7Q30f4KMVYyDp7woAloEDdjqYmr5KsFztaIf97A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145796; 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=8KcQ0WRld0hUONr1QSax/SYEJWIJZvW/aVrBdf1FA7A=; b=g/bXGwNCOh20gJNiLnnJ2mLJExIeEZh0v9Y6vrRSDOsjDOyj+UkeYwmqDon/r+0UvQOg9aSFA17Ws5zbvd6q/mrlb3hna2CCfD/iq1popMHXR0dWtXe4uaqPLglxT1nXY9A9/4fPNp2yQlzELBMHFb+tmNdTqXNeUrRk5ksF/G4= 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 1665145796149765.8764560073844; Fri, 7 Oct 2022 05:29:56 -0700 (PDT) Received: from localhost ([::1]:37874 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmUE-0005uU-J8 for importer@patchew.org; Fri, 07 Oct 2022 08:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44616) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku7-0005Rq-Kd for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:32981) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku6-0003D5-31 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:31 -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-110-v-HLJtsmPkqMETEA269VMA-1; Fri, 07 Oct 2022 06:48:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27FD1877CA0; Fri, 7 Oct 2022 10:48:26 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 67CEB2028DC1; Fri, 7 Oct 2022 10:48:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139709; 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=8KcQ0WRld0hUONr1QSax/SYEJWIJZvW/aVrBdf1FA7A=; b=URlyxEClW+bDEDzR/kaUbqJEgI/I8VKxvj/kRV7Di8CWA09pMP/dnz+znxN08wvVhAIRGU 0UIDOowZRkFgmAcmbMghwaUL5J85/EM0kTVKxwctE8l/uH8LRkMNfgOFqBQHmh+jM/zqIJ X82fXPWclY9sYkL3Cgh1V3SjHLMJuqE= X-MC-Unique: v-HLJtsmPkqMETEA269VMA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 26/50] migration: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:28 +0200 Message-Id: <20221007104752.141361-27-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145796650100001 From: Marc-Andr=C3=A9 Lureau Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Juan Quintela Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-26-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- migration/migration.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index bb8bbddfe4..739bb683f3 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -574,7 +574,8 @@ static void process_incoming_migration_bh(void *opaque) migration_incoming_state_destroy(); } =20 -static void process_incoming_migration_co(void *opaque) +static void coroutine_fn +process_incoming_migration_co(void *opaque) { MigrationIncomingState *mis =3D migration_incoming_get_current(); PostcopyState ps; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665144695; cv=none; d=zohomail.com; s=zohoarc; b=eJV6/y+Hm4eHef7H3rDaqlNR6BJerWazX3W+SrG+U3HGVce8IQOjxPAmHi0o+AsXorxZObPK6fwlnR9e+od3lXhycHu4bv2dNSkBgtYIjRrpv6gvu4YcF/W6OFDlF8bTRKktYsxnERiz51KOgVZIwCCB4k5MKJ7og9CnzJAjt8A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665144695; 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=AeMA4+5HIUHZtmEityWP+uIbNI/+4g7xJVx7Uinfqzk=; b=W8Gq5x7/brvK/ldNK3PjOZNt0+TXlTK5OkW5KIba92IakI300rADm5Shgu8iRUtnyYjnVMWf4bHIloUE+YqSGMxVTJhELJNM5TRBh2T+gbPBHJAPk4rGpmScjrkb/wJkckPH4cYcaDaFfgpY6W7QiM3fiXzOFV55OJUp9hyIUl4= 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 1665144695887484.3113778490325; Fri, 7 Oct 2022 05:11:35 -0700 (PDT) Received: from localhost ([::1]:52084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmCU-00027J-J2 for importer@patchew.org; Fri, 07 Oct 2022 08:11:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44626) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuA-0005TN-Dp for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50550) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku6-0003DM-W9 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:32 -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-588-poO7zNx4MLm1ISDwdYksxQ-1; Fri, 07 Oct 2022 06:48:27 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 20C3F101CC62; Fri, 7 Oct 2022 10:48:27 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6042D200C0DE; Fri, 7 Oct 2022 10:48:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139710; 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=AeMA4+5HIUHZtmEityWP+uIbNI/+4g7xJVx7Uinfqzk=; b=BUnuIB91EbeL8R16RbcJR8lTSBAsKTFFxGTQ/NUOm+2bdGHTjscZXnUzKlzHeW0cdm0XGO 3vOmzTomE800jL6+FKvm0oeObtXiKYezOjW3ADXU4q3bqTkjq5QymgVAyPNnbvHdMKRNS7 i1K6fT5wGNi9knoPVfQJbVoKaTrM+9A= X-MC-Unique: poO7zNx4MLm1ISDwdYksxQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 27/50] test-coroutine: add missing coroutine_fn annotations Date: Fri, 7 Oct 2022 12:47:29 +0200 Message-Id: <20221007104752.141361-28-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665144697861100001 From: Marc-Andr=C3=A9 Lureau Callers of coroutine_fn must be coroutine_fn themselves, or the call must be within "if (qemu_in_coroutine())". Apply coroutine_fn to functions where this holds. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: Alberto Faria Signed-off-by: Paolo Bonzini Message-Id: <20220922084924.201610-27-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- tests/unit/test-coroutine.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/test-coroutine.c b/tests/unit/test-coroutine.c index aa77a3bcb3..e16b80c245 100644 --- a/tests/unit/test-coroutine.c +++ b/tests/unit/test-coroutine.c @@ -610,7 +610,7 @@ static void perf_baseline(void) g_test_message("Function call %u iterations: %f s", maxcycles, duratio= n); } =20 -static __attribute__((noinline)) void perf_cost_func(void *opaque) +static __attribute__((noinline)) void coroutine_fn perf_cost_func(void *op= aque) { qemu_coroutine_yield(); } --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665143005; cv=none; d=zohomail.com; s=zohoarc; b=aVOiK2eEuis1BmMEijWQV92PHKPisexCutdEy8vkGiB3jiH9nmyWErTd+F6tLBTG+UnVh+PdOaNnAi8EDmoPAP5xWYVeIrDrpUFujUg/hjEjEcIzyuRToYwDgBiIk/XYEgzkuNrT03CQToMWJ70yJlNfEFhSH2jJUcezTu/mx6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143005; 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=xI4l/yIadiPT+cZ44G1USrI4MwhpfqEZxdmf7qcc/Ew=; b=GIwsmA0aY21Sl+2gEc2Peqmx5a5lTIpNoyVm1Ines5nR3+O1U0aUfiMtdugvWXqFWq0zj7yl8B+jn49HeHHhSbLW8AEy61k7hha3UZHlytjLUV6EwYhtE+DYN8r7CJLXCxMg3FOwyELEcqg5snTnOj4vaOMdQxZYxc3Lem/yvVA= 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 1665143005519491.5872562849661; Fri, 7 Oct 2022 04:43:25 -0700 (PDT) Received: from localhost ([::1]:60760 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogllC-0001Jm-T3 for importer@patchew.org; Fri, 07 Oct 2022 07:43:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuA-0005TM-Hl for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:50313) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku8-0003Dc-5R for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:33 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-551-HtqKMpXkMSaiGJDTpMdH1Q-1; Fri, 07 Oct 2022 06:48:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 187462A59555; Fri, 7 Oct 2022 10:48:28 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 57691200BC6D; Fri, 7 Oct 2022 10:48:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139711; 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=xI4l/yIadiPT+cZ44G1USrI4MwhpfqEZxdmf7qcc/Ew=; b=BF7/+coJqskniO9Vs2/eoB8ZBTKeF0f+wF+gUOfGPwRhbu7nX/Sy1WKrZrto0aZbAx9dm4 sNvb3LElO77RWh9Ah8XcM9+3yUkN+kH7i/gy8D65VjJ7tH+It9bNGUZfLsTb3jvc2OU252 7to+bZoKHUzfMux+QXbxbJBhfOxQQfw= X-MC-Unique: HtqKMpXkMSaiGJDTpMdH1Q-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 28/50] quorum: Remove unnecessary forward declaration Date: Fri, 7 Oct 2022 12:47:30 +0200 Message-Id: <20221007104752.141361-29-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143005811100003 Signed-off-by: Kevin Wolf Message-Id: <20221006122607.162769-1-kwolf@redhat.com> Reviewed-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Kevin Wolf --- block/quorum.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/block/quorum.c b/block/quorum.c index 970f63d9f9..f9e6539ceb 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -232,8 +232,6 @@ static bool quorum_has_too_much_io_failed(QuorumAIOCB *= acb) return false; } =20 -static int read_fifo_child(QuorumAIOCB *acb); - static void quorum_copy_qiov(QEMUIOVector *dest, QEMUIOVector *source) { int i; --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665146081; cv=none; d=zohomail.com; s=zohoarc; b=ZQk8RFOgB4GS+iOiQGDYeMHVfZMg43ZLXU8vrR83q90mWl0ZaAJ4dKxMqCSRNrcGmDgymaJZu4mXYmYfgb7qQkFnDeNO3HYATjtQIt+uD1BDUYCAiAKBVZrFTdrXtGG3uMpFjpcjLC7jFBxIdnseNMq8xrP5+RlaydOGEssS01E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146081; 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=fULRlTMKxeGCyVMMvHXo50ojOJxY7rNm+8NVXRMXaNA=; b=P75O4hMa3SlSzZq3BCXXDXWrYZTlB6xuLW/ctqPXLJOICeJ6mSwno3jkCfflQ72/zV3iSOjUruZeIr+3Bkk2R1eyOlRY8jpH/pPgEokQGbWPrppH7XoZVUAm0UT8xYp06By4JLRzFdapjKYgse/SmZiEUmsUraD1JFwmwXtCu9M= 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 1665146081056213.11586751183222; Fri, 7 Oct 2022 05:34:41 -0700 (PDT) Received: from localhost ([::1]:39352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmYp-0001V8-N2 for importer@patchew.org; Fri, 07 Oct 2022 08:34:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku8-0005Rt-Jl for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50032) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogku6-0003DH-TP for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:32 -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-510-wdBhSBVpNHK_tSNBjmkFsw-1; Fri, 07 Oct 2022 06:48:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 151D2101A528; Fri, 7 Oct 2022 10:48:29 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5493D2024CBB; Fri, 7 Oct 2022 10:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139710; 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=fULRlTMKxeGCyVMMvHXo50ojOJxY7rNm+8NVXRMXaNA=; b=X27ibFllVjUp30j3ExZPOwTKrVOEkGttlaBhYStuKkibQinwbd6mtgKR5Wh1YN0oPM7kKq Lfm7We226WtPu71NWx4qatjCKvZaArkAcUY66tuTcS9Q7Hw5pvA3eZ/FJncfXgX41cmEpg 2oiO5R7SFmsJvxATa5y0HMG6wBLnFo0= X-MC-Unique: wdBhSBVpNHK_tSNBjmkFsw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 29/50] job.c: make job_mutex and job_lock/unlock() public Date: Fri, 7 Oct 2022 12:47:31 +0200 Message-Id: <20221007104752.141361-30-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146081707100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito job mutex will be used to protect the job struct elements and list, replacing AioContext locks. Right now use a shared lock for all jobs, in order to keep things simple. Once the AioContext lock is gone, we can introduce per-job locks. To simplify the switch from aiocontext to job lock, introduce *nop* lock/unlock functions and macros. We want to always call job_lock/unlock outside the AioContext locks, and not vice-versa, otherwise we might get a deadlock. This is not straightforward to do, and that's why we start with nop functions. Once everything is protected by job_lock/unlock, we can change the nop into an actual mutex and remove the aiocontext lock. Since job_mutex is already being used, add static real_job_{lock/unlock} for the existing usage. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-2-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/qemu/job.h | 24 ++++++++++++++++++++++++ job.c | 35 +++++++++++++++++++++++------------ 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 397ac39608..e625547bdb 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -303,6 +303,30 @@ typedef enum JobCreateFlags { JOB_MANUAL_DISMISS =3D 0x04, } JobCreateFlags; =20 +extern QemuMutex job_mutex; + +#define JOB_LOCK_GUARD() /* QEMU_LOCK_GUARD(&job_mutex) */ + +#define WITH_JOB_LOCK_GUARD() /* WITH_QEMU_LOCK_GUARD(&job_mutex) */ + +/** + * job_lock: + * + * Take the mutex protecting the list of jobs and their status. + * Most functions called by the monitor need to call job_lock + * and job_unlock manually. On the other hand, function called + * by the block jobs themselves and by the block layer will take the + * lock for you. + */ +void job_lock(void); + +/** + * job_unlock: + * + * Release the mutex protecting the list of jobs and their status. + */ +void job_unlock(void); + /** * Allocate and return a new job transaction. Jobs can be added to the * transaction using job_txn_add_job(). diff --git a/job.c b/job.c index 20f0d8b2cd..7365db827a 100644 --- a/job.c +++ b/job.c @@ -32,6 +32,12 @@ #include "trace/trace-root.h" #include "qapi/qapi-events-job.h" =20 +/* + * job_mutex protects the jobs list, but also makes the + * struct job fields thread-safe. + */ +QemuMutex job_mutex; + static QLIST_HEAD(, Job) jobs =3D QLIST_HEAD_INITIALIZER(jobs); =20 /* Job State Transition Table */ @@ -74,17 +80,22 @@ struct JobTxn { int refcnt; }; =20 -/* Right now, this mutex is only needed to synchronize accesses to job->bu= sy - * and job->sleep_timer, such as concurrent calls to job_do_yield and - * job_enter. */ -static QemuMutex job_mutex; +void job_lock(void) +{ + /* nop */ +} + +void job_unlock(void) +{ + /* nop */ +} =20 -static void job_lock(void) +static void real_job_lock(void) { qemu_mutex_lock(&job_mutex); } =20 -static void job_unlock(void) +static void real_job_unlock(void) { qemu_mutex_unlock(&job_mutex); } @@ -450,21 +461,21 @@ void job_enter_cond(Job *job, bool(*fn)(Job *job)) return; } =20 - job_lock(); + real_job_lock(); if (job->busy) { - job_unlock(); + real_job_unlock(); return; } =20 if (fn && !fn(job)) { - job_unlock(); + real_job_unlock(); return; } =20 assert(!job->deferred_to_main_loop); timer_del(&job->sleep_timer); job->busy =3D true; - job_unlock(); + real_job_unlock(); aio_co_enter(job->aio_context, job->co); } =20 @@ -481,13 +492,13 @@ void job_enter(Job *job) * called explicitly. */ static void coroutine_fn job_do_yield(Job *job, uint64_t ns) { - job_lock(); + real_job_lock(); if (ns !=3D -1) { timer_mod(&job->sleep_timer, ns); } job->busy =3D false; job_event_idle(job); - job_unlock(); + real_job_unlock(); qemu_coroutine_yield(); =20 /* Set by job_enter_cond() before re-entering the coroutine. */ --=20 2.37.3 From nobody Fri Apr 11 22:47:15 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=1665145599; cv=none; d=zohomail.com; s=zohoarc; b=aWeHyoNVCunrdEw1e9aB7HTZavcAHBTbZrko1mQVTFnrut8gCnrPKNy2Zm391FuaGaRfRZLTzWp9MTudlke8akdwZ6+CoFWWIKEZ3D+SudbAvL4/tjgYnSPX95KrdIFkAvJJXwH41J2hBw9LUIzxGpNRy4f9gDMSRYhK+WOsN+c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145599; 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=pQ7DllBtpirD1S+d3ZnssLKS6wGrzrnLWFLmczKhS4E=; b=bUrnWR+mcLvZ0pxgwENKL4WR7d0CLYDq83vZ3SjWVAasLZ1q5HF7t5ozq9QT8kIO3uirtehhW4WvBa6SU//w6qOBoWtsV7cr0emtKnKdHWKwv1vHkg2Z8UwNIuqz2Nrmfz9wZweQd4dUTc0SKHtUjlBugvyy+iXEW3d+BQnsiAY= 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 1665145599343269.9401278619579; Fri, 7 Oct 2022 05:26:39 -0700 (PDT) Received: from localhost ([::1]:55702 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmR3-0002M4-Cj for importer@patchew.org; Fri, 07 Oct 2022 08:26:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuD-0005fG-4c for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:28543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuA-0003E2-8u for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:36 -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-81-iaeEEMGlNXml_xguLuzLJA-1; Fri, 07 Oct 2022 06:48:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0EBEF95E3A5; Fri, 7 Oct 2022 10:48:30 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4DDCA2024CC5; Fri, 7 Oct 2022 10:48:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139713; 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=pQ7DllBtpirD1S+d3ZnssLKS6wGrzrnLWFLmczKhS4E=; b=RlzLfSijfcJODzaTrSVQFDwrJ4zlfJ2bc7nYCowQvmX693tq0xIiWumWxxySg0HpSH24BD TyTNGMyLxrnj9c0kE+rhEvlEkU4CQXK/3Ge3IE/qGBgxTZwGMSaJNeX8RH8IWYz6c1NhTi RmFleq0okRfw92QVUtgbvMycOtZnd5E= X-MC-Unique: iaeEEMGlNXml_xguLuzLJA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 30/50] job.h: categorize fields in struct Job Date: Fri, 7 Oct 2022 12:47:32 +0200 Message-Id: <20221007104752.141361-31-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145599746100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Categorize the fields in struct Job to understand which ones need to be protected by the job mutex and which don't. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Message-Id: <20220926093214.506243-3-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/qemu/job.h | 61 +++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index e625547bdb..8530c6a4e1 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -40,27 +40,52 @@ typedef struct JobTxn JobTxn; * Long-running operation. */ typedef struct Job { + + /* Fields set at initialization (job_create), and never modified */ + /** The ID of the job. May be NULL for internal jobs. */ char *id; =20 - /** The type of this job. */ + /** + * The type of this job. + * All callbacks are called with job_mutex *not* held. + */ const JobDriver *driver; =20 - /** Reference count of the block job */ - int refcnt; - - /** Current state; See @JobStatus for details. */ - JobStatus status; - - /** AioContext to run the job coroutine in */ - AioContext *aio_context; - /** * The coroutine that executes the job. If not NULL, it is reentered = when * busy is false and the job is cancelled. + * Initialized in job_start() */ Coroutine *co; =20 + /** True if this job should automatically finalize itself */ + bool auto_finalize; + + /** True if this job should automatically dismiss itself */ + bool auto_dismiss; + + /** The completion function that will be called when the job completes= . */ + BlockCompletionFunc *cb; + + /** The opaque value that is passed to the completion function. */ + void *opaque; + + /* ProgressMeter API is thread-safe */ + ProgressMeter progress; + + + /** Protected by AioContext lock */ + + /** AioContext to run the job coroutine in */ + AioContext *aio_context; + + /** Reference count of the block job */ + int refcnt; + + /** Current state; See @JobStatus for details. */ + JobStatus status; + /** * Timer that is used by @job_sleep_ns. Accessed under job_mutex (in * job.c). @@ -112,14 +137,6 @@ typedef struct Job { /** Set to true when the job has deferred work to the main loop. */ bool deferred_to_main_loop; =20 - /** True if this job should automatically finalize itself */ - bool auto_finalize; - - /** True if this job should automatically dismiss itself */ - bool auto_dismiss; - - ProgressMeter progress; - /** * Return code from @run and/or @prepare callback(s). * Not final until the job has reached the CONCLUDED status. @@ -134,12 +151,6 @@ typedef struct Job { */ Error *err; =20 - /** The completion function that will be called when the job completes= . */ - BlockCompletionFunc *cb; - - /** The opaque value that is passed to the completion function. */ - void *opaque; - /** Notifiers called when a cancelled job is finalised */ NotifierList on_finalize_cancelled; =20 @@ -167,6 +178,7 @@ typedef struct Job { =20 /** * Callbacks and other information about a Job driver. + * All callbacks are invoked with job_mutex *not* held. */ struct JobDriver { =20 @@ -472,7 +484,6 @@ void coroutine_fn job_yield(Job *job); */ void coroutine_fn job_sleep_ns(Job *job, int64_t ns); =20 - /** Returns the JobType of a given Job. */ JobType job_type(const Job *job); =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665146584; cv=none; d=zohomail.com; s=zohoarc; b=MpaNSSDCkz+LLbI7gePjJlBUVe/xsZqgsZNWnzjH0w/Wg5VLYJr1R+MpGmIYRy2oUPitk6uBHsTEh1gyHkkGEW5XOFC6HazQKl9GCSIM0xHjl+Simv5u5puD2mYRNiBd98irjaxgeG1QCgnx4eBTfMKkB/vNw8jytwq3WBwNpY4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146584; 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=mzHMEFUxv4YdLPsJiANuUHHkeNTKF4yHPtjR6dkaRec=; b=FJhQbEFJOhOCinex+IRG1HjwoyljlgGoEQeORvKHb9WdNAecgN4ItAmNd2aq+L8MBb+p11P7p3wYLaanSLT/ApgP/yWB5GCcMusunFXTxEvvOEK8Q9Zd1acCxgJUxhdPCPA0S6TvLUv61fHfpO7dBSR3rws31IcWPbwbQTTmzSY= 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 166514658412793.45765294630212; Fri, 7 Oct 2022 05:43:04 -0700 (PDT) Received: from localhost ([::1]:52164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmgv-0003YK-WE for importer@patchew.org; Fri, 07 Oct 2022 08:43:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuB-0005a0-SJ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:35 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27963) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuA-0003Dt-0B for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:35 -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-660-xL4_VxImPCCscI9z7ZyjeA-1; Fri, 07 Oct 2022 06:48:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0D302185A78F; Fri, 7 Oct 2022 10:48:31 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4AFC6200C0DE; Fri, 7 Oct 2022 10:48:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139712; 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=mzHMEFUxv4YdLPsJiANuUHHkeNTKF4yHPtjR6dkaRec=; b=Jp30KZ2uFFAeSLCcophi6xM6IFi7tRg6oT89mONJ2q8UTTAr7UDGK4xhGKEbAukMrolgZe Le+Mih37k7Fg5cjcpUzco0XUvrXvw6Nazl6G/kYuMyMSzYsat7UzuItWErwbIxMUAQ5j1W Aq81ANBqPsDoneW4OSvz+8zy6IDJRhc= X-MC-Unique: xL4_VxImPCCscI9z7ZyjeA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 31/50] job.c: API functions not used outside should be static Date: Fri, 7 Oct 2022 12:47:33 +0200 Message-Id: <20221007104752.141361-32-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146584778100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito job_event_* functions can all be static, as they are not used outside job.c. Same applies for job_txn_add_job(). Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-4-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/qemu/job.h | 18 ------------------ job.c | 22 +++++++++++++++++++--- 2 files changed, 19 insertions(+), 21 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 8530c6a4e1..e3e31e2548 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -358,18 +358,6 @@ JobTxn *job_txn_new(void); */ void job_txn_unref(JobTxn *txn); =20 -/** - * @txn: The transaction (may be NULL) - * @job: Job to add to the transaction - * - * Add @job to the transaction. The @job must not already be in a transac= tion. - * The caller must call either job_txn_unref() or job_completed() to relea= se - * the reference that is automatically grabbed here. - * - * If @txn is NULL, the function does nothing. - */ -void job_txn_add_job(JobTxn *txn, Job *job); - /** * Create a new long-running job and return it. * @@ -431,12 +419,6 @@ void job_progress_set_remaining(Job *job, uint64_t rem= aining); */ void job_progress_increase_remaining(Job *job, uint64_t delta); =20 -/** To be called when a cancelled job is finalised. */ -void job_event_cancelled(Job *job); - -/** To be called when a successfully completed job is finalised. */ -void job_event_completed(Job *job); - /** * Conditionally enter the job coroutine if the job is ready to run, not * already busy and fn() returns true. fn() is called while under the job_= lock diff --git a/job.c b/job.c index 7365db827a..9500b5b36e 100644 --- a/job.c +++ b/job.c @@ -125,7 +125,17 @@ void job_txn_unref(JobTxn *txn) } } =20 -void job_txn_add_job(JobTxn *txn, Job *job) +/** + * @txn: The transaction (may be NULL) + * @job: Job to add to the transaction + * + * Add @job to the transaction. The @job must not already be in a transac= tion. + * The caller must call either job_txn_unref() or job_completed() to relea= se + * the reference that is automatically grabbed here. + * + * If @txn is NULL, the function does nothing. + */ +static void job_txn_add_job(JobTxn *txn, Job *job) { if (!txn) { return; @@ -427,12 +437,18 @@ void job_progress_increase_remaining(Job *job, uint64= _t delta) progress_increase_remaining(&job->progress, delta); } =20 -void job_event_cancelled(Job *job) +/** + * To be called when a cancelled job is finalised. + */ +static void job_event_cancelled(Job *job) { notifier_list_notify(&job->on_finalize_cancelled, job); } =20 -void job_event_completed(Job *job) +/** + * To be called when a successfully completed job is finalised. + */ +static void job_event_completed(Job *job) { notifier_list_notify(&job->on_finalize_completed, job); } --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665146958; cv=none; d=zohomail.com; s=zohoarc; b=VxDB7hLoFjynKZmQ9O1yNa4hudPSP13BH9aJ0kUqrV0dhg9Mtij4L69tNxgKRkQsvPzqSEdfc1xsEPpU5g5wvPjOo42zHYk5FUrGY8zGopyw7evw8GgII+L83BmtbMESuoRetVU2/IPjq+D3oHFOxE91prgwszKS7yQvzN/BzeE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146958; 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=fD7SsacDltC4lVcXn6LNGXSfRXOcskpa9bdilaKw6Hg=; b=P/l+YaP5DTKBVxvusZT94ptOAksSk94mV9JHy1aWJDgmhCrF09nmBRnsbamcesgDFTga5F98rgQT4cieKd16iiIkIM+9v0HAtYWYJHtdRPOFYklIWFRLSg+TmNPB+8h7cDb/lhA1iB4tl6DKk402QawXWMdYi0exoFG19m/f4J0= 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 16651469587311016.3717995376624; Fri, 7 Oct 2022 05:49:18 -0700 (PDT) Received: from localhost ([::1]:59554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmmz-0001BK-HP for importer@patchew.org; Fri, 07 Oct 2022 08:49:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuD-0005ez-2i for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47809) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuA-0003E4-9O for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:36 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-589-UdbEz8SUMeSBSwkG8bogsw-1; Fri, 07 Oct 2022 06:48:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06854382624C; Fri, 7 Oct 2022 10:48:32 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 454C72028DC1; Fri, 7 Oct 2022 10:48:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139713; 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=fD7SsacDltC4lVcXn6LNGXSfRXOcskpa9bdilaKw6Hg=; b=egtogKAiZN7ca8jFZKiZURgQewT/Jq5bKGKidmKTfcF81WZQSxo+rVC/60mplnjvu0pWS4 79ptByqSB1q+TnKC/AftyrmwfBzs6LDlAk4Uqfg4JgRGpSt+nSGc2tb05LtkSLf9cr6U7/ z9wpSrvmubiUIJN6FclAYGu6dLCJ2yY= X-MC-Unique: UdbEz8SUMeSBSwkG8bogsw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 32/50] aio-wait.h: introduce AIO_WAIT_WHILE_UNLOCKED Date: Fri, 7 Oct 2022 12:47:34 +0200 Message-Id: <20221007104752.141361-33-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146960707100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Same as AIO_WAIT_WHILE macro, but if we are in the Main loop do not release and then acquire ctx_ 's aiocontext. Once all Aiocontext locks go away, this macro will replace AIO_WAIT_WHILE. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-5-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/aio-wait.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h index 54840f8622..dd9a7f6461 100644 --- a/include/block/aio-wait.h +++ b/include/block/aio-wait.h @@ -59,10 +59,13 @@ typedef struct { extern AioWait global_aio_wait; =20 /** - * AIO_WAIT_WHILE: + * AIO_WAIT_WHILE_INTERNAL: * @ctx: the aio context, or NULL if multiple aio contexts (for which the * caller does not hold a lock) are involved in the polling conditio= n. * @cond: wait while this conditional expression is true + * @unlock: whether to unlock and then lock again @ctx. This apples + * only when waiting for another AioContext from the main loop. + * Otherwise it's ignored. * * Wait while a condition is true. Use this to implement synchronous * operations that require event loop activity. @@ -75,7 +78,7 @@ extern AioWait global_aio_wait; * wait on conditions between two IOThreads since that could lead to deadl= ock, * go via the main loop instead. */ -#define AIO_WAIT_WHILE(ctx, cond) ({ \ +#define AIO_WAIT_WHILE_INTERNAL(ctx, cond, unlock) ({ \ bool waited_ =3D false; \ AioWait *wait_ =3D &global_aio_wait; \ AioContext *ctx_ =3D (ctx); \ @@ -92,11 +95,11 @@ extern AioWait global_aio_wait; assert(qemu_get_current_aio_context() =3D=3D \ qemu_get_aio_context()); \ while ((cond)) { \ - if (ctx_) { \ + if (unlock && ctx_) { \ aio_context_release(ctx_); \ } \ aio_poll(qemu_get_aio_context(), true); \ - if (ctx_) { \ + if (unlock && ctx_) { \ aio_context_acquire(ctx_); \ } \ waited_ =3D true; \ @@ -105,6 +108,12 @@ extern AioWait global_aio_wait; qatomic_dec(&wait_->num_waiters); \ waited_; }) =20 +#define AIO_WAIT_WHILE(ctx, cond) \ + AIO_WAIT_WHILE_INTERNAL(ctx, cond, true) + +#define AIO_WAIT_WHILE_UNLOCKED(ctx, cond) \ + AIO_WAIT_WHILE_INTERNAL(ctx, cond, false) + /** * aio_wait_kick: * Wake up the main thread if it is waiting on AIO_WAIT_WHILE(). During --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665145395; cv=none; d=zohomail.com; s=zohoarc; b=ECj8hwf7fBX+sy/7ggmr5n9BeCar/V2avhY5c/9RwQgqHzQ6GfzLuGKAUB5j6n9z1A2NC1mmjz4zcQ2hb3KSPWo9i8S/mk+alkdDLdxDGmM5FGbGx+OmxXOOSdBm9VIu/uR4GQvGBSpZde8Wq46Pn8UMn+btqoEC5m6ywsbYb/o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145395; 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=Km+ii9D7ROH2QVi2O4c+Xg1Jo+k74YZRtZ8gsp2h2GE=; b=a6SkSrrojcXGEUpLrkcxve2LcffI32dkrE2x2R73iNOkcIvvAeuC60lBPUc0LZvN1gvrqlyR0US6GrZvzGpYDD26U8XiV0XikJ0c0zPZBplDJ2rZ4xY2hkCtFlQIvHnxuxNvJ4+n9KBAU3vmQZIR67o3aDuawiXVgmOIZt7LEc0= 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 166514539567567.24094508789506; Fri, 7 Oct 2022 05:23:15 -0700 (PDT) Received: from localhost ([::1]:36810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmNj-0007IV-MW for importer@patchew.org; Fri, 07 Oct 2022 08:23:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0005q4-QJ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:34129) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuD-0003Fs-Gr for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -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-658-552q1O4GNTCReV8a35OqrQ-1; Fri, 07 Oct 2022 06:48:33 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45DE6811E87; Fri, 7 Oct 2022 10:48:33 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45CDC2024CBB; Fri, 7 Oct 2022 10:48:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139716; 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=Km+ii9D7ROH2QVi2O4c+Xg1Jo+k74YZRtZ8gsp2h2GE=; b=JXdjVH6W1MIluRuqDNqk1l/jVkd617qNGN0TgM+qoXH50Bt1fgfFsFV705IRELcWqeYIDh aHEuzxDfFjp3WpbRnxavlCUEtPWXlSOcalJHARYhpYYBI1wLVC3vpoxnlRe5cH/MA8ACT0 tYpL32i2uCKIe/NTXuBOFR+9W4iNB8U= X-MC-Unique: 552q1O4GNTCReV8a35OqrQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 33/50] job.c: add job_lock/unlock while keeping job.h intact Date: Fri, 7 Oct 2022 12:47:35 +0200 Message-Id: <20221007104752.141361-34-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145397281100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito With "intact" we mean that all job.h functions implicitly take the lock. Therefore API callers are unmodified. This means that: - many static functions that will be always called with job lock held become _locked, and call _locked functions - all public functions take the lock internally if needed, and call _locked functions - all public functions called internally by other functions in job.c will h= ave a _locked counterpart (sometimes public), to avoid deadlocks (job lock alre= ady taken). These functions are not used for now. - some public functions called only from exernal files (not job.c) do not have _locked() counterpart and take the lock inside. Others won't need the lock at all because use fields only set at initialization and never modified. job_{lock/unlock} is independent from real_job_{lock/unlock}. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop* Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-6-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/qemu/job.h | 138 +++++++++- job.c | 610 ++++++++++++++++++++++++++++++++------------- 2 files changed, 561 insertions(+), 187 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index e3e31e2548..870dce1535 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -358,8 +358,15 @@ JobTxn *job_txn_new(void); */ void job_txn_unref(JobTxn *txn); =20 +/* + * Same as job_txn_unref(), but called with job lock held. + * Might release the lock temporarily. + */ +void job_txn_unref_locked(JobTxn *txn); + /** * Create a new long-running job and return it. + * Called with job_mutex *not* held. * * @job_id: The id of the newly-created job, or %NULL for internal jobs * @driver: The class object for the newly-created job. @@ -380,17 +387,25 @@ void *job_create(const char *job_id, const JobDriver = *driver, JobTxn *txn, */ void job_ref(Job *job); =20 +/* Same as job_ref(), but called with job lock held. */ +void job_ref_locked(Job *job); + /** * Release a reference that was previously acquired with job_ref() or * job_create(). If it's the last reference to the object, it will be free= d. */ void job_unref(Job *job); =20 +/* Same as job_unref(), but called with job lock held. */ +void job_unref_locked(Job *job); + /** * @job: The job that has made progress * @done: How much progress the job made since the last call * * Updates the progress counter of the job. + * + * May be called with mutex held or not held. */ void job_progress_update(Job *job, uint64_t done); =20 @@ -401,6 +416,8 @@ void job_progress_update(Job *job, uint64_t done); * * Sets the expected end value of the progress counter of a job so that a * completion percentage can be calculated when the progress is updated. + * + * May be called with mutex held or not held. */ void job_progress_set_remaining(Job *job, uint64_t remaining); =20 @@ -416,6 +433,8 @@ void job_progress_set_remaining(Job *job, uint64_t rema= ining); * length before, and job_progress_update() afterwards. * (So the operation acts as a parenthesis in regards to the main job * operation running in background.) + * + * May be called with mutex held or not held. */ void job_progress_increase_remaining(Job *job, uint64_t delta); =20 @@ -426,11 +445,19 @@ void job_progress_increase_remaining(Job *job, uint64= _t delta); */ void job_enter_cond(Job *job, bool(*fn)(Job *job)); =20 +/* + * Same as job_enter_cond(), but called with job lock held. + * Might release the lock temporarily. + */ +void job_enter_cond_locked(Job *job, bool(*fn)(Job *job)); + /** * @job: A job that has not yet been started. * * Begins execution of a job. * Takes ownership of one reference to the job object. + * + * Called with job_mutex *not* held. */ void job_start(Job *job); =20 @@ -438,6 +465,7 @@ void job_start(Job *job); * @job: The job to enter. * * Continue the specified job by entering the coroutine. + * Called with job_mutex *not* held. */ void job_enter(Job *job); =20 @@ -446,6 +474,8 @@ void job_enter(Job *job); * * Pause now if job_pause() has been called. Jobs that perform lots of I/O * must call this between requests so that the job can be paused. + * + * Called with job_mutex *not* held. */ void coroutine_fn job_pause_point(Job *job); =20 @@ -453,6 +483,7 @@ void coroutine_fn job_pause_point(Job *job); * @job: The job that calls the function. * * Yield the job coroutine. + * Called with job_mutex *not* held. */ void coroutine_fn job_yield(Job *job); =20 @@ -463,6 +494,8 @@ void coroutine_fn job_yield(Job *job); * Put the job to sleep (assuming that it wasn't canceled) for @ns * %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will immediately * interrupt the wait. + * + * Called with job_mutex *not* held. */ void coroutine_fn job_sleep_ns(Job *job, int64_t ns); =20 @@ -475,21 +508,40 @@ const char *job_type_str(const Job *job); /** Returns true if the job should not be visible to the management layer.= */ bool job_is_internal(Job *job); =20 -/** Returns whether the job is being cancelled. */ +/** + * Returns whether the job is being cancelled. + * Called with job_mutex *not* held. + */ bool job_is_cancelled(Job *job); =20 +/* Same as job_is_cancelled(), but called with job lock held. */ +bool job_is_cancelled_locked(Job *job); + /** * Returns whether the job is scheduled for cancellation (at an * indefinite point). + * Called with job_mutex *not* held. */ bool job_cancel_requested(Job *job); =20 -/** Returns whether the job is in a completed state. */ +/** + * Returns whether the job is in a completed state. + * Called with job_mutex *not* held. + */ bool job_is_completed(Job *job); =20 -/** Returns whether the job is ready to be completed. */ +/* Same as job_is_completed(), but called with job lock held. */ +bool job_is_completed_locked(Job *job); + +/** + * Returns whether the job is ready to be completed. + * Called with job_mutex *not* held. + */ bool job_is_ready(Job *job); =20 +/* Same as job_is_ready(), but called with job lock held. */ +bool job_is_ready_locked(Job *job); + /** * Request @job to pause at the next pause point. Must be paired with * job_resume(). If the job is supposed to be resumed by user action, call @@ -497,24 +549,45 @@ bool job_is_ready(Job *job); */ void job_pause(Job *job); =20 +/* Same as job_pause(), but called with job lock held. */ +void job_pause_locked(Job *job); + /** Resumes a @job paused with job_pause. */ void job_resume(Job *job); =20 +/* + * Same as job_resume(), but called with job lock held. + * Might release the lock temporarily. + */ +void job_resume_locked(Job *job); + /** * Asynchronously pause the specified @job. * Do not allow a resume until a matching call to job_user_resume. */ void job_user_pause(Job *job, Error **errp); =20 +/* Same as job_user_pause(), but called with job lock held. */ +void job_user_pause_locked(Job *job, Error **errp); + /** Returns true if the job is user-paused. */ bool job_user_paused(Job *job); =20 +/* Same as job_user_paused(), but called with job lock held. */ +bool job_user_paused_locked(Job *job); + /** * Resume the specified @job. * Must be paired with a preceding job_user_pause. */ void job_user_resume(Job *job, Error **errp); =20 +/* + * Same as job_user_resume(), but called with job lock held. + * Might release the lock temporarily. + */ +void job_user_resume_locked(Job *job, Error **errp); + /** * Get the next element from the list of block jobs after @job, or the * first one if @job is %NULL. @@ -523,6 +596,9 @@ void job_user_resume(Job *job, Error **errp); */ Job *job_next(Job *job); =20 +/* Same as job_next(), but called with job lock held. */ +Job *job_next_locked(Job *job); + /** * Get the job identified by @id (which must not be %NULL). * @@ -530,6 +606,9 @@ Job *job_next(Job *job); */ Job *job_get(const char *id); =20 +/* Same as job_get(), but called with job lock held. */ +Job *job_get_locked(const char *id); + /** * Check whether the verb @verb can be applied to @job in its current stat= e. * Returns 0 if the verb can be applied; otherwise errp is set and -EPERM @@ -537,27 +616,48 @@ Job *job_get(const char *id); */ int job_apply_verb(Job *job, JobVerb verb, Error **errp); =20 -/** The @job could not be started, free it. */ +/* Same as job_apply_verb, but called with job lock held. */ +int job_apply_verb_locked(Job *job, JobVerb verb, Error **errp); + +/** + * The @job could not be started, free it. + * Called with job_mutex *not* held. + */ void job_early_fail(Job *job); =20 -/** Moves the @job from RUNNING to READY */ +/** + * Moves the @job from RUNNING to READY. + * Called with job_mutex *not* held. + */ void job_transition_to_ready(Job *job); =20 /** Asynchronously complete the specified @job. */ void job_complete(Job *job, Error **errp); =20 +/* + * Same as job_complete(), but called with job lock held. + * Might release the lock temporarily. + */ +void job_complete_locked(Job *job, Error **errp); + /** * Asynchronously cancel the specified @job. If @force is true, the job sh= ould * be cancelled immediately without waiting for a consistent state. */ void job_cancel(Job *job, bool force); =20 +/* Same as job_cancel(), but called with job lock held. */ +void job_cancel_locked(Job *job, bool force); + /** * Cancels the specified job like job_cancel(), but may refuse to do so if= the * operation isn't meaningful in the current state of the job. */ void job_user_cancel(Job *job, bool force, Error **errp); =20 +/* Same as job_user_cancel(), but called with job lock held. */ +void job_user_cancel_locked(Job *job, bool force, Error **errp); + /** * Synchronously cancel the @job. The completion callback is called * before the function returns. If @force is false, the job may @@ -571,7 +671,14 @@ void job_user_cancel(Job *job, bool force, Error **err= p); */ int job_cancel_sync(Job *job, bool force); =20 -/** Synchronously force-cancels all jobs using job_cancel_sync(). */ +/* Same as job_cancel_sync, but called with job lock held. */ +int job_cancel_sync_locked(Job *job, bool force); + +/** + * Synchronously force-cancels all jobs using job_cancel_sync_locked(). + * + * Called with job_lock *not* held. + */ void job_cancel_sync_all(void); =20 /** @@ -590,6 +697,9 @@ void job_cancel_sync_all(void); */ int job_complete_sync(Job *job, Error **errp); =20 +/* Same as job_complete_sync, but called with job lock held. */ +int job_complete_sync_locked(Job *job, Error **errp); + /** * For a @job that has finished its work and is pending awaiting explicit * acknowledgement to commit its work, this will commit that work. @@ -600,12 +710,18 @@ int job_complete_sync(Job *job, Error **errp); */ void job_finalize(Job *job, Error **errp); =20 +/* Same as job_finalize(), but called with job lock held. */ +void job_finalize_locked(Job *job, Error **errp); + /** * Remove the concluded @job from the query list and resets the passed poi= nter * to %NULL. Returns an error if the job is not actually concluded. */ void job_dismiss(Job **job, Error **errp); =20 +/* Same as job_dismiss(), but called with job lock held. */ +void job_dismiss_locked(Job **job, Error **errp); + /** * Synchronously finishes the given @job. If @finish is given, it is calle= d to * trigger completion or cancellation of the job. @@ -615,6 +731,14 @@ void job_dismiss(Job **job, Error **errp); * * Callers must hold the AioContext lock of job->aio_context. */ -int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error *= *errp); +int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), + Error **errp); + +/* + * Same as job_finish_sync(), but called with job lock held. + * Might release the lock temporarily. + */ +int job_finish_sync_locked(Job *job, void (*finish)(Job *, Error **errp), + Error **errp); =20 #endif diff --git a/job.c b/job.c index 9500b5b36e..87564979cb 100644 --- a/job.c +++ b/job.c @@ -38,6 +38,7 @@ */ QemuMutex job_mutex; =20 +/* Protected by job_mutex */ static QLIST_HEAD(, Job) jobs =3D QLIST_HEAD_INITIALIZER(jobs); =20 /* Job State Transition Table */ @@ -113,18 +114,25 @@ JobTxn *job_txn_new(void) return txn; } =20 -static void job_txn_ref(JobTxn *txn) +/* Called with job_mutex held. */ +static void job_txn_ref_locked(JobTxn *txn) { txn->refcnt++; } =20 -void job_txn_unref(JobTxn *txn) +void job_txn_unref_locked(JobTxn *txn) { if (txn && --txn->refcnt =3D=3D 0) { g_free(txn); } } =20 +void job_txn_unref(JobTxn *txn) +{ + JOB_LOCK_GUARD(); + job_txn_unref_locked(txn); +} + /** * @txn: The transaction (may be NULL) * @job: Job to add to the transaction @@ -134,8 +142,10 @@ void job_txn_unref(JobTxn *txn) * the reference that is automatically grabbed here. * * If @txn is NULL, the function does nothing. + * + * Called with job_mutex held. */ -static void job_txn_add_job(JobTxn *txn, Job *job) +static void job_txn_add_job_locked(JobTxn *txn, Job *job) { if (!txn) { return; @@ -145,19 +155,21 @@ static void job_txn_add_job(JobTxn *txn, Job *job) job->txn =3D txn; =20 QLIST_INSERT_HEAD(&txn->jobs, job, txn_list); - job_txn_ref(txn); + job_txn_ref_locked(txn); } =20 -static void job_txn_del_job(Job *job) +/* Called with job_mutex held. */ +static void job_txn_del_job_locked(Job *job) { if (job->txn) { QLIST_REMOVE(job, txn_list); - job_txn_unref(job->txn); + job_txn_unref_locked(job->txn); job->txn =3D NULL; } } =20 -static int job_txn_apply(Job *job, int fn(Job *)) +/* Called with job_mutex held, but releases it temporarily. */ +static int job_txn_apply_locked(Job *job, int fn(Job *)) { AioContext *inner_ctx; Job *other_job, *next; @@ -170,7 +182,7 @@ static int job_txn_apply(Job *job, int fn(Job *)) * we need to release it here to avoid holding the lock twice - which = would * break AIO_WAIT_WHILE from within fn. */ - job_ref(job); + job_ref_locked(job); aio_context_release(job->aio_context); =20 QLIST_FOREACH_SAFE(other_job, &txn->jobs, txn_list, next) { @@ -188,7 +200,7 @@ static int job_txn_apply(Job *job, int fn(Job *)) * can't use a local variable to cache it. */ aio_context_acquire(job->aio_context); - job_unref(job); + job_unref_locked(job); return rc; } =20 @@ -197,7 +209,8 @@ bool job_is_internal(Job *job) return (job->id =3D=3D NULL); } =20 -static void job_state_transition(Job *job, JobStatus s1) +/* Called with job_mutex held. */ +static void job_state_transition_locked(Job *job, JobStatus s1) { JobStatus s0 =3D job->status; assert(s1 >=3D 0 && s1 < JOB_STATUS__MAX); @@ -212,7 +225,7 @@ static void job_state_transition(Job *job, JobStatus s1) } } =20 -int job_apply_verb(Job *job, JobVerb verb, Error **errp) +int job_apply_verb_locked(Job *job, JobVerb verb, Error **errp) { JobStatus s0 =3D job->status; assert(verb >=3D 0 && verb < JOB_VERB__MAX); @@ -226,6 +239,12 @@ int job_apply_verb(Job *job, JobVerb verb, Error **err= p) return -EPERM; } =20 +int job_apply_verb(Job *job, JobVerb verb, Error **errp) +{ + JOB_LOCK_GUARD(); + return job_apply_verb_locked(job, verb, errp); +} + JobType job_type(const Job *job) { return job->driver->job_type; @@ -236,19 +255,32 @@ const char *job_type_str(const Job *job) return JobType_str(job_type(job)); } =20 -bool job_is_cancelled(Job *job) +bool job_is_cancelled_locked(Job *job) { /* force_cancel may be true only if cancelled is true, too */ assert(job->cancelled || !job->force_cancel); return job->force_cancel; } =20 -bool job_cancel_requested(Job *job) +bool job_is_cancelled(Job *job) +{ + JOB_LOCK_GUARD(); + return job_is_cancelled_locked(job); +} + +/* Called with job_mutex held. */ +static bool job_cancel_requested_locked(Job *job) { return job->cancelled; } =20 -bool job_is_ready(Job *job) +bool job_cancel_requested(Job *job) +{ + JOB_LOCK_GUARD(); + return job_cancel_requested_locked(job); +} + +bool job_is_ready_locked(Job *job) { switch (job->status) { case JOB_STATUS_UNDEFINED: @@ -270,7 +302,13 @@ bool job_is_ready(Job *job) return false; } =20 -bool job_is_completed(Job *job) +bool job_is_ready(Job *job) +{ + JOB_LOCK_GUARD(); + return job_is_ready_locked(job); +} + +bool job_is_completed_locked(Job *job) { switch (job->status) { case JOB_STATUS_UNDEFINED: @@ -292,17 +330,24 @@ bool job_is_completed(Job *job) return false; } =20 -static bool job_started(Job *job) +bool job_is_completed(Job *job) +{ + JOB_LOCK_GUARD(); + return job_is_completed_locked(job); +} + +static bool job_started_locked(Job *job) { return job->co; } =20 -static bool job_should_pause(Job *job) +/* Called with job_mutex held. */ +static bool job_should_pause_locked(Job *job) { return job->pause_count > 0; } =20 -Job *job_next(Job *job) +Job *job_next_locked(Job *job) { if (!job) { return QLIST_FIRST(&jobs); @@ -310,7 +355,13 @@ Job *job_next(Job *job) return QLIST_NEXT(job, job_list); } =20 -Job *job_get(const char *id) +Job *job_next(Job *job) +{ + JOB_LOCK_GUARD(); + return job_next_locked(job); +} + +Job *job_get_locked(const char *id) { Job *job; =20 @@ -323,6 +374,13 @@ Job *job_get(const char *id) return NULL; } =20 +Job *job_get(const char *id) +{ + JOB_LOCK_GUARD(); + return job_get_locked(id); +} + +/* Called with job_mutex *not* held. */ static void job_sleep_timer_cb(void *opaque) { Job *job =3D opaque; @@ -336,6 +394,8 @@ void *job_create(const char *job_id, const JobDriver *d= river, JobTxn *txn, { Job *job; =20 + JOB_LOCK_GUARD(); + if (job_id) { if (flags & JOB_INTERNAL) { error_setg(errp, "Cannot specify job ID for internal job"); @@ -345,7 +405,7 @@ void *job_create(const char *job_id, const JobDriver *d= river, JobTxn *txn, error_setg(errp, "Invalid job ID '%s'", job_id); return NULL; } - if (job_get(job_id)) { + if (job_get_locked(job_id)) { error_setg(errp, "Job ID '%s' already in use", job_id); return NULL; } @@ -375,7 +435,7 @@ void *job_create(const char *job_id, const JobDriver *d= river, JobTxn *txn, notifier_list_init(&job->on_ready); notifier_list_init(&job->on_idle); =20 - job_state_transition(job, JOB_STATUS_CREATED); + job_state_transition_locked(job, JOB_STATUS_CREATED); aio_timer_init(qemu_get_aio_context(), &job->sleep_timer, QEMU_CLOCK_REALTIME, SCALE_NS, job_sleep_timer_cb, job); @@ -386,21 +446,27 @@ void *job_create(const char *job_id, const JobDriver = *driver, JobTxn *txn, * consolidating the job management logic */ if (!txn) { txn =3D job_txn_new(); - job_txn_add_job(txn, job); - job_txn_unref(txn); + job_txn_add_job_locked(txn, job); + job_txn_unref_locked(txn); } else { - job_txn_add_job(txn, job); + job_txn_add_job_locked(txn, job); } =20 return job; } =20 -void job_ref(Job *job) +void job_ref_locked(Job *job) { ++job->refcnt; } =20 -void job_unref(Job *job) +void job_ref(Job *job) +{ + JOB_LOCK_GUARD(); + job_ref_locked(job); +} + +void job_unref_locked(Job *job) { GLOBAL_STATE_CODE(); =20 @@ -410,7 +476,9 @@ void job_unref(Job *job) assert(!job->txn); =20 if (job->driver->free) { + job_unlock(); job->driver->free(job); + job_lock(); } =20 QLIST_REMOVE(job, job_list); @@ -422,6 +490,12 @@ void job_unref(Job *job) } } =20 +void job_unref(Job *job) +{ + JOB_LOCK_GUARD(); + job_unref_locked(job); +} + void job_progress_update(Job *job, uint64_t done) { progress_work_done(&job->progress, done); @@ -439,38 +513,43 @@ void job_progress_increase_remaining(Job *job, uint64= _t delta) =20 /** * To be called when a cancelled job is finalised. + * Called with job_mutex held. */ -static void job_event_cancelled(Job *job) +static void job_event_cancelled_locked(Job *job) { notifier_list_notify(&job->on_finalize_cancelled, job); } =20 /** * To be called when a successfully completed job is finalised. + * Called with job_mutex held. */ -static void job_event_completed(Job *job) +static void job_event_completed_locked(Job *job) { notifier_list_notify(&job->on_finalize_completed, job); } =20 -static void job_event_pending(Job *job) +/* Called with job_mutex held. */ +static void job_event_pending_locked(Job *job) { notifier_list_notify(&job->on_pending, job); } =20 -static void job_event_ready(Job *job) +/* Called with job_mutex held. */ +static void job_event_ready_locked(Job *job) { notifier_list_notify(&job->on_ready, job); } =20 -static void job_event_idle(Job *job) +/* Called with job_mutex held. */ +static void job_event_idle_locked(Job *job) { notifier_list_notify(&job->on_idle, job); } =20 -void job_enter_cond(Job *job, bool(*fn)(Job *job)) +void job_enter_cond_locked(Job *job, bool(*fn)(Job *job)) { - if (!job_started(job)) { + if (!job_started_locked(job)) { return; } if (job->deferred_to_main_loop) { @@ -492,12 +571,21 @@ void job_enter_cond(Job *job, bool(*fn)(Job *job)) timer_del(&job->sleep_timer); job->busy =3D true; real_job_unlock(); + job_unlock(); aio_co_enter(job->aio_context, job->co); + job_lock(); +} + +void job_enter_cond(Job *job, bool(*fn)(Job *job)) +{ + JOB_LOCK_GUARD(); + job_enter_cond_locked(job, fn); } =20 void job_enter(Job *job) { - job_enter_cond(job, NULL); + JOB_LOCK_GUARD(); + job_enter_cond_locked(job, NULL); } =20 /* Yield, and schedule a timer to reenter the coroutine after @ns nanoseco= nds. @@ -505,100 +593,129 @@ void job_enter(Job *job) * is allowed and cancels the timer. * * If @ns is (uint64_t) -1, no timer is scheduled and job_enter() must be - * called explicitly. */ -static void coroutine_fn job_do_yield(Job *job, uint64_t ns) + * called explicitly. + * + * Called with job_mutex held, but releases it temporarily. + */ +static void coroutine_fn job_do_yield_locked(Job *job, uint64_t ns) { real_job_lock(); if (ns !=3D -1) { timer_mod(&job->sleep_timer, ns); } job->busy =3D false; - job_event_idle(job); + job_event_idle_locked(job); real_job_unlock(); + job_unlock(); qemu_coroutine_yield(); + job_lock(); =20 /* Set by job_enter_cond() before re-entering the coroutine. */ assert(job->busy); } =20 -void coroutine_fn job_pause_point(Job *job) +/* Called with job_mutex held, but releases it temporarily. */ +static void coroutine_fn job_pause_point_locked(Job *job) { - assert(job && job_started(job)); + assert(job && job_started_locked(job)); =20 - if (!job_should_pause(job)) { + if (!job_should_pause_locked(job)) { return; } - if (job_is_cancelled(job)) { + if (job_is_cancelled_locked(job)) { return; } =20 if (job->driver->pause) { + job_unlock(); job->driver->pause(job); + job_lock(); } =20 - if (job_should_pause(job) && !job_is_cancelled(job)) { + if (job_should_pause_locked(job) && !job_is_cancelled_locked(job)) { JobStatus status =3D job->status; - job_state_transition(job, status =3D=3D JOB_STATUS_READY - ? JOB_STATUS_STANDBY - : JOB_STATUS_PAUSED); + job_state_transition_locked(job, status =3D=3D JOB_STATUS_READY + ? JOB_STATUS_STANDBY + : JOB_STATUS_PAUSED); job->paused =3D true; - job_do_yield(job, -1); + job_do_yield_locked(job, -1); job->paused =3D false; - job_state_transition(job, status); + job_state_transition_locked(job, status); } =20 if (job->driver->resume) { + job_unlock(); job->driver->resume(job); + job_lock(); } } =20 -void coroutine_fn job_yield(Job *job) +void coroutine_fn job_pause_point(Job *job) +{ + JOB_LOCK_GUARD(); + job_pause_point_locked(job); +} + +static void coroutine_fn job_yield_locked(Job *job) { assert(job->busy); =20 /* Check cancellation *before* setting busy =3D false, too! */ - if (job_is_cancelled(job)) { + if (job_is_cancelled_locked(job)) { return; } =20 - if (!job_should_pause(job)) { - job_do_yield(job, -1); + if (!job_should_pause_locked(job)) { + job_do_yield_locked(job, -1); } =20 - job_pause_point(job); + job_pause_point_locked(job); +} + +void coroutine_fn job_yield(Job *job) +{ + JOB_LOCK_GUARD(); + job_yield_locked(job); } =20 void coroutine_fn job_sleep_ns(Job *job, int64_t ns) { + JOB_LOCK_GUARD(); assert(job->busy); =20 /* Check cancellation *before* setting busy =3D false, too! */ - if (job_is_cancelled(job)) { + if (job_is_cancelled_locked(job)) { return; } =20 - if (!job_should_pause(job)) { - job_do_yield(job, qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + ns); + if (!job_should_pause_locked(job)) { + job_do_yield_locked(job, qemu_clock_get_ns(QEMU_CLOCK_REALTIME) + = ns); } =20 - job_pause_point(job); + job_pause_point_locked(job); } =20 -/* Assumes the block_job_mutex is held */ -static bool job_timer_not_pending(Job *job) +/* Assumes the job_mutex is held */ +static bool job_timer_not_pending_locked(Job *job) { return !timer_pending(&job->sleep_timer); } =20 -void job_pause(Job *job) +void job_pause_locked(Job *job) { job->pause_count++; if (!job->paused) { - job_enter(job); + job_enter_cond_locked(job, NULL); } } =20 -void job_resume(Job *job) +void job_pause(Job *job) +{ + JOB_LOCK_GUARD(); + job_pause_locked(job); +} + +void job_resume_locked(Job *job) { assert(job->pause_count > 0); job->pause_count--; @@ -607,12 +724,18 @@ void job_resume(Job *job) } =20 /* kick only if no timer is pending */ - job_enter_cond(job, job_timer_not_pending); + job_enter_cond_locked(job, job_timer_not_pending_locked); } =20 -void job_user_pause(Job *job, Error **errp) +void job_resume(Job *job) { - if (job_apply_verb(job, JOB_VERB_PAUSE, errp)) { + JOB_LOCK_GUARD(); + job_resume_locked(job); +} + +void job_user_pause_locked(Job *job, Error **errp) +{ + if (job_apply_verb_locked(job, JOB_VERB_PAUSE, errp)) { return; } if (job->user_paused) { @@ -620,15 +743,27 @@ void job_user_pause(Job *job, Error **errp) return; } job->user_paused =3D true; - job_pause(job); + job_pause_locked(job); } =20 -bool job_user_paused(Job *job) +void job_user_pause(Job *job, Error **errp) +{ + JOB_LOCK_GUARD(); + job_user_pause_locked(job, errp); +} + +bool job_user_paused_locked(Job *job) { return job->user_paused; } =20 -void job_user_resume(Job *job, Error **errp) +bool job_user_paused(Job *job) +{ + JOB_LOCK_GUARD(); + return job_user_paused_locked(job); +} + +void job_user_resume_locked(Job *job, Error **errp) { assert(job); GLOBAL_STATE_CODE(); @@ -636,66 +771,84 @@ void job_user_resume(Job *job, Error **errp) error_setg(errp, "Can't resume a job that was not paused"); return; } - if (job_apply_verb(job, JOB_VERB_RESUME, errp)) { + if (job_apply_verb_locked(job, JOB_VERB_RESUME, errp)) { return; } if (job->driver->user_resume) { + job_unlock(); job->driver->user_resume(job); + job_lock(); } job->user_paused =3D false; - job_resume(job); + job_resume_locked(job); } =20 -static void job_do_dismiss(Job *job) +void job_user_resume(Job *job, Error **errp) +{ + JOB_LOCK_GUARD(); + job_user_resume_locked(job, errp); +} + +/* Called with job_mutex held, but releases it temporarily. */ +static void job_do_dismiss_locked(Job *job) { assert(job); job->busy =3D false; job->paused =3D false; job->deferred_to_main_loop =3D true; =20 - job_txn_del_job(job); + job_txn_del_job_locked(job); =20 - job_state_transition(job, JOB_STATUS_NULL); - job_unref(job); + job_state_transition_locked(job, JOB_STATUS_NULL); + job_unref_locked(job); } =20 -void job_dismiss(Job **jobptr, Error **errp) +void job_dismiss_locked(Job **jobptr, Error **errp) { Job *job =3D *jobptr; /* similarly to _complete, this is QMP-interface only. */ assert(job->id); - if (job_apply_verb(job, JOB_VERB_DISMISS, errp)) { + if (job_apply_verb_locked(job, JOB_VERB_DISMISS, errp)) { return; } =20 - job_do_dismiss(job); + job_do_dismiss_locked(job); *jobptr =3D NULL; } =20 +void job_dismiss(Job **jobptr, Error **errp) +{ + JOB_LOCK_GUARD(); + job_dismiss_locked(jobptr, errp); +} + void job_early_fail(Job *job) { + JOB_LOCK_GUARD(); assert(job->status =3D=3D JOB_STATUS_CREATED); - job_do_dismiss(job); + job_do_dismiss_locked(job); } =20 -static void job_conclude(Job *job) +/* Called with job_mutex held. */ +static void job_conclude_locked(Job *job) { - job_state_transition(job, JOB_STATUS_CONCLUDED); - if (job->auto_dismiss || !job_started(job)) { - job_do_dismiss(job); + job_state_transition_locked(job, JOB_STATUS_CONCLUDED); + if (job->auto_dismiss || !job_started_locked(job)) { + job_do_dismiss_locked(job); } } =20 -static void job_update_rc(Job *job) +/* Called with job_mutex held. */ +static void job_update_rc_locked(Job *job) { - if (!job->ret && job_is_cancelled(job)) { + if (!job->ret && job_is_cancelled_locked(job)) { job->ret =3D -ECANCELED; } if (job->ret) { if (!job->err) { error_setg(&job->err, "%s", strerror(-job->ret)); } - job_state_transition(job, JOB_STATUS_ABORTING); + job_state_transition_locked(job, JOB_STATUS_ABORTING); } } =20 @@ -725,43 +878,57 @@ static void job_clean(Job *job) } } =20 -static int job_finalize_single(Job *job) +/* Called with job_mutex held, but releases it temporarily */ +static int job_finalize_single_locked(Job *job) { - assert(job_is_completed(job)); + int job_ret; + + assert(job_is_completed_locked(job)); =20 /* Ensure abort is called for late-transactional failures */ - job_update_rc(job); + job_update_rc_locked(job); + + job_ret =3D job->ret; + job_unlock(); =20 - if (!job->ret) { + if (!job_ret) { job_commit(job); } else { job_abort(job); } job_clean(job); =20 + job_lock(); + if (job->cb) { - job->cb(job->opaque, job->ret); + job_ret =3D job->ret; + job_unlock(); + job->cb(job->opaque, job_ret); + job_lock(); } =20 /* Emit events only if we actually started */ - if (job_started(job)) { - if (job_is_cancelled(job)) { - job_event_cancelled(job); + if (job_started_locked(job)) { + if (job_is_cancelled_locked(job)) { + job_event_cancelled_locked(job); } else { - job_event_completed(job); + job_event_completed_locked(job); } } =20 - job_txn_del_job(job); - job_conclude(job); + job_txn_del_job_locked(job); + job_conclude_locked(job); return 0; } =20 -static void job_cancel_async(Job *job, bool force) +/* Called with job_mutex held, but releases it temporarily */ +static void job_cancel_async_locked(Job *job, bool force) { GLOBAL_STATE_CODE(); if (job->driver->cancel) { + job_unlock(); force =3D job->driver->cancel(job, force); + job_lock(); } else { /* No .cancel() means the job will behave as if force-cancelled */ force =3D true; @@ -770,7 +937,9 @@ static void job_cancel_async(Job *job, bool force) if (job->user_paused) { /* Do not call job_enter here, the caller will handle it. */ if (job->driver->user_resume) { + job_unlock(); job->driver->user_resume(job); + job_lock(); } job->user_paused =3D false; assert(job->pause_count > 0); @@ -791,7 +960,8 @@ static void job_cancel_async(Job *job, bool force) } } =20 -static void job_completed_txn_abort(Job *job) +/* Called with job_mutex held, but releases it temporarily. */ +static void job_completed_txn_abort_locked(Job *job) { AioContext *ctx; JobTxn *txn =3D job->txn; @@ -804,7 +974,7 @@ static void job_completed_txn_abort(Job *job) return; } txn->aborting =3D true; - job_txn_ref(txn); + job_txn_ref_locked(txn); =20 /* * We can only hold the single job's AioContext lock while calling @@ -812,7 +982,7 @@ static void job_completed_txn_abort(Job *job) * calls of AIO_WAIT_WHILE(), which could deadlock otherwise. * Note that the job's AioContext may change when it is finalized. */ - job_ref(job); + job_ref_locked(job); aio_context_release(job->aio_context); =20 /* Other jobs are effectively cancelled by us, set the status for @@ -827,7 +997,7 @@ static void job_completed_txn_abort(Job *job) * Therefore, pass force=3Dtrue to terminate all other jobs as= quickly * as possible. */ - job_cancel_async(other_job, true); + job_cancel_async_locked(other_job, true); aio_context_release(ctx); } } @@ -839,11 +1009,11 @@ static void job_completed_txn_abort(Job *job) */ ctx =3D other_job->aio_context; aio_context_acquire(ctx); - if (!job_is_completed(other_job)) { - assert(job_cancel_requested(other_job)); - job_finish_sync(other_job, NULL, NULL); + if (!job_is_completed_locked(other_job)) { + assert(job_cancel_requested_locked(other_job)); + job_finish_sync_locked(other_job, NULL, NULL); } - job_finalize_single(other_job); + job_finalize_single_locked(other_job); aio_context_release(ctx); } =20 @@ -852,110 +1022,132 @@ static void job_completed_txn_abort(Job *job) * even if the job went away during job_finalize_single(). */ aio_context_acquire(job->aio_context); - job_unref(job); + job_unref_locked(job); =20 - job_txn_unref(txn); + job_txn_unref_locked(txn); } =20 -static int job_prepare(Job *job) +/* Called with job_mutex held, but releases it temporarily */ +static int job_prepare_locked(Job *job) { + int ret; + GLOBAL_STATE_CODE(); if (job->ret =3D=3D 0 && job->driver->prepare) { - job->ret =3D job->driver->prepare(job); - job_update_rc(job); + job_unlock(); + ret =3D job->driver->prepare(job); + job_lock(); + job->ret =3D ret; + job_update_rc_locked(job); } return job->ret; } =20 -static int job_needs_finalize(Job *job) +/* Called with job_mutex held */ +static int job_needs_finalize_locked(Job *job) { return !job->auto_finalize; } =20 -static void job_do_finalize(Job *job) +/* Called with job_mutex held */ +static void job_do_finalize_locked(Job *job) { int rc; assert(job && job->txn); =20 /* prepare the transaction to complete */ - rc =3D job_txn_apply(job, job_prepare); + rc =3D job_txn_apply_locked(job, job_prepare_locked); if (rc) { - job_completed_txn_abort(job); + job_completed_txn_abort_locked(job); } else { - job_txn_apply(job, job_finalize_single); + job_txn_apply_locked(job, job_finalize_single_locked); } } =20 -void job_finalize(Job *job, Error **errp) +void job_finalize_locked(Job *job, Error **errp) { assert(job && job->id); - if (job_apply_verb(job, JOB_VERB_FINALIZE, errp)) { + if (job_apply_verb_locked(job, JOB_VERB_FINALIZE, errp)) { return; } - job_do_finalize(job); + job_do_finalize_locked(job); } =20 -static int job_transition_to_pending(Job *job) +void job_finalize(Job *job, Error **errp) { - job_state_transition(job, JOB_STATUS_PENDING); + JOB_LOCK_GUARD(); + job_finalize_locked(job, errp); +} + +/* Called with job_mutex held. */ +static int job_transition_to_pending_locked(Job *job) +{ + job_state_transition_locked(job, JOB_STATUS_PENDING); if (!job->auto_finalize) { - job_event_pending(job); + job_event_pending_locked(job); } return 0; } =20 void job_transition_to_ready(Job *job) { - job_state_transition(job, JOB_STATUS_READY); - job_event_ready(job); + JOB_LOCK_GUARD(); + job_state_transition_locked(job, JOB_STATUS_READY); + job_event_ready_locked(job); } =20 -static void job_completed_txn_success(Job *job) +/* Called with job_mutex held. */ +static void job_completed_txn_success_locked(Job *job) { JobTxn *txn =3D job->txn; Job *other_job; =20 - job_state_transition(job, JOB_STATUS_WAITING); + job_state_transition_locked(job, JOB_STATUS_WAITING); =20 /* * Successful completion, see if there are other running jobs in this * txn. */ QLIST_FOREACH(other_job, &txn->jobs, txn_list) { - if (!job_is_completed(other_job)) { + if (!job_is_completed_locked(other_job)) { return; } assert(other_job->ret =3D=3D 0); } =20 - job_txn_apply(job, job_transition_to_pending); + job_txn_apply_locked(job, job_transition_to_pending_locked); =20 /* If no jobs need manual finalization, automatically do so */ - if (job_txn_apply(job, job_needs_finalize) =3D=3D 0) { - job_do_finalize(job); + if (job_txn_apply_locked(job, job_needs_finalize_locked) =3D=3D 0) { + job_do_finalize_locked(job); } } =20 -static void job_completed(Job *job) +/* Called with job_mutex held. */ +static void job_completed_locked(Job *job) { - assert(job && job->txn && !job_is_completed(job)); + assert(job && job->txn && !job_is_completed_locked(job)); =20 - job_update_rc(job); + job_update_rc_locked(job); trace_job_completed(job, job->ret); if (job->ret) { - job_completed_txn_abort(job); + job_completed_txn_abort_locked(job); } else { - job_completed_txn_success(job); + job_completed_txn_success_locked(job); } } =20 -/** Useful only as a type shim for aio_bh_schedule_oneshot. */ +/** + * Useful only as a type shim for aio_bh_schedule_oneshot. + * Called with job_mutex *not* held. + */ static void job_exit(void *opaque) { Job *job =3D (Job *)opaque; AioContext *ctx; + JOB_LOCK_GUARD(); =20 - job_ref(job); + job_ref_locked(job); aio_context_acquire(job->aio_context); =20 /* This is a lie, we're not quiescent, but still doing the completion @@ -963,9 +1155,9 @@ static void job_exit(void *opaque) * drain block nodes, and if .drained_poll still returned true, we wou= ld * deadlock. */ job->busy =3D false; - job_event_idle(job); + job_event_idle_locked(job); =20 - job_completed(job); + job_completed_locked(job); =20 /* * Note that calling job_completed can move the job to a different @@ -974,7 +1166,7 @@ static void job_exit(void *opaque) * the job underneath us. */ ctx =3D job->aio_context; - job_unref(job); + job_unref_locked(job); aio_context_release(ctx); } =20 @@ -985,37 +1177,47 @@ static void job_exit(void *opaque) static void coroutine_fn job_co_entry(void *opaque) { Job *job =3D opaque; + int ret; =20 assert(job && job->driver && job->driver->run); - assert(job->aio_context =3D=3D qemu_get_current_aio_context()); - job_pause_point(job); - job->ret =3D job->driver->run(job, &job->err); - job->deferred_to_main_loop =3D true; - job->busy =3D true; + WITH_JOB_LOCK_GUARD() { + assert(job->aio_context =3D=3D qemu_get_current_aio_context()); + job_pause_point_locked(job); + } + ret =3D job->driver->run(job, &job->err); + WITH_JOB_LOCK_GUARD() { + job->ret =3D ret; + job->deferred_to_main_loop =3D true; + job->busy =3D true; + } aio_bh_schedule_oneshot(qemu_get_aio_context(), job_exit, job); } =20 void job_start(Job *job) { - assert(job && !job_started(job) && job->paused && - job->driver && job->driver->run); - job->co =3D qemu_coroutine_create(job_co_entry, job); - job->pause_count--; - job->busy =3D true; - job->paused =3D false; - job_state_transition(job, JOB_STATUS_RUNNING); + assert(qemu_in_main_thread()); + + WITH_JOB_LOCK_GUARD() { + assert(job && !job_started_locked(job) && job->paused && + job->driver && job->driver->run); + job->co =3D qemu_coroutine_create(job_co_entry, job); + job->pause_count--; + job->busy =3D true; + job->paused =3D false; + job_state_transition_locked(job, JOB_STATUS_RUNNING); + } aio_co_enter(job->aio_context, job->co); } =20 -void job_cancel(Job *job, bool force) +void job_cancel_locked(Job *job, bool force) { if (job->status =3D=3D JOB_STATUS_CONCLUDED) { - job_do_dismiss(job); + job_do_dismiss_locked(job); return; } - job_cancel_async(job, force); - if (!job_started(job)) { - job_completed(job); + job_cancel_async_locked(job, force); + if (!job_started_locked(job)) { + job_completed_locked(job); } else if (job->deferred_to_main_loop) { /* * job_cancel_async() ignores soft-cancel requests for jobs @@ -1027,102 +1229,150 @@ void job_cancel(Job *job, bool force) * choose to call job_is_cancelled() to show that we invoke * job_completed_txn_abort() only for force-cancelled jobs.) */ - if (job_is_cancelled(job)) { - job_completed_txn_abort(job); + if (job_is_cancelled_locked(job)) { + job_completed_txn_abort_locked(job); } } else { - job_enter(job); + job_enter_cond_locked(job, NULL); } } =20 -void job_user_cancel(Job *job, bool force, Error **errp) +void job_cancel(Job *job, bool force) { - if (job_apply_verb(job, JOB_VERB_CANCEL, errp)) { + JOB_LOCK_GUARD(); + job_cancel_locked(job, force); +} + +void job_user_cancel_locked(Job *job, bool force, Error **errp) +{ + if (job_apply_verb_locked(job, JOB_VERB_CANCEL, errp)) { return; } - job_cancel(job, force); + job_cancel_locked(job, force); +} + +void job_user_cancel(Job *job, bool force, Error **errp) +{ + JOB_LOCK_GUARD(); + job_user_cancel_locked(job, force, errp); } =20 /* A wrapper around job_cancel() taking an Error ** parameter so it may be * used with job_finish_sync() without the need for (rather nasty) function - * pointer casts there. */ -static void job_cancel_err(Job *job, Error **errp) + * pointer casts there. + * + * Called with job_mutex held. + */ +static void job_cancel_err_locked(Job *job, Error **errp) { - job_cancel(job, false); + job_cancel_locked(job, false); } =20 /** * Same as job_cancel_err(), but force-cancel. + * Called with job_mutex held. */ -static void job_force_cancel_err(Job *job, Error **errp) +static void job_force_cancel_err_locked(Job *job, Error **errp) { - job_cancel(job, true); + job_cancel_locked(job, true); } =20 -int job_cancel_sync(Job *job, bool force) +int job_cancel_sync_locked(Job *job, bool force) { if (force) { - return job_finish_sync(job, &job_force_cancel_err, NULL); + return job_finish_sync_locked(job, &job_force_cancel_err_locked, N= ULL); } else { - return job_finish_sync(job, &job_cancel_err, NULL); + return job_finish_sync_locked(job, &job_cancel_err_locked, NULL); } } =20 +int job_cancel_sync(Job *job, bool force) +{ + JOB_LOCK_GUARD(); + return job_cancel_sync_locked(job, force); +} + void job_cancel_sync_all(void) { Job *job; AioContext *aio_context; + JOB_LOCK_GUARD(); =20 - while ((job =3D job_next(NULL))) { + while ((job =3D job_next_locked(NULL))) { aio_context =3D job->aio_context; aio_context_acquire(aio_context); - job_cancel_sync(job, true); + job_cancel_sync_locked(job, true); aio_context_release(aio_context); } } =20 +int job_complete_sync_locked(Job *job, Error **errp) +{ + return job_finish_sync_locked(job, job_complete_locked, errp); +} + int job_complete_sync(Job *job, Error **errp) { - return job_finish_sync(job, job_complete, errp); + JOB_LOCK_GUARD(); + return job_complete_sync_locked(job, errp); } =20 -void job_complete(Job *job, Error **errp) +void job_complete_locked(Job *job, Error **errp) { /* Should not be reachable via external interface for internal jobs */ assert(job->id); GLOBAL_STATE_CODE(); - if (job_apply_verb(job, JOB_VERB_COMPLETE, errp)) { + if (job_apply_verb_locked(job, JOB_VERB_COMPLETE, errp)) { return; } - if (job_cancel_requested(job) || !job->driver->complete) { + if (job_cancel_requested_locked(job) || !job->driver->complete) { error_setg(errp, "The active block job '%s' cannot be completed", job->id); return; } =20 + job_unlock(); job->driver->complete(job, errp); + job_lock(); } =20 -int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error *= *errp) +void job_complete(Job *job, Error **errp) +{ + JOB_LOCK_GUARD(); + job_complete_locked(job, errp); +} + +int job_finish_sync_locked(Job *job, + void (*finish)(Job *, Error **errp), + Error **errp) { Error *local_err =3D NULL; int ret; =20 - job_ref(job); + job_ref_locked(job); =20 if (finish) { finish(job, &local_err); } if (local_err) { error_propagate(errp, local_err); - job_unref(job); + job_unref_locked(job); return -EBUSY; } =20 + job_unlock(); AIO_WAIT_WHILE(job->aio_context, (job_enter(job), !job_is_completed(job))); + job_lock(); =20 - ret =3D (job_is_cancelled(job) && job->ret =3D=3D 0) ? -ECANCELED : jo= b->ret; - job_unref(job); + ret =3D (job_is_cancelled_locked(job) && job->ret =3D=3D 0) + ? -ECANCELED : job->ret; + job_unref_locked(job); return ret; } + +int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error *= *errp) +{ + JOB_LOCK_GUARD(); + return job_finish_sync_locked(job, finish, errp); +} --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665144407; cv=none; d=zohomail.com; s=zohoarc; b=AX3fy8F0MuIyB61R4PEeiWZ6lCYIhefz3jdOpHpXZXPZbHArDxwwBgIQsgL8rmIbg8BRFfdZEmFGFt2k1Jq8ljsE18/4gCtRVbRlvEsmrlhihPqyBzksYlGsBtnUW0r41mkuga6kDMSF/VMG/3Fi//SMR/jCIhjsDYLbcO8/mmc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665144407; 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=Iin/KtuBJO2fKqM9yRN6RS7gOWlB2A2sIDrWi2Xrrjo=; b=XGFxwLJoyERaIQ0BF+cbFVzHtBkLLKEKEripQXGuhb83o8iERu3KYXtV5mbqC6DDODViUdvgsdLbNfmRBfF9Zk2JgTys0OluVdokd3cxLSJXS7GYYxixJGEy3720xoPtPRcvMSONPcerVptcADe4gCzh0n63FMJ2BsQ+McC+BE0= 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 1665144407393526.6408658549361; Fri, 7 Oct 2022 05:06:47 -0700 (PDT) Received: from localhost ([::1]:54974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogm7o-0000Rd-HU for importer@patchew.org; Fri, 07 Oct 2022 08:06:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54222) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0005pw-PE for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:37574) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuE-0003G7-G9 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -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-537-N4gDAsimNf2R5TUhMqBEeg-1; Fri, 07 Oct 2022 06:48:34 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 61951877CA0; Fri, 7 Oct 2022 10:48:34 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7EBA12024CBB; Fri, 7 Oct 2022 10:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139717; 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=Iin/KtuBJO2fKqM9yRN6RS7gOWlB2A2sIDrWi2Xrrjo=; b=KdagxEmdoHuyX06jkIiYn3SZrK8YrFnM2BmXBp9WNsL+1GN2nmHegGTE0wSZ6s3Md3vggB v55g8ne4MIQBOa3JNQDUAozviy363L0ktkI4qYMb0ITYIQW4QFtvGja3j5b5VsR2Rb/7qK 9vcVxtd2kr9rtmutOZKvVVhS5a9LPrY= X-MC-Unique: N4gDAsimNf2R5TUhMqBEeg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 34/50] job: move and update comments from blockjob.c Date: Fri, 7 Oct 2022 12:47:36 +0200 Message-Id: <20221007104752.141361-35-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665144407690100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This comment applies more on job, it was left in blockjob as in the past the whole job logic was implemented there. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. No functional change intended. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Message-Id: <20220926093214.506243-7-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- blockjob.c | 20 -------------------- job.c | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/blockjob.c b/blockjob.c index 4868453d74..7da59a1f1c 100644 --- a/blockjob.c +++ b/blockjob.c @@ -36,21 +36,6 @@ #include "qemu/main-loop.h" #include "qemu/timer.h" =20 -/* - * The block job API is composed of two categories of functions. - * - * The first includes functions used by the monitor. The monitor is - * peculiar in that it accesses the block job list with block_job_get, and - * therefore needs consistency across block_job_get and the actual operati= on - * (e.g. block_job_set_speed). The consistency is achieved with - * aio_context_acquire/release. These functions are declared in blockjob.= h. - * - * The second includes functions used by the block job drivers and sometim= es - * by the core block layer. These do not care about locking, because the - * whole coroutine runs under the AioContext lock, and are declared in - * blockjob_int.h. - */ - static bool is_block_job(Job *job) { return job_type(job) =3D=3D JOB_TYPE_BACKUP || @@ -433,11 +418,6 @@ static void block_job_event_ready(Notifier *n, void *o= paque) } =20 =20 -/* - * API for block job drivers and the block layer. These functions are - * declared in blockjob_int.h. - */ - void *block_job_create(const char *job_id, const BlockJobDriver *driver, JobTxn *txn, BlockDriverState *bs, uint64_t perm, uint64_t shared_perm, int64_t speed, int flags, diff --git a/job.c b/job.c index 87564979cb..926e385ac2 100644 --- a/job.c +++ b/job.c @@ -32,6 +32,22 @@ #include "trace/trace-root.h" #include "qapi/qapi-events-job.h" =20 +/* + * The job API is composed of two categories of functions. + * + * The first includes functions used by the monitor. The monitor is + * peculiar in that it accesses the job list with job_get, and + * therefore needs consistency across job_get and the actual operation + * (e.g. job_user_cancel). To achieve this consistency, the caller + * calls job_lock/job_unlock itself around the whole operation. + * + * + * The second includes functions used by the job drivers and sometimes + * by the core block layer. These delegate the locking to the callee inste= ad. + * + * TODO Actually make this true + */ + /* * job_mutex protects the jobs list, but also makes the * struct job fields thread-safe. --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665143797; cv=none; d=zohomail.com; s=zohoarc; b=A7qNOhqQm9ap6hC8623UBTLwKxJd/JkQhmh4+2xTPBEUTjIUC3JXi4tNDEe2OL+E1XTsbAb2kkiNl/p/rBxpkzCZWe715E8Kg80/fqpxDdbAiNzPHLUWdM+sKkvYfG8RjIAktePDBIjL5QFJZY7lTCyMuQhSha8JvCojHCZsmHM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143797; 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=efVycWThdQ0UYqUmznlpdEAoqAnDvWY6bNbCBuW9B1s=; b=Ru8AL+8CC4Yo4huevyM+W2a/SBfoogWox7Dwumo04WSy8lQpZAcLvDDQU3YTNrE4C1whIQIELT6ZP9s0QAgwXTQsOM3r69YUY8SUerEnkbmWdjmOTOY9/o6kKqJVxXXcojPdwQ6vpLVlXezHqCVUIFhD7EeuW926rRRZe6UKiVk= 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 1665143797911182.92988068304942; Fri, 7 Oct 2022 04:56:37 -0700 (PDT) Received: from localhost ([::1]:41208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglxu-0001c6-At for importer@patchew.org; Fri, 07 Oct 2022 07:56:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54218) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0005pJ-JP for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:42218) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuF-0003GV-GN for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-653-CFygWq0DNZOnh0z_IiWmjA-1; Fri, 07 Oct 2022 06:48:35 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5AAF23826243; Fri, 7 Oct 2022 10:48:35 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99D552028DC1; Fri, 7 Oct 2022 10:48:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139718; 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=efVycWThdQ0UYqUmznlpdEAoqAnDvWY6bNbCBuW9B1s=; b=AVWT1/zJGbeiK/nySeEluWdfy+JhDoYWp7MSh3bx6GXVruos3nVXG4nes/ObxbzKecRQ/W 5CgD6bjo0zO+hPt8wzMsFvfz65eZ9RzbFEpXtjnxx8kKzZzl3sFhP+/y7m3GDcqr/Qj/Bi +Hbpii60rwhkowp8tlTQIOlXsP+qp3g= X-MC-Unique: CFygWq0DNZOnh0z_IiWmjA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 35/50] blockjob: introduce block_job _locked() APIs Date: Fri, 7 Oct 2022 12:47:37 +0200 Message-Id: <20221007104752.141361-36-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143799242100004 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Just as done with job.h, create _locked() functions in blockjob.h These functions will be later useful when caller has already taken the lock. All blockjob _locked functions call job _locked functions. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi Message-Id: <20220926093214.506243-8-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/block/blockjob.h | 18 ++++++++++++++ blockjob.c | 52 ++++++++++++++++++++++++++++++++-------- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 6525e16fd5..8b65d3949d 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -92,6 +92,9 @@ typedef struct BlockJob { */ BlockJob *block_job_next(BlockJob *job); =20 +/* Same as block_job_next(), but called with job lock held. */ +BlockJob *block_job_next_locked(BlockJob *job); + /** * block_job_get: * @id: The id of the block job. @@ -102,6 +105,9 @@ BlockJob *block_job_next(BlockJob *job); */ BlockJob *block_job_get(const char *id); =20 +/* Same as block_job_get(), but called with job lock held. */ +BlockJob *block_job_get_locked(const char *id); + /** * block_job_add_bdrv: * @job: A block job @@ -145,6 +151,12 @@ bool block_job_has_bdrv(BlockJob *job, BlockDriverStat= e *bs); */ bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); =20 +/* + * Same as block_job_set_speed(), but called with job lock held. + * Might release the lock temporarily. + */ +bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp= ); + /** * block_job_query: * @job: The job to get information about. @@ -153,6 +165,9 @@ bool block_job_set_speed(BlockJob *job, int64_t speed, = Error **errp); */ BlockJobInfo *block_job_query(BlockJob *job, Error **errp); =20 +/* Same as block_job_query(), but called with job lock held. */ +BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp); + /** * block_job_iostatus_reset: * @job: The job whose I/O status should be reset. @@ -162,6 +177,9 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **er= rp); */ void block_job_iostatus_reset(BlockJob *job); =20 +/* Same as block_job_iostatus_reset(), but called with job lock held. */ +void block_job_iostatus_reset_locked(BlockJob *job); + /* * block_job_get_aio_context: * diff --git a/blockjob.c b/blockjob.c index 7da59a1f1c..0d59aba439 100644 --- a/blockjob.c +++ b/blockjob.c @@ -44,21 +44,27 @@ static bool is_block_job(Job *job) job_type(job) =3D=3D JOB_TYPE_STREAM; } =20 -BlockJob *block_job_next(BlockJob *bjob) +BlockJob *block_job_next_locked(BlockJob *bjob) { Job *job =3D bjob ? &bjob->job : NULL; GLOBAL_STATE_CODE(); =20 do { - job =3D job_next(job); + job =3D job_next_locked(job); } while (job && !is_block_job(job)); =20 return job ? container_of(job, BlockJob, job) : NULL; } =20 -BlockJob *block_job_get(const char *id) +BlockJob *block_job_next(BlockJob *bjob) { - Job *job =3D job_get(id); + JOB_LOCK_GUARD(); + return block_job_next_locked(bjob); +} + +BlockJob *block_job_get_locked(const char *id) +{ + Job *job =3D job_get_locked(id); GLOBAL_STATE_CODE(); =20 if (job && is_block_job(job)) { @@ -68,6 +74,12 @@ BlockJob *block_job_get(const char *id) } } =20 +BlockJob *block_job_get(const char *id) +{ + JOB_LOCK_GUARD(); + return block_job_get_locked(id); +} + void block_job_free(Job *job) { BlockJob *bjob =3D container_of(job, BlockJob, job); @@ -256,14 +268,14 @@ static bool job_timer_pending(Job *job) return timer_pending(&job->sleep_timer); } =20 -bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp) { const BlockJobDriver *drv =3D block_job_driver(job); int64_t old_speed =3D job->speed; =20 GLOBAL_STATE_CODE(); =20 - if (job_apply_verb(&job->job, JOB_VERB_SET_SPEED, errp) < 0) { + if (job_apply_verb_locked(&job->job, JOB_VERB_SET_SPEED, errp) < 0) { return false; } if (speed < 0) { @@ -277,7 +289,9 @@ bool block_job_set_speed(BlockJob *job, int64_t speed, = Error **errp) job->speed =3D speed; =20 if (drv->set_speed) { + job_unlock(); drv->set_speed(job, speed); + job_lock(); } =20 if (speed && speed <=3D old_speed) { @@ -285,18 +299,24 @@ bool block_job_set_speed(BlockJob *job, int64_t speed= , Error **errp) } =20 /* kick only if a timer is pending */ - job_enter_cond(&job->job, job_timer_pending); + job_enter_cond_locked(&job->job, job_timer_pending); =20 return true; } =20 +bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +{ + JOB_LOCK_GUARD(); + return block_job_set_speed_locked(job, speed, errp); +} + int64_t block_job_ratelimit_get_delay(BlockJob *job, uint64_t n) { IO_CODE(); return ratelimit_calculate_delay(&job->limit, n); } =20 -BlockJobInfo *block_job_query(BlockJob *job, Error **errp) +BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp) { BlockJobInfo *info; uint64_t progress_current, progress_total; @@ -320,7 +340,7 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **er= rp) info->len =3D progress_total; info->speed =3D job->speed; info->io_status =3D job->iostatus; - info->ready =3D job_is_ready(&job->job), + info->ready =3D job_is_ready_locked(&job->job), info->status =3D job->job.status; info->auto_finalize =3D job->job.auto_finalize; info->auto_dismiss =3D job->job.auto_dismiss; @@ -333,6 +353,12 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **e= rrp) return info; } =20 +BlockJobInfo *block_job_query(BlockJob *job, Error **errp) +{ + JOB_LOCK_GUARD(); + return block_job_query_locked(job, errp); +} + static void block_job_iostatus_set_err(BlockJob *job, int error) { if (job->iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { @@ -478,7 +504,7 @@ fail: return NULL; } =20 -void block_job_iostatus_reset(BlockJob *job) +void block_job_iostatus_reset_locked(BlockJob *job) { GLOBAL_STATE_CODE(); if (job->iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { @@ -488,6 +514,12 @@ void block_job_iostatus_reset(BlockJob *job) job->iostatus =3D BLOCK_DEVICE_IO_STATUS_OK; } =20 +void block_job_iostatus_reset(BlockJob *job) +{ + JOB_LOCK_GUARD(); + block_job_iostatus_reset_locked(job); +} + void block_job_user_resume(Job *job) { BlockJob *bjob =3D container_of(job, BlockJob, job); --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665142421; cv=none; d=zohomail.com; s=zohoarc; b=AtEt8EMELtUJ/qpKsJpKaI7U09okhD77YGTjwmWC8adrnsEceNyC5qVRN1NWFDF0UoChU6SYMRXA1gn0i6tuB3fvMTfOHifKX/ecL83c5dPA334Eltwqs6eH6+RWiJ+tx+8bwBtC3KwouNp2OfV9dmZL7nYy0htj4Vi2VJAt+5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665142421; 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=p/+v3H6aSx0QXLvioRW8RWOD3PtTXuSNfQdTQyBTUco=; b=itElrFhckDwjIamQSRQcv3rtelo0yLagXLKwmsVSHSkgI0A6abqhpcbELAtwAu4tGmUV3CtLYmI2/BC0Gr66amBEQDs2rZLy2Lqgnma8kpe0xzgN7XfRrnfxy9l7zGNaA0Co4ifaVirFi4WLRjIn3QJRg68TsT1kSET1UvIo+2k= 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 1665142421245469.37314016165567; Fri, 7 Oct 2022 04:33:41 -0700 (PDT) Received: from localhost ([::1]:55894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglbm-0005KC-Rr for importer@patchew.org; Fri, 07 Oct 2022 07:33:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0005pS-MJ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49880) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuE-0003G3-8b for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:42 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-Du2-zZZ4Na6QgqydDcrmpQ-1; Fri, 07 Oct 2022 06:48:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 55D3A382624C; Fri, 7 Oct 2022 10:48:36 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 933DB2024CBB; Fri, 7 Oct 2022 10:48:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139717; 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=p/+v3H6aSx0QXLvioRW8RWOD3PtTXuSNfQdTQyBTUco=; b=gecgdg5UK+fZBIDLvXtiBgoPXCvJWIrfqxakVa40KodPKNGLf0Gso8WMjRfeOI2aQ+kSKa 15PVqUYavZbQ94D8G4PLoTfCVn/hhL68UWebpbpzzWQb4kXPqaN2yACb9XsqHXF2DunWT5 XTNDF9SdPxNOL4UsyIwfrHXds2Inc8o= X-MC-Unique: Du2-zZZ4Na6QgqydDcrmpQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 36/50] jobs: add job lock in find_* functions Date: Fri, 7 Oct 2022 12:47:38 +0200 Message-Id: <20221007104752.141361-37-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665142421656100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Both blockdev.c and job-qmp.c have TOC/TOU conditions, because they first search for the job and then perform an action on it. Therefore, we need to do the search + action under the same job mutex critical section. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-9-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- blockdev.c | 67 +++++++++++++++++++++++++++++++++++++----------------- job-qmp.c | 57 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 86 insertions(+), 38 deletions(-) diff --git a/blockdev.c b/blockdev.c index 392d9476e6..2e941e2979 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3313,9 +3313,13 @@ out: aio_context_release(aio_context); } =20 -/* Get a block job using its ID and acquire its AioContext */ -static BlockJob *find_block_job(const char *id, AioContext **aio_context, - Error **errp) +/* + * Get a block job using its ID and acquire its AioContext. + * Called with job_mutex held. + */ +static BlockJob *find_block_job_locked(const char *id, + AioContext **aio_context, + Error **errp) { BlockJob *job; =20 @@ -3323,7 +3327,7 @@ static BlockJob *find_block_job(const char *id, AioCo= ntext **aio_context, =20 *aio_context =3D NULL; =20 - job =3D block_job_get(id); + job =3D block_job_get_locked(id); =20 if (!job) { error_set(errp, ERROR_CLASS_DEVICE_NOT_ACTIVE, @@ -3340,13 +3344,16 @@ static BlockJob *find_block_job(const char *id, Aio= Context **aio_context, void qmp_block_job_set_speed(const char *device, int64_t speed, Error **er= rp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(device, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(device, &aio_context, errp); =20 if (!job) { return; } =20 - block_job_set_speed(job, speed, errp); + block_job_set_speed_locked(job, speed, errp); aio_context_release(aio_context); } =20 @@ -3354,7 +3361,10 @@ void qmp_block_job_cancel(const char *device, bool has_force, bool force, Error **errp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(device, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(device, &aio_context, errp); =20 if (!job) { return; @@ -3364,14 +3374,14 @@ void qmp_block_job_cancel(const char *device, force =3D false; } =20 - if (job_user_paused(&job->job) && !force) { + if (job_user_paused_locked(&job->job) && !force) { error_setg(errp, "The block job for device '%s' is currently pause= d", device); goto out; } =20 trace_qmp_block_job_cancel(job); - job_user_cancel(&job->job, force, errp); + job_user_cancel_locked(&job->job, force, errp); out: aio_context_release(aio_context); } @@ -3379,57 +3389,69 @@ out: void qmp_block_job_pause(const char *device, Error **errp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(device, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(device, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_block_job_pause(job); - job_user_pause(&job->job, errp); + job_user_pause_locked(&job->job, errp); aio_context_release(aio_context); } =20 void qmp_block_job_resume(const char *device, Error **errp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(device, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(device, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_block_job_resume(job); - job_user_resume(&job->job, errp); + job_user_resume_locked(&job->job, errp); aio_context_release(aio_context); } =20 void qmp_block_job_complete(const char *device, Error **errp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(device, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(device, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_block_job_complete(job); - job_complete(&job->job, errp); + job_complete_locked(&job->job, errp); aio_context_release(aio_context); } =20 void qmp_block_job_finalize(const char *id, Error **errp) { AioContext *aio_context; - BlockJob *job =3D find_block_job(id, &aio_context, errp); + BlockJob *job; + + JOB_LOCK_GUARD(); + job =3D find_block_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_block_job_finalize(job); - job_ref(&job->job); - job_finalize(&job->job, errp); + job_ref_locked(&job->job); + job_finalize_locked(&job->job, errp); =20 /* * Job's context might have changed via job_finalize (and job_txn_apply @@ -3437,23 +3459,26 @@ void qmp_block_job_finalize(const char *id, Error *= *errp) * one. */ aio_context =3D block_job_get_aio_context(job); - job_unref(&job->job); + job_unref_locked(&job->job); aio_context_release(aio_context); } =20 void qmp_block_job_dismiss(const char *id, Error **errp) { AioContext *aio_context; - BlockJob *bjob =3D find_block_job(id, &aio_context, errp); + BlockJob *bjob; Job *job; =20 + JOB_LOCK_GUARD(); + bjob =3D find_block_job_locked(id, &aio_context, errp); + if (!bjob) { return; } =20 trace_qmp_block_job_dismiss(bjob); job =3D &bjob->job; - job_dismiss(&job, errp); + job_dismiss_locked(&job, errp); aio_context_release(aio_context); } =20 diff --git a/job-qmp.c b/job-qmp.c index 829a28aa70..b1c456482a 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -29,14 +29,19 @@ #include "qapi/error.h" #include "trace/trace-root.h" =20 -/* Get a job using its ID and acquire its AioContext */ -static Job *find_job(const char *id, AioContext **aio_context, Error **err= p) +/* + * Get a job using its ID and acquire its AioContext. + * Called with job_mutex held. + */ +static Job *find_job_locked(const char *id, + AioContext **aio_context, + Error **errp) { Job *job; =20 *aio_context =3D NULL; =20 - job =3D job_get(id); + job =3D job_get_locked(id); if (!job) { error_setg(errp, "Job not found"); return NULL; @@ -51,71 +56,86 @@ static Job *find_job(const char *id, AioContext **aio_c= ontext, Error **errp) void qmp_job_cancel(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_cancel(job); - job_user_cancel(job, true, errp); + job_user_cancel_locked(job, true, errp); aio_context_release(aio_context); } =20 void qmp_job_pause(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_pause(job); - job_user_pause(job, errp); + job_user_pause_locked(job, errp); aio_context_release(aio_context); } =20 void qmp_job_resume(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_resume(job); - job_user_resume(job, errp); + job_user_resume_locked(job, errp); aio_context_release(aio_context); } =20 void qmp_job_complete(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_complete(job); - job_complete(job, errp); + job_complete_locked(job, errp); aio_context_release(aio_context); } =20 void qmp_job_finalize(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_finalize(job); - job_ref(job); - job_finalize(job, errp); + job_ref_locked(job); + job_finalize_locked(job, errp); =20 /* * Job's context might have changed via job_finalize (and job_txn_apply @@ -123,21 +143,24 @@ void qmp_job_finalize(const char *id, Error **errp) * one. */ aio_context =3D job->aio_context; - job_unref(job); + job_unref_locked(job); aio_context_release(aio_context); } =20 void qmp_job_dismiss(const char *id, Error **errp) { AioContext *aio_context; - Job *job =3D find_job(id, &aio_context, errp); + Job *job; + + JOB_LOCK_GUARD(); + job =3D find_job_locked(id, &aio_context, errp); =20 if (!job) { return; } =20 trace_qmp_job_dismiss(job); - job_dismiss(&job, errp); + job_dismiss_locked(&job, errp); aio_context_release(aio_context); } =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665147793; cv=none; d=zohomail.com; s=zohoarc; b=Mm45Cxd3u3FKioSkA6gtdOB3fZzXxFWBoF/x4W6z1qOE0iVPjwrbGLf0s0wNF99n5r5RidX9HssfYejjK1fKDtoKsKUb9ciUzcn7puwJtApVjGf8h7189VgNc5aW9JI5v48SZQSGWaIvPdXOwB2qp9pm0fYJV6wXTDiRYTumFaE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665147793; 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=eAkyd3y16JpLDbVeF3VSq3SBIgTSm681nAiFkzs0l74=; b=loSGub9R4IGNnbXC6Ra8sfVx2KyvBiGYwMX8K8kKxtE4hZRK+KPwIHJXW0JW5I5dKRzsQDb5EXo5qo6BXZVZCYYQMB+ZeXf1MLpUrQixx4upAnGLXPWVqBDlvWKKs50Idty+ur2/TjNTHy68xaCzxQf1WYHZXxmRmfki5J5kBRg= 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 1665147793479286.6592532257881; Fri, 7 Oct 2022 06:03:13 -0700 (PDT) Received: from localhost ([::1]:37286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogn0R-0004CY-Mq for importer@patchew.org; Fri, 07 Oct 2022 09:03:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuK-0005sB-S2 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0003HB-3M for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:44 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-nUSYx6lANOO33MxOquL4iA-1; Fri, 07 Oct 2022 06:48:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 519FB29AB3E0; Fri, 7 Oct 2022 10:48:37 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9066A2028DC1; Fri, 7 Oct 2022 10:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139721; 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=eAkyd3y16JpLDbVeF3VSq3SBIgTSm681nAiFkzs0l74=; b=GwAP2f+j/0OVkHXHSEXSk/R7DHoPfDsIOVcfncv4QBhfWCb/lQjHxYy1EdGvF1TIehpQ3F jb9fPJXxDAG2anNIWuQINeoYCHAUumOb5SH5XHtF1kRr4mi5nfAfPGqGXuWJzr1KU37xVN i4n4+d+haTLOdCe8y1PPnNdl/ovqcbM= X-MC-Unique: nUSYx6lANOO33MxOquL4iA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 37/50] jobs: use job locks also in the unit tests Date: Fri, 7 Oct 2022 12:47:39 +0200 Message-Id: <20221007104752.141361-38-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665147795841100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Add missing job synchronization in the unit tests, with explicit locks. We are deliberately using _locked functions wrapped by a guard instead of a normal call because the normal call will be removed in future, as the only usage is limited to the tests. In other words, if a function like job_pause() is/will be only used in tests to avoid: WITH_JOB_LOCK_GUARD(){ job_pause_locked(); } then it is not worth keeping job_pause(), and just use the guard. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-10-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- tests/unit/test-bdrv-drain.c | 76 ++++++++++++-------- tests/unit/test-block-iothread.c | 8 ++- tests/unit/test-blockjob-txn.c | 24 ++++--- tests/unit/test-blockjob.c | 115 +++++++++++++++++++------------ 4 files changed, 140 insertions(+), 83 deletions(-) diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 36be84ae55..0db056ea63 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -943,61 +943,83 @@ static void test_blockjob_common_drain_node(enum drai= n_type drain_type, } } =20 - g_assert_cmpint(job->job.pause_count, =3D=3D, 0); - g_assert_false(job->job.paused); - g_assert_true(tjob->running); - g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + WITH_JOB_LOCK_GUARD() { + g_assert_cmpint(job->job.pause_count, =3D=3D, 0); + g_assert_false(job->job.paused); + g_assert_true(tjob->running); + g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + } =20 do_drain_begin_unlocked(drain_type, drain_bs); =20 - if (drain_type =3D=3D BDRV_DRAIN_ALL) { - /* bdrv_drain_all() drains both src and target */ - g_assert_cmpint(job->job.pause_count, =3D=3D, 2); - } else { - g_assert_cmpint(job->job.pause_count, =3D=3D, 1); + WITH_JOB_LOCK_GUARD() { + if (drain_type =3D=3D BDRV_DRAIN_ALL) { + /* bdrv_drain_all() drains both src and target */ + g_assert_cmpint(job->job.pause_count, =3D=3D, 2); + } else { + g_assert_cmpint(job->job.pause_count, =3D=3D, 1); + } + g_assert_true(job->job.paused); + g_assert_false(job->job.busy); /* The job is paused */ } - g_assert_true(job->job.paused); - g_assert_false(job->job.busy); /* The job is paused */ =20 do_drain_end_unlocked(drain_type, drain_bs); =20 if (use_iothread) { - /* paused is reset in the I/O thread, wait for it */ + /* + * Here we are waiting for the paused status to change, + * so don't bother protecting the read every time. + * + * paused is reset in the I/O thread, wait for it + */ while (job->job.paused) { aio_poll(qemu_get_aio_context(), false); } } =20 - g_assert_cmpint(job->job.pause_count, =3D=3D, 0); - g_assert_false(job->job.paused); - g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + WITH_JOB_LOCK_GUARD() { + g_assert_cmpint(job->job.pause_count, =3D=3D, 0); + g_assert_false(job->job.paused); + g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + } =20 do_drain_begin_unlocked(drain_type, target); =20 - if (drain_type =3D=3D BDRV_DRAIN_ALL) { - /* bdrv_drain_all() drains both src and target */ - g_assert_cmpint(job->job.pause_count, =3D=3D, 2); - } else { - g_assert_cmpint(job->job.pause_count, =3D=3D, 1); + WITH_JOB_LOCK_GUARD() { + if (drain_type =3D=3D BDRV_DRAIN_ALL) { + /* bdrv_drain_all() drains both src and target */ + g_assert_cmpint(job->job.pause_count, =3D=3D, 2); + } else { + g_assert_cmpint(job->job.pause_count, =3D=3D, 1); + } + g_assert_true(job->job.paused); + g_assert_false(job->job.busy); /* The job is paused */ } - g_assert_true(job->job.paused); - g_assert_false(job->job.busy); /* The job is paused */ =20 do_drain_end_unlocked(drain_type, target); =20 if (use_iothread) { - /* paused is reset in the I/O thread, wait for it */ + /* + * Here we are waiting for the paused status to change, + * so don't bother protecting the read every time. + * + * paused is reset in the I/O thread, wait for it + */ while (job->job.paused) { aio_poll(qemu_get_aio_context(), false); } } =20 - g_assert_cmpint(job->job.pause_count, =3D=3D, 0); - g_assert_false(job->job.paused); - g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + WITH_JOB_LOCK_GUARD() { + g_assert_cmpint(job->job.pause_count, =3D=3D, 0); + g_assert_false(job->job.paused); + g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ + } =20 aio_context_acquire(ctx); - ret =3D job_complete_sync(&job->job, &error_abort); + WITH_JOB_LOCK_GUARD() { + ret =3D job_complete_sync_locked(&job->job, &error_abort); + } g_assert_cmpint(ret, =3D=3D, (result =3D=3D TEST_JOB_SUCCESS ? 0 : -EI= O)); =20 if (use_iothread) { diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 8b55eccc89..96fd21c00a 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -583,7 +583,9 @@ static void test_attach_blockjob(void) } =20 aio_context_acquire(ctx); - job_complete_sync(&tjob->common.job, &error_abort); + WITH_JOB_LOCK_GUARD() { + job_complete_sync_locked(&tjob->common.job, &error_abort); + } blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); aio_context_release(ctx); =20 @@ -757,7 +759,9 @@ static void test_propagate_mirror(void) BLOCKDEV_ON_ERROR_REPORT, BLOCKDEV_ON_ERROR_REPORT, false, "filter_node", MIRROR_COPY_MODE_BACKGROUND, &error_abort); - job =3D job_get("job0"); + WITH_JOB_LOCK_GUARD() { + job =3D job_get_locked("job0"); + } filter =3D bdrv_find_node("filter_node"); =20 /* Change the AioContext of src */ diff --git a/tests/unit/test-blockjob-txn.c b/tests/unit/test-blockjob-txn.c index c69028b450..d3b0bb24be 100644 --- a/tests/unit/test-blockjob-txn.c +++ b/tests/unit/test-blockjob-txn.c @@ -116,8 +116,10 @@ static void test_single_job(int expected) job =3D test_block_job_start(1, true, expected, &result, txn); job_start(&job->job); =20 - if (expected =3D=3D -ECANCELED) { - job_cancel(&job->job, false); + WITH_JOB_LOCK_GUARD() { + if (expected =3D=3D -ECANCELED) { + job_cancel_locked(&job->job, false); + } } =20 while (result =3D=3D -EINPROGRESS) { @@ -160,13 +162,15 @@ static void test_pair_jobs(int expected1, int expecte= d2) /* Release our reference now to trigger as many nice * use-after-free bugs as possible. */ - job_txn_unref(txn); + WITH_JOB_LOCK_GUARD() { + job_txn_unref_locked(txn); =20 - if (expected1 =3D=3D -ECANCELED) { - job_cancel(&job1->job, false); - } - if (expected2 =3D=3D -ECANCELED) { - job_cancel(&job2->job, false); + if (expected1 =3D=3D -ECANCELED) { + job_cancel_locked(&job1->job, false); + } + if (expected2 =3D=3D -ECANCELED) { + job_cancel_locked(&job2->job, false); + } } =20 while (result1 =3D=3D -EINPROGRESS || result2 =3D=3D -EINPROGRESS) { @@ -219,7 +223,9 @@ static void test_pair_jobs_fail_cancel_race(void) job_start(&job1->job); job_start(&job2->job); =20 - job_cancel(&job1->job, false); + WITH_JOB_LOCK_GUARD() { + job_cancel_locked(&job1->job, false); + } =20 /* Now make job2 finish before the main loop kicks jobs. This simulat= es * the race between a pending kick and another job completing. diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index 4c9e1bf1e5..e4f126bb6d 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -211,8 +211,11 @@ static CancelJob *create_common(Job **pjob) bjob =3D mk_job(blk, "Steve", &test_cancel_driver, true, JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS); job =3D &bjob->job; - job_ref(job); - assert(job->status =3D=3D JOB_STATUS_CREATED); + WITH_JOB_LOCK_GUARD() { + job_ref_locked(job); + assert(job->status =3D=3D JOB_STATUS_CREATED); + } + s =3D container_of(bjob, CancelJob, common); s->blk =3D blk; =20 @@ -231,12 +234,14 @@ static void cancel_common(CancelJob *s) aio_context_acquire(ctx); =20 job_cancel_sync(&job->job, true); - if (sts !=3D JOB_STATUS_CREATED && sts !=3D JOB_STATUS_CONCLUDED) { - Job *dummy =3D &job->job; - job_dismiss(&dummy, &error_abort); + WITH_JOB_LOCK_GUARD() { + if (sts !=3D JOB_STATUS_CREATED && sts !=3D JOB_STATUS_CONCLUDED) { + Job *dummy =3D &job->job; + job_dismiss_locked(&dummy, &error_abort); + } + assert(job->job.status =3D=3D JOB_STATUS_NULL); + job_unref_locked(&job->job); } - assert(job->job.status =3D=3D JOB_STATUS_NULL); - job_unref(&job->job); destroy_blk(blk); =20 aio_context_release(ctx); @@ -251,6 +256,13 @@ static void test_cancel_created(void) cancel_common(s); } =20 +static void assert_job_status_is(Job *job, int status) +{ + WITH_JOB_LOCK_GUARD() { + assert(job->status =3D=3D status); + } +} + static void test_cancel_running(void) { Job *job; @@ -259,7 +271,7 @@ static void test_cancel_running(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); + assert_job_status_is(job, JOB_STATUS_RUNNING); =20 cancel_common(s); } @@ -272,11 +284,12 @@ static void test_cancel_paused(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); - - job_user_pause(job, &error_abort); + WITH_JOB_LOCK_GUARD() { + assert(job->status =3D=3D JOB_STATUS_RUNNING); + job_user_pause_locked(job, &error_abort); + } job_enter(job); - assert(job->status =3D=3D JOB_STATUS_PAUSED); + assert_job_status_is(job, JOB_STATUS_PAUSED); =20 cancel_common(s); } @@ -289,11 +302,11 @@ static void test_cancel_ready(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); + assert_job_status_is(job, JOB_STATUS_RUNNING); =20 s->should_converge =3D true; job_enter(job); - assert(job->status =3D=3D JOB_STATUS_READY); + assert_job_status_is(job, JOB_STATUS_READY); =20 cancel_common(s); } @@ -306,15 +319,16 @@ static void test_cancel_standby(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); + assert_job_status_is(job, JOB_STATUS_RUNNING); =20 s->should_converge =3D true; job_enter(job); - assert(job->status =3D=3D JOB_STATUS_READY); - - job_user_pause(job, &error_abort); + WITH_JOB_LOCK_GUARD() { + assert(job->status =3D=3D JOB_STATUS_READY); + job_user_pause_locked(job, &error_abort); + } job_enter(job); - assert(job->status =3D=3D JOB_STATUS_STANDBY); + assert_job_status_is(job, JOB_STATUS_STANDBY); =20 cancel_common(s); } @@ -327,20 +341,21 @@ static void test_cancel_pending(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); + assert_job_status_is(job, JOB_STATUS_RUNNING); =20 s->should_converge =3D true; job_enter(job); - assert(job->status =3D=3D JOB_STATUS_READY); - - job_complete(job, &error_abort); + WITH_JOB_LOCK_GUARD() { + assert(job->status =3D=3D JOB_STATUS_READY); + job_complete_locked(job, &error_abort); + } job_enter(job); while (!job->deferred_to_main_loop) { aio_poll(qemu_get_aio_context(), true); } - assert(job->status =3D=3D JOB_STATUS_READY); + assert_job_status_is(job, JOB_STATUS_READY); aio_poll(qemu_get_aio_context(), true); - assert(job->status =3D=3D JOB_STATUS_PENDING); + assert_job_status_is(job, JOB_STATUS_PENDING); =20 cancel_common(s); } @@ -353,25 +368,28 @@ static void test_cancel_concluded(void) s =3D create_common(&job); =20 job_start(job); - assert(job->status =3D=3D JOB_STATUS_RUNNING); + assert_job_status_is(job, JOB_STATUS_RUNNING); =20 s->should_converge =3D true; job_enter(job); - assert(job->status =3D=3D JOB_STATUS_READY); - - job_complete(job, &error_abort); + WITH_JOB_LOCK_GUARD() { + assert(job->status =3D=3D JOB_STATUS_READY); + job_complete_locked(job, &error_abort); + } job_enter(job); while (!job->deferred_to_main_loop) { aio_poll(qemu_get_aio_context(), true); } - assert(job->status =3D=3D JOB_STATUS_READY); + assert_job_status_is(job, JOB_STATUS_READY); aio_poll(qemu_get_aio_context(), true); - assert(job->status =3D=3D JOB_STATUS_PENDING); + assert_job_status_is(job, JOB_STATUS_PENDING); =20 aio_context_acquire(job->aio_context); - job_finalize(job, &error_abort); + WITH_JOB_LOCK_GUARD() { + job_finalize_locked(job, &error_abort); + } aio_context_release(job->aio_context); - assert(job->status =3D=3D JOB_STATUS_CONCLUDED); + assert_job_status_is(job, JOB_STATUS_CONCLUDED); =20 cancel_common(s); } @@ -459,36 +477,43 @@ static void test_complete_in_standby(void) bjob =3D mk_job(blk, "job", &test_yielding_driver, true, JOB_MANUAL_FINALIZE | JOB_MANUAL_DISMISS); job =3D &bjob->job; - assert(job->status =3D=3D JOB_STATUS_CREATED); + assert_job_status_is(job, JOB_STATUS_CREATED); =20 /* Wait for the job to become READY */ job_start(job); aio_context_acquire(ctx); + /* + * Here we are waiting for the status to change, so don't bother + * protecting the read every time. + */ AIO_WAIT_WHILE(ctx, job->status !=3D JOB_STATUS_READY); aio_context_release(ctx); =20 /* Begin the drained section, pausing the job */ bdrv_drain_all_begin(); - assert(job->status =3D=3D JOB_STATUS_STANDBY); + assert_job_status_is(job, JOB_STATUS_STANDBY); + /* Lock the IO thread to prevent the job from being run */ aio_context_acquire(ctx); /* This will schedule the job to resume it */ bdrv_drain_all_end(); =20 - /* But the job cannot run, so it will remain on standby */ - assert(job->status =3D=3D JOB_STATUS_STANDBY); + WITH_JOB_LOCK_GUARD() { + /* But the job cannot run, so it will remain on standby */ + assert(job->status =3D=3D JOB_STATUS_STANDBY); =20 - /* Even though the job is on standby, this should work */ - job_complete(job, &error_abort); + /* Even though the job is on standby, this should work */ + job_complete_locked(job, &error_abort); =20 - /* The test is done now, clean up. */ - job_finish_sync(job, NULL, &error_abort); - assert(job->status =3D=3D JOB_STATUS_PENDING); + /* The test is done now, clean up. */ + job_finish_sync_locked(job, NULL, &error_abort); + assert(job->status =3D=3D JOB_STATUS_PENDING); =20 - job_finalize(job, &error_abort); - assert(job->status =3D=3D JOB_STATUS_CONCLUDED); + job_finalize_locked(job, &error_abort); + assert(job->status =3D=3D JOB_STATUS_CONCLUDED); =20 - job_dismiss(&job, &error_abort); + job_dismiss_locked(&job, &error_abort); + } =20 destroy_blk(blk); aio_context_release(ctx); --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665145763; cv=none; d=zohomail.com; s=zohoarc; b=fm5m5/cH9xQLjs1RDZ+L5NPZTm7lZSSTLgI3Ik58s8u0GqSYjlNQ9xVdWV8/XpvnR23ilC9vszEVLsgSdwRVpl/CPHmFu/60gcXgmXxqJFZ+GBOi9DQw93bgAqhjBLE3tgql9d9W8fwBxuLqQZUbkvw/GaGiQub+QJpknL954SY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145763; 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=sZIzJHueKKSWA78PMnN+y4KB31b58z/EQ+UCkBjNpwU=; b=mD9HZV3M8IIJxKJq0kdZT8VpYR/wmwIZKU64t25WJeacqxwFvjkAk6AvauRSYEYYftRhqfyBt3k9jcavIUA6zpnbQ7WavdrdUDee5fhrHQimgK2FhW99MC7nOmRmYyMsRrYC8bUAAy223QsfwgHz6psCLWQXcZpbcP7T4zijPEk= 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 16651457639591001.3111162546567; Fri, 7 Oct 2022 05:29:23 -0700 (PDT) Received: from localhost ([::1]:39620 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmTi-0005QB-UT for importer@patchew.org; Fri, 07 Oct 2022 08:29:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54236) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuL-0005sC-32 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:47835) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0003HJ-BC for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:44 -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-649-9LY7nk5xMMORamKUScGwNg-1; Fri, 07 Oct 2022 06:48:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4FEFF85A583; Fri, 7 Oct 2022 10:48:38 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8BFBF2024CBB; Fri, 7 Oct 2022 10:48:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139721; 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=sZIzJHueKKSWA78PMnN+y4KB31b58z/EQ+UCkBjNpwU=; b=H2LOcd5c3GDAAeoC28UuYSxqkM8jmrFsbhz/3K1WPOahEvKbhITnDNbEYK9TgN06tUxAmK 5QewV/wVYrLVcnED7G1eUXx1CY32+693CcFfjlVUMSiQS3XGdyKCRJVD4phIb/BczRxHaB Ly281AB4nzuijLdfCXjOhNxafDbW4MM= X-MC-Unique: 9LY7nk5xMMORamKUScGwNg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 38/50] block/mirror.c: use of job helpers in drivers Date: Fri, 7 Oct 2022 12:47:40 +0200 Message-Id: <20221007104752.141361-39-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145766146100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Once job lock is used and aiocontext is removed, mirror has to perform job operations under the same critical section, Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-11-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block/mirror.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 3c4ab1159d..c6bf7f40ce 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1152,8 +1152,10 @@ static void mirror_complete(Job *job, Error **errp) s->should_complete =3D true; =20 /* If the job is paused, it will be re-entered when it is resumed */ - if (!job->paused) { - job_enter(job); + WITH_JOB_LOCK_GUARD() { + if (!job->paused) { + job_enter_cond_locked(job, NULL); + } } } =20 @@ -1173,8 +1175,11 @@ static bool mirror_drained_poll(BlockJob *job) * from one of our own drain sections, to avoid a deadlock waiting for * ourselves. */ - if (!s->common.job.paused && !job_is_cancelled(&job->job) && !s->in_dr= ain) { - return true; + WITH_JOB_LOCK_GUARD() { + if (!s->common.job.paused && !job_is_cancelled_locked(&job->job) + && !s->in_drain) { + return true; + } } =20 return !!s->in_flight; --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665144055; cv=none; d=zohomail.com; s=zohoarc; b=dVVLcHSZhTP0ZaHiwr41hFY8flZh7fSxUm+JgsvgZYYOx13lNdG3ahy95B0gEBJxc0IbkST0iO3jqBEVFWNQCwhFXRxTSQW/yWm2zc6pSbf03pJgAEIg7L69wizSRqwxF0zlTAQ0KGMkBFbRCI3VRUrWiIGK+MDlds1i+MiUPwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665144055; 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=ua0jko/6n4cZlaBamjrAI8+x0sWv7ho1aBCyiAgf6Sc=; b=J82pSbsSoncMO6PiE21FAsIs99zd3Dl8D7maAXGTV1zhkISWUqWOhGORni/coWqK4tKZi7rzzNtK2B9uNkAv4Ik+txyB1RpsKNnWS1tOXZHYDuTDI8p9ZDu0Pnb1BSCvOy+UWRnMx4mbXrqFwej+EYzkKC4NDIj+KDnc7ALra2k= 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 1665144055207751.8060907958543; Fri, 7 Oct 2022 05:00:55 -0700 (PDT) Received: from localhost ([::1]:45650 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogm29-0004kl-7c for importer@patchew.org; Fri, 07 Oct 2022 08:00:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuM-0005u9-0I for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:46 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:46611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuJ-0003I5-Bo for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:45 -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-597-CLhz4oDRMHasQazBoJk_cQ-1; Fri, 07 Oct 2022 06:48:39 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4D151185A78B; Fri, 7 Oct 2022 10:48:39 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B6FC2028DC1; Fri, 7 Oct 2022 10:48:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139722; 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=ua0jko/6n4cZlaBamjrAI8+x0sWv7ho1aBCyiAgf6Sc=; b=D07+yUqsCiCko+xCx5lm+JttPlU8+3INqh1p8+w4OGC6AbDESkKl1biV7olfh26UH3hQ2t IxQkYjuQT0i/tyg18cTK5JWav8R5vowV0YgBtlAL+VRGApqG06cC+Jh6waqOfwuQyz7zVn K4web59OkDgI074hoSv0GBh0DYCn0DQ= X-MC-Unique: CLhz4oDRMHasQazBoJk_cQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 39/50] jobs: group together API calls under the same job lock Date: Fri, 7 Oct 2022 12:47:41 +0200 Message-Id: <20221007104752.141361-40-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665144057011100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Now that the API offers also _locked() functions, take advantage of it and give also the caller control to take the lock and call _locked functions. This makes sense especially when we have for loops, because it makes no sense to have: for(job =3D job_next(); ...) where each job_next() takes the lock internally. Instead we want JOB_LOCK_GUARD(); for(job =3D job_next_locked(); ...) In addition, protect also direct field accesses, by either creating a new critical section or widening the existing ones. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-12-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- block.c | 17 ++++++++++------- blockdev.c | 14 ++++++++++---- blockjob.c | 35 ++++++++++++++++++++++------------- job-qmp.c | 9 ++++++--- monitor/qmp-cmds.c | 7 +++++-- qemu-img.c | 15 ++++++++++----- 6 files changed, 63 insertions(+), 34 deletions(-) diff --git a/block.c b/block.c index 9b0fae5c1e..1fbf6b9e69 100644 --- a/block.c +++ b/block.c @@ -4981,8 +4981,8 @@ static void bdrv_close(BlockDriverState *bs) =20 void bdrv_close_all(void) { - assert(job_next(NULL) =3D=3D NULL); GLOBAL_STATE_CODE(); + assert(job_next(NULL) =3D=3D NULL); =20 /* Drop references from requests still in flight, such as canceled blo= ck * jobs whose AIO context has not been polled yet */ @@ -6168,13 +6168,16 @@ XDbgBlockGraph *bdrv_get_xdbg_block_graph(Error **e= rrp) } } =20 - for (job =3D block_job_next(NULL); job; job =3D block_job_next(job)) { - GSList *el; + WITH_JOB_LOCK_GUARD() { + for (job =3D block_job_next_locked(NULL); job; + job =3D block_job_next_locked(job)) { + GSList *el; =20 - xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK_JOB, - job->job.id); - for (el =3D job->nodes; el; el =3D el->next) { - xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); + xdbg_graph_add_node(gr, job, X_DBG_BLOCK_GRAPH_NODE_TYPE_BLOCK= _JOB, + job->job.id); + for (el =3D job->nodes; el; el =3D el->next) { + xdbg_graph_add_edge(gr, job, (BdrvChild *)el->data); + } } } =20 diff --git a/blockdev.c b/blockdev.c index 2e941e2979..46090bb0aa 100644 --- a/blockdev.c +++ b/blockdev.c @@ -150,12 +150,15 @@ void blockdev_mark_auto_del(BlockBackend *blk) return; } =20 - for (job =3D block_job_next(NULL); job; job =3D block_job_next(job)) { + JOB_LOCK_GUARD(); + + for (job =3D block_job_next_locked(NULL); job; + job =3D block_job_next_locked(job)) { if (block_job_has_bdrv(job, blk_bs(blk))) { AioContext *aio_context =3D job->job.aio_context; aio_context_acquire(aio_context); =20 - job_cancel(&job->job, false); + job_cancel_locked(&job->job, false); =20 aio_context_release(aio_context); } @@ -3756,7 +3759,10 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) BlockJobInfoList *head =3D NULL, **tail =3D &head; BlockJob *job; =20 - for (job =3D block_job_next(NULL); job; job =3D block_job_next(job)) { + JOB_LOCK_GUARD(); + + for (job =3D block_job_next_locked(NULL); job; + job =3D block_job_next_locked(job)) { BlockJobInfo *value; AioContext *aio_context; =20 @@ -3765,7 +3771,7 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) } aio_context =3D block_job_get_aio_context(job); aio_context_acquire(aio_context); - value =3D block_job_query(job, errp); + value =3D block_job_query_locked(job, errp); aio_context_release(aio_context); if (!value) { qapi_free_BlockJobInfoList(head); diff --git a/blockjob.c b/blockjob.c index 0d59aba439..96fb9d9f73 100644 --- a/blockjob.c +++ b/blockjob.c @@ -111,8 +111,10 @@ static bool child_job_drained_poll(BdrvChild *c) /* An inactive or completed job doesn't have any pending requests. Jobs * with !job->busy are either already paused or have a pause point aft= er * being reentered, so no job driver code will run before they pause. = */ - if (!job->busy || job_is_completed(job)) { - return false; + WITH_JOB_LOCK_GUARD() { + if (!job->busy || job_is_completed_locked(job)) { + return false; + } } =20 /* Otherwise, assume that it isn't fully stopped yet, but allow the jo= b to @@ -475,13 +477,15 @@ void *block_job_create(const char *job_id, const Bloc= kJobDriver *driver, job->ready_notifier.notify =3D block_job_event_ready; job->idle_notifier.notify =3D block_job_on_idle; =20 - notifier_list_add(&job->job.on_finalize_cancelled, - &job->finalize_cancelled_notifier); - notifier_list_add(&job->job.on_finalize_completed, - &job->finalize_completed_notifier); - notifier_list_add(&job->job.on_pending, &job->pending_notifier); - notifier_list_add(&job->job.on_ready, &job->ready_notifier); - notifier_list_add(&job->job.on_idle, &job->idle_notifier); + WITH_JOB_LOCK_GUARD() { + notifier_list_add(&job->job.on_finalize_cancelled, + &job->finalize_cancelled_notifier); + notifier_list_add(&job->job.on_finalize_completed, + &job->finalize_completed_notifier); + notifier_list_add(&job->job.on_pending, &job->pending_notifier); + notifier_list_add(&job->job.on_ready, &job->ready_notifier); + notifier_list_add(&job->job.on_idle, &job->idle_notifier); + } =20 error_setg(&job->blocker, "block device is in use by block job: %s", job_type_str(&job->job)); @@ -558,10 +562,15 @@ BlockErrorAction block_job_error_action(BlockJob *job= , BlockdevOnError on_err, action); } if (action =3D=3D BLOCK_ERROR_ACTION_STOP) { - if (!job->job.user_paused) { - job_pause(&job->job); - /* make the pause user visible, which will be resumed from QMP= . */ - job->job.user_paused =3D true; + WITH_JOB_LOCK_GUARD() { + if (!job->job.user_paused) { + job_pause_locked(&job->job); + /* + * make the pause user visible, which will be + * resumed from QMP. + */ + job->job.user_paused =3D true; + } } block_job_iostatus_set_err(job, error); } diff --git a/job-qmp.c b/job-qmp.c index b1c456482a..393d3a5b81 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -164,7 +164,8 @@ void qmp_job_dismiss(const char *id, Error **errp) aio_context_release(aio_context); } =20 -static JobInfo *job_query_single(Job *job, Error **errp) +/* Called with job_mutex held. */ +static JobInfo *job_query_single_locked(Job *job, Error **errp) { JobInfo *info; uint64_t progress_current; @@ -194,7 +195,9 @@ JobInfoList *qmp_query_jobs(Error **errp) JobInfoList *head =3D NULL, **tail =3D &head; Job *job; =20 - for (job =3D job_next(NULL); job; job =3D job_next(job)) { + JOB_LOCK_GUARD(); + + for (job =3D job_next_locked(NULL); job; job =3D job_next_locked(job))= { JobInfo *value; AioContext *aio_context; =20 @@ -203,7 +206,7 @@ JobInfoList *qmp_query_jobs(Error **errp) } aio_context =3D job->aio_context; aio_context_acquire(aio_context); - value =3D job_query_single(job, errp); + value =3D job_query_single_locked(job, errp); aio_context_release(aio_context); if (!value) { qapi_free_JobInfoList(head); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 7314cd813d..81c8fdadf8 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -135,8 +135,11 @@ void qmp_cont(Error **errp) blk_iostatus_reset(blk); } =20 - for (job =3D block_job_next(NULL); job; job =3D block_job_next(job)) { - block_job_iostatus_reset(job); + WITH_JOB_LOCK_GUARD() { + for (job =3D block_job_next_locked(NULL); job; + job =3D block_job_next_locked(job)) { + block_job_iostatus_reset_locked(job); + } } =20 /* Continuing after completed migration. Images have been inactivated = to diff --git a/qemu-img.c b/qemu-img.c index cab9776f42..e0a30b1f4c 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -912,9 +912,11 @@ static void run_block_job(BlockJob *job, Error **errp) int ret =3D 0; =20 aio_context_acquire(aio_context); - job_ref(&job->job); + job_lock(); + job_ref_locked(&job->job); do { float progress =3D 0.0f; + job_unlock(); aio_poll(aio_context, true); =20 progress_get_snapshot(&job->job.progress, &progress_current, @@ -923,14 +925,17 @@ static void run_block_job(BlockJob *job, Error **errp) progress =3D (float)progress_current / progress_total * 100.f; } qemu_progress_print(progress, 0); - } while (!job_is_ready(&job->job) && !job_is_completed(&job->job)); + job_lock(); + } while (!job_is_ready_locked(&job->job) && + !job_is_completed_locked(&job->job)); =20 - if (!job_is_completed(&job->job)) { - ret =3D job_complete_sync(&job->job, errp); + if (!job_is_completed_locked(&job->job)) { + ret =3D job_complete_sync_locked(&job->job, errp); } else { ret =3D job->job.ret; } - job_unref(&job->job); + job_unref_locked(&job->job); + job_unlock(); aio_context_release(aio_context); =20 /* publish completion progress only when success */ --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665147380; cv=none; d=zohomail.com; s=zohoarc; b=PRpVLD3mp07zrPd8VlPRYHltSeETlIYPzGd3wqKwUgAW2mYaim/hIG7/q3ZDTCfJDCZXkFTANE64F2zhXown5zydpgUtMala+mIX+6EI5aW2Zk8/dpz5795R36wlYd09BtqtCEdrDSvs0dkvVt2VcU6Oy9MfV4i79Z/6USkzMAg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665147380; 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=hRMMxrBx2XBHT5L9KCDeXOpJZ9qxcgPmbHeoZsJSG4Y=; b=V30nTFtkkEh6XzIsesyxnDxep1qpt1cpLS5gSZEg0InYpdcIRexmw6j5eFNaCy0/4e/k4O65Du4F/0+kb8Qh72aaNBbAE2Vn5ygCT6NUG15q5sggnoTfi5RLegWAGTRrq0VIh0IOvZHc0mawCrIBYVDltZl2JiMOo+BSzr7eJbY= 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 16651473808131007.6401868655795; Fri, 7 Oct 2022 05:56:20 -0700 (PDT) Received: from localhost ([::1]:54934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmtn-0007Zq-Ae for importer@patchew.org; Fri, 07 Oct 2022 08:56:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54230) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuK-0005s9-NN for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44490) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuI-0003HE-62 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:44 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-158-A54b-rbgPaiO4Sb6ahIZhw-1; Fri, 07 Oct 2022 06:48:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 45C201C07590; Fri, 7 Oct 2022 10:48:40 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8458F2024CBB; Fri, 7 Oct 2022 10:48:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139721; 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=hRMMxrBx2XBHT5L9KCDeXOpJZ9qxcgPmbHeoZsJSG4Y=; b=X3ik2Of+WQqKl2XDO4zNhPQIQL3o6jgd+xrgEz1FAQ6gASJBwVDTEUh3rjBKY5p2UvaD// uqKsdZMtOG+R/Jaexe43jqdB802Pv4jFfjW304Tefzt1UexDJSRCplqxdyfYhb+6zGqPKz zfxsLZ+EOOJwzSyXZ/IT0zyqtFg/d4s= X-MC-Unique: A54b-rbgPaiO4Sb6ahIZhw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 40/50] job: detect change of aiocontext within job coroutine Date: Fri, 7 Oct 2022 12:47:42 +0200 Message-Id: <20221007104752.141361-41-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665147382923100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini We want to make sure access of job->aio_context is always done under either BQL or job_mutex. The problem is that using aio_co_enter(job->aiocontext, job->co) in job_start and job_enter_cond makes the coroutine immediately resume, so we can't hold the job lock. And caching it is not safe either, as it might change. job_start is under BQL, so it can freely read job->aiocontext, but job_enter_cond is not. We want to avoid reading job->aio_context in job_enter_cond, therefore: 1) use aio_co_wake(), since it doesn't want an aiocontext as argument but uses job->co->ctx 2) detect possible discrepancy between job->co->ctx and job->aio_context by checking right after the coroutine resumes back from yielding if job->aio_context has changed. If so, reschedule the coroutine to the new context. Calling bdrv_try_set_aio_context() will issue the following calls (simplified): * in terms of bdrv callbacks: .drained_begin -> .set_aio_context -> .drained_end * in terms of child_job functions: child_job_drained_begin -> child_job_set_aio_context -> child_job_drained= _end * in terms of job functions: job_pause_locked -> job_set_aio_context -> job_resume_locked We can see that after setting the new aio_context, job_resume_locked calls again job_enter_cond, which then invokes aio_co_wake(). But while job->aiocontext has been set in job_set_aio_context, job->co->ctx has not changed, so the coroutine would be entering in the wrong aiocontext. Using aio_co_schedule in job_resume_locked() might seem as a valid alternative, but the problem is that the bh resuming the coroutine is not scheduled immediately, and if in the meanwhile another bdrv_try_set_aio_context() is run (see test_propagate_mirror() in test-block-iothread.c), we would have the first schedule in the wrong aiocontext, and the second set of drains won't even manage to schedule the coroutine, as job->busy would still be true from the previous job_resume_locked(). The solution is to stick with aio_co_wake() and detect every time the coroutine resumes back from yielding if job->aio_context has changed. If so, we can reschedule it to the new context. Check for the aiocontext change in job_do_yield_locked because: 1) aio_co_reschedule_self requires to be in the running coroutine 2) since child_job_set_aio_context allows changing the aiocontext only while the job is paused, this is the exact place where the coroutine resumes, before running JobDriver's code. Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Signed-off-by: Paolo Bonzini Message-Id: <20220926093214.506243-13-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- job.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/job.c b/job.c index 926e385ac2..3ef5028751 100644 --- a/job.c +++ b/job.c @@ -588,7 +588,7 @@ void job_enter_cond_locked(Job *job, bool(*fn)(Job *job= )) job->busy =3D true; real_job_unlock(); job_unlock(); - aio_co_enter(job->aio_context, job->co); + aio_co_wake(job->co); job_lock(); } =20 @@ -615,6 +615,8 @@ void job_enter(Job *job) */ static void coroutine_fn job_do_yield_locked(Job *job, uint64_t ns) { + AioContext *next_aio_context; + real_job_lock(); if (ns !=3D -1) { timer_mod(&job->sleep_timer, ns); @@ -626,7 +628,20 @@ static void coroutine_fn job_do_yield_locked(Job *job,= uint64_t ns) qemu_coroutine_yield(); job_lock(); =20 - /* Set by job_enter_cond() before re-entering the coroutine. */ + next_aio_context =3D job->aio_context; + /* + * Coroutine has resumed, but in the meanwhile the job AioContext + * might have changed via bdrv_try_set_aio_context(), so we need to mo= ve + * the coroutine too in the new aiocontext. + */ + while (qemu_get_current_aio_context() !=3D next_aio_context) { + job_unlock(); + aio_co_reschedule_self(next_aio_context); + job_lock(); + next_aio_context =3D job->aio_context; + } + + /* Set by job_enter_cond_locked() before re-entering the coroutine. */ assert(job->busy); } =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665146706; cv=none; d=zohomail.com; s=zohoarc; b=FxJgb03HnwbjgUDFPkE7zFZUhl9oU9NFf3oz/XbiU8qfLyGGHpfGzNKMTDg13HLawFxRDRGxWrbycJWjPe3CxmZUNNNL36B0KolE67j4splBmiwu/XGKE0KfU3aqIFta5bQ9QS27ar0akd0Ik+lSx1c4yUNkggp+dnZcWwYNk1E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146706; 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=VXenS0USuqCPutG2E9TgzFlcbqGbt4PNzs5GFEdAjxw=; b=HmGGB09ey8IPSMYXzgW4yzaWJHXOwX8+WyYm9GBsiNHHNJlEOZzt7JU2JsLkCKdutp9IVDAmBXqr9xEFiLvC3N0qdy3t5PmXre3vZopcV9fmL+VKW73cNReGOc0+X69wmz+o+fNeCpLQOw4g5dvwsTOOWIVlt6EfnY/Ae0SkPBE= 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 166514670599032.59193693741952; Fri, 7 Oct 2022 05:45:05 -0700 (PDT) Received: from localhost ([::1]:47088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmiu-0006On-UG for importer@patchew.org; Fri, 07 Oct 2022 08:45:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40522) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuZ-0006Ai-7S for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:49:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57883) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuX-0003Mr-P6 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:58 -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-675-L9k6LJQ3M-qgs1GHxrNdSg-1; Fri, 07 Oct 2022 06:48:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4059E95E3A5; Fri, 7 Oct 2022 10:48:41 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E6922028DC1; Fri, 7 Oct 2022 10:48:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139737; 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=VXenS0USuqCPutG2E9TgzFlcbqGbt4PNzs5GFEdAjxw=; b=Zhh+CgCWR6ZmXRIR6QMKymByPx6plZ2L/uQF0TetJwW0kp+f4ck4EgQ6FrVe8H4k9d7FRU InLWHGsrMjMIM0Im7G1wQgdNf6KmvFPaLsQAGRZ0D7MXcjSHZo9xVD2vWnpf/5v7bru476 o7fBts26PMBYoOf1SUCJ29+DDEXOCa8= X-MC-Unique: L9k6LJQ3M-qgs1GHxrNdSg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 41/50] jobs: protect job.aio_context with BQL and job_mutex Date: Fri, 7 Oct 2022 12:47:43 +0200 Message-Id: <20221007104752.141361-42-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146707749100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito In order to make it thread safe, implement a "fake rwlock", where we allow reads under BQL *or* job_mutex held, but writes only under BQL *and* job_mutex. The only write we have is in child_job_set_aio_ctx, which always happens under drain (so the job is paused). For this reason, introduce job_set_aio_context and make sure that the context is set under BQL, job_mutex and drain. Also make sure all other places where the aiocontext is read are protected. The reads in commit.c and mirror.c are actually safe, because always done under BQL. Note: at this stage, job_{lock/unlock} and job lock guard macros are *nop*. Suggested-by: Paolo Bonzini Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20220926093214.506243-14-eesposit@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- include/qemu/job.h | 23 ++++++++++++++++++++--- block/replication.c | 1 + blockjob.c | 3 ++- job.c | 12 ++++++++++++ 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index 870dce1535..c96387069d 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -74,11 +74,17 @@ typedef struct Job { /* ProgressMeter API is thread-safe */ ProgressMeter progress; =20 + /** + * AioContext to run the job coroutine in. + * The job Aiocontext can be read when holding *either* + * the BQL (so we are in the main loop) or the job_mutex. + * It can only be written when we hold *both* BQL + * and the job_mutex. + */ + AioContext *aio_context; =20 - /** Protected by AioContext lock */ =20 - /** AioContext to run the job coroutine in */ - AioContext *aio_context; + /** Protected by AioContext lock */ =20 /** Reference count of the block job */ int refcnt; @@ -741,4 +747,15 @@ int job_finish_sync(Job *job, void (*finish)(Job *, Er= ror **errp), int job_finish_sync_locked(Job *job, void (*finish)(Job *, Error **errp), Error **errp); =20 +/** + * Sets the @job->aio_context. + * Called with job_mutex *not* held. + * + * This function must run in the main thread to protect against + * concurrent read in job_finish_sync_locked(), takes the job_mutex + * lock to protect against the read in job_do_yield_locked(), and must + * be called when the job is quiescent. + */ +void job_set_aio_context(Job *job, AioContext *ctx); + #endif diff --git a/block/replication.c b/block/replication.c index 55c8f894aa..5977f7a833 100644 --- a/block/replication.c +++ b/block/replication.c @@ -142,6 +142,7 @@ static void replication_close(BlockDriverState *bs) { BDRVReplicationState *s =3D bs->opaque; Job *commit_job; + GLOBAL_STATE_CODE(); =20 if (s->stage =3D=3D BLOCK_REPLICATION_RUNNING) { replication_stop(s->rs, false, NULL); diff --git a/blockjob.c b/blockjob.c index 96fb9d9f73..c8919cef9b 100644 --- a/blockjob.c +++ b/blockjob.c @@ -162,12 +162,13 @@ static void child_job_set_aio_ctx(BdrvChild *c, AioCo= ntext *ctx, bdrv_set_aio_context_ignore(sibling->bs, ctx, ignore); } =20 - job->job.aio_context =3D ctx; + job_set_aio_context(&job->job, ctx); } =20 static AioContext *child_job_get_parent_aio_context(BdrvChild *c) { BlockJob *job =3D c->opaque; + GLOBAL_STATE_CODE(); =20 return job->job.aio_context; } diff --git a/job.c b/job.c index 3ef5028751..3e6f61c523 100644 --- a/job.c +++ b/job.c @@ -396,6 +396,17 @@ Job *job_get(const char *id) return job_get_locked(id); } =20 +void job_set_aio_context(Job *job, AioContext *ctx) +{ + /* protect against read in job_finish_sync_locked and job_start */ + GLOBAL_STATE_CODE(); + /* protect against read in job_do_yield_locked */ + JOB_LOCK_GUARD(); + /* ensure the job is quiescent while the AioContext is changed */ + assert(job->paused || job_is_completed_locked(job)); + job->aio_context =3D ctx; +} + /* Called with job_mutex *not* held. */ static void job_sleep_timer_cb(void *opaque) { @@ -1379,6 +1390,7 @@ int job_finish_sync_locked(Job *job, { Error *local_err =3D NULL; int ret; + GLOBAL_STATE_CODE(); =20 job_ref_locked(job); =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665143389; cv=none; d=zohomail.com; s=zohoarc; b=fXg4+H8h61cTzjdK4FByTxBiAT/ZgQVsGiNZidBXrL5MQyqY+rcBg+xa5pawBOi+FrOQRFTm/ioate2qrzPIVj8HXXD6Rr/SGrmTuux4vNKoBxEcWlOdl5+4vC+ii/AzagmrttSLBfd1psZBWudYRVsUzijjvEKuIJaRwBSPfWU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665143389; 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=7QNLuesQeEoRs6rSiuaAvoqBv/q1X7S0r9g2GM3nvfg=; b=lDSIw5UHiuA0ZV1dqtjxhiq5W5ekJrHHIZ/r+f+xLN2zhz6/YbS/+O0V1AuG1zGmzRmHAlN1Qd6IxwQXWx3CPJTgK0WwiYPHJ/Sy7FTIA0fztckffwxRqIeaMn/iavFl8jRbTAyHHZRc6tPUHTJSv2FnbdzM/B3TbBGLkEu2DME= 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 1665143389861117.47913894252508; Fri, 7 Oct 2022 04:49:49 -0700 (PDT) Received: from localhost ([::1]:60410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oglrQ-0005iE-8k for importer@patchew.org; Fri, 07 Oct 2022 07:49:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38224) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuN-0005xn-VY for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:52064) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuM-0003JA-6f for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:47 -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-554-6o5AsN4yNP-ICDyYjlHOTA-1; Fri, 07 Oct 2022 06:48:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D3A895E3A8; Fri, 7 Oct 2022 10:48:42 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 78FDF2024CBB; Fri, 7 Oct 2022 10:48:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139725; 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=7QNLuesQeEoRs6rSiuaAvoqBv/q1X7S0r9g2GM3nvfg=; b=gwY3FxaiuJp/8UKpoGZMjCY2JnOMOw9S7owiHVItsp1b7yCiOj3iowk62l67crxQp/sVZ7 7YBDMUaXo3KWm+cQZjA2IQert3ZJwRuPt1CwwjcDSoPTp/lLSPh+e4ckCbnJa0S5uLMT7K jAtc29A9TsT0/141HbrIadJAkD2W9Fc= X-MC-Unique: 6o5AsN4yNP-ICDyYjlHOTA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 42/50] blockjob.h: categorize fields in struct BlockJob Date: Fri, 7 Oct 2022 12:47:44 +0200 Message-Id: <20221007104752.141361-43-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665143390428100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito The same job lock is being used also to protect some of blockjob fields. Categorize them just as done in job.h. Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20220926093214.506243-15-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/blockjob.h | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 8b65d3949d..10c24e240a 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -40,21 +40,38 @@ typedef struct BlockJobDriver BlockJobDriver; * Long-running operation on a BlockDriverState. */ typedef struct BlockJob { - /** Data belonging to the generic Job infrastructure */ + /** + * Data belonging to the generic Job infrastructure. + * Protected by job mutex. + */ Job job; =20 - /** Status that is published by the query-block-jobs QMP API */ + /** + * Status that is published by the query-block-jobs QMP API. + * Protected by job mutex. + */ BlockDeviceIoStatus iostatus; =20 - /** Speed that was set with @block_job_set_speed. */ + /** + * Speed that was set with @block_job_set_speed. + * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + */ int64_t speed; =20 - /** Rate limiting data structure for implementing @speed. */ + /** + * Rate limiting data structure for implementing @speed. + * RateLimit API is thread-safe. + */ RateLimit limit; =20 - /** Block other operations when block job is running */ + /** + * Block other operations when block job is running. + * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + */ Error *blocker; =20 + /** All notifiers are set once in block_job_create() and never modifie= d. */ + /** Called when a cancelled job is finalised. */ Notifier finalize_cancelled_notifier; =20 @@ -70,7 +87,10 @@ typedef struct BlockJob { /** Called when the job coroutine yields or terminates */ Notifier idle_notifier; =20 - /** BlockDriverStates that are involved in this block job */ + /** + * BlockDriverStates that are involved in this block job. + * Always modified and read under QEMU global mutex (GLOBAL_STATE_CODE= ). + */ GSList *nodes; } BlockJob; =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665147875; cv=none; d=zohomail.com; s=zohoarc; b=FkxXUUgRpuHZvhbGdOL6croZYZtDXUHJEfKC6NSM4zuWI7L2nUu8wPEXZJTi+OIsAJQbD6B8J4DF5lBiUirtpgnlqcBEkGdRnR97u/CabddEHt9P1YDYa44cAEFJCHuMCzjdC31i8x3o4x86SxUmvH2ZC4gS+YK0MyD1g+7MW+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665147875; 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=+f8PptoQgZEerq3XQKIpTG03Vwo0qiZUEBDcjBNRHD8=; b=ZowJ7OEDyvROv7Gx3igsJFG9GEFMVFvbIwmY3yM5NeSdKcUk+Ds2D9UQO2DhmQbrlT0J/rCEouQF9PeLsUSXyV5tNjF7qHvc2D9UKW00iy5GYpGBW1xUfcawjcoaugwYpkqtM+K4VKwKWAgJnDYjEvnxgD8Ih92E3gDBnPryOVE= 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 1665147875194647.0388209482105; Fri, 7 Oct 2022 06:04:35 -0700 (PDT) Received: from localhost ([::1]:52084 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogn1l-0005Zw-5C for importer@patchew.org; Fri, 07 Oct 2022 09:04:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuN-0005wa-0J for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:57072) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuL-0003Iu-B6 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:46 -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-663-JJzoI-jOP8iZOoLtOh8Lxg-1; Fri, 07 Oct 2022 06:48:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 35625185A78F; Fri, 7 Oct 2022 10:48:43 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 74B932024CBB; Fri, 7 Oct 2022 10:48:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139724; 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=+f8PptoQgZEerq3XQKIpTG03Vwo0qiZUEBDcjBNRHD8=; b=ZImxU5Vtc3jvYsOnHHy812w5o91udHrFqAtrCHqj6XW3yYC29kFpkNZE99oMwsNgoymHL/ uaSjyTLGwfyuc6BeyJemXEi6237ref2TizEZDkPRvOKPfxe4GksMRX1uK0SZ+lBmKJ08BE NY/Emzjar+dTQt2mh9BR5XuOZkuvrp4= X-MC-Unique: JJzoI-jOP8iZOoLtOh8Lxg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 43/50] blockjob: rename notifier callbacks as _locked Date: Fri, 7 Oct 2022 12:47:45 +0200 Message-Id: <20221007104752.141361-44-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665147876567100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito They all are called with job_lock held, in job_event_*_locked() Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-16-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- blockjob.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/blockjob.c b/blockjob.c index c8919cef9b..d8fb5311c7 100644 --- a/blockjob.c +++ b/blockjob.c @@ -250,7 +250,8 @@ int block_job_add_bdrv(BlockJob *job, const char *name,= BlockDriverState *bs, return 0; } =20 -static void block_job_on_idle(Notifier *n, void *opaque) +/* Called with job_mutex lock held. */ +static void block_job_on_idle_locked(Notifier *n, void *opaque) { aio_wait_kick(); } @@ -370,7 +371,8 @@ static void block_job_iostatus_set_err(BlockJob *job, i= nt error) } } =20 -static void block_job_event_cancelled(Notifier *n, void *opaque) +/* Called with job_mutex lock held. */ +static void block_job_event_cancelled_locked(Notifier *n, void *opaque) { BlockJob *job =3D opaque; uint64_t progress_current, progress_total; @@ -389,7 +391,8 @@ static void block_job_event_cancelled(Notifier *n, void= *opaque) job->speed); } =20 -static void block_job_event_completed(Notifier *n, void *opaque) +/* Called with job_mutex lock held. */ +static void block_job_event_completed_locked(Notifier *n, void *opaque) { BlockJob *job =3D opaque; const char *msg =3D NULL; @@ -415,7 +418,8 @@ static void block_job_event_completed(Notifier *n, void= *opaque) msg); } =20 -static void block_job_event_pending(Notifier *n, void *opaque) +/* Called with job_mutex lock held. */ +static void block_job_event_pending_locked(Notifier *n, void *opaque) { BlockJob *job =3D opaque; =20 @@ -427,7 +431,8 @@ static void block_job_event_pending(Notifier *n, void *= opaque) job->job.id); } =20 -static void block_job_event_ready(Notifier *n, void *opaque) +/* Called with job_mutex lock held. */ +static void block_job_event_ready_locked(Notifier *n, void *opaque) { BlockJob *job =3D opaque; uint64_t progress_current, progress_total; @@ -472,11 +477,11 @@ void *block_job_create(const char *job_id, const Bloc= kJobDriver *driver, =20 ratelimit_init(&job->limit); =20 - job->finalize_cancelled_notifier.notify =3D block_job_event_cancelled; - job->finalize_completed_notifier.notify =3D block_job_event_completed; - job->pending_notifier.notify =3D block_job_event_pending; - job->ready_notifier.notify =3D block_job_event_ready; - job->idle_notifier.notify =3D block_job_on_idle; + job->finalize_cancelled_notifier.notify =3D block_job_event_cancelled_= locked; + job->finalize_completed_notifier.notify =3D block_job_event_completed_= locked; + job->pending_notifier.notify =3D block_job_event_pending_locked; + job->ready_notifier.notify =3D block_job_event_ready_locked; + job->idle_notifier.notify =3D block_job_on_idle_locked; =20 WITH_JOB_LOCK_GUARD() { notifier_list_add(&job->job.on_finalize_cancelled, --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665146273; cv=none; d=zohomail.com; s=zohoarc; b=epiU6LcLJhlljoSWR0/nWny0UPYfUeip1xSocqSl8UhSRt39xXp16q1NVnn/uyX8FkzsRAUEIt61Y6IHLTjUaL7HK+OhYqTV8vpfmTt7Du8FpNWV5TXKNrmM+2HMcBC/z/juP5MN4GSY0MAAe7uWn+eMFSJ+YUjFIWCSK4oCnb8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665146273; 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=/eN7TGtlCeGpaR7gIw93tHCnGlJGEy5lfCRCdxpl8RA=; b=R6mbttRAzebAqBeE1XtASA2UOv2bYJN392zZcesJkqSYPtqgNBs2Kb1y1uYxkW4cpUfwA7ZoaGL3B08CezIi4fCfZ5AiQPS6ZmMlIIaHTbHHtxxO225aHqQYO+VhmmAbfQEelnFWSPmPorJXNCrkYL0yJmn/YOUHhBBOF9mXba4= 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 1665146273680978.4273415106491; Fri, 7 Oct 2022 05:37:53 -0700 (PDT) Received: from localhost ([::1]:59340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmbw-0004jG-Km for importer@patchew.org; Fri, 07 Oct 2022 08:37:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38226) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuO-0005y1-7O for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:60635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuM-0003JW-IM for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:47 -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-121-cldxWwbjNtyGqW4zYlK3vA-1; Fri, 07 Oct 2022 06:48:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D11F85A583; Fri, 7 Oct 2022 10:48:44 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7A3A9200C0DE; Fri, 7 Oct 2022 10:48:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139726; 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=/eN7TGtlCeGpaR7gIw93tHCnGlJGEy5lfCRCdxpl8RA=; b=JTFC8P77NsMZKbuBfkhwEkyxMoQV2cg4XMAjGcl9xrrx0LgZlb7eNcE8Lrbe8tyHPBNn7a ULlpDAsewgDjUwYsdrY8LPFmGhyl237pyZr2KmvYvJOu9ZwlBvxhhwZzmLXcX7UDe32IHx UnY8JV7L1Zy/ycuKKzWqO5Gg6iR6zic= X-MC-Unique: cldxWwbjNtyGqW4zYlK3vA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 44/50] blockjob: protect iostatus field in BlockJob struct Date: Fri, 7 Oct 2022 12:47:46 +0200 Message-Id: <20221007104752.141361-45-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665146275805100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito iostatus is the only field (together with .job) that needs protection using the job mutex. It is set in the main loop (GLOBAL_STATE functions) but read in I/O code (block_job_error_action). In order to protect it, change block_job_iostatus_set_err to block_job_iostatus_set_err_locked(), always called under job lock. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-17-eesposit@redhat.com> [kwolf: Fixed up type of iostatus] Signed-off-by: Kevin Wolf --- block/mirror.c | 6 +++++- blockjob.c | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index c6bf7f40ce..80c0109d39 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -894,6 +894,7 @@ static int coroutine_fn mirror_run(Job *job, Error **er= rp) BlockDriverState *bs =3D s->mirror_top_bs->backing->bs; BlockDriverState *target_bs =3D blk_bs(s->target); bool need_drain =3D true; + BlockDeviceIoStatus iostatus; int64_t length; int64_t target_length; BlockDriverInfo bdi; @@ -1016,8 +1017,11 @@ static int coroutine_fn mirror_run(Job *job, Error *= *errp) * We do so every BLKOCK_JOB_SLICE_TIME nanoseconds, or when there= is * an error, or when the source is clean, whichever comes first. */ delta =3D qemu_clock_get_ns(QEMU_CLOCK_REALTIME) - s->last_pause_n= s; + WITH_JOB_LOCK_GUARD() { + iostatus =3D s->common.iostatus; + } if (delta < BLOCK_JOB_SLICE_TIME && - s->common.iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { + iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { if (s->in_flight >=3D MAX_IN_FLIGHT || s->buf_free_count =3D= =3D 0 || (cnt =3D=3D 0 && s->in_flight > 0)) { trace_mirror_yield(s, cnt, s->buf_free_count, s->in_flight= ); diff --git a/blockjob.c b/blockjob.c index d8fb5311c7..d04f804001 100644 --- a/blockjob.c +++ b/blockjob.c @@ -363,7 +363,8 @@ BlockJobInfo *block_job_query(BlockJob *job, Error **er= rp) return block_job_query_locked(job, errp); } =20 -static void block_job_iostatus_set_err(BlockJob *job, int error) +/* Called with job lock held */ +static void block_job_iostatus_set_err_locked(BlockJob *job, int error) { if (job->iostatus =3D=3D BLOCK_DEVICE_IO_STATUS_OK) { job->iostatus =3D error =3D=3D ENOSPC ? BLOCK_DEVICE_IO_STATUS_NOS= PACE : @@ -577,8 +578,8 @@ BlockErrorAction block_job_error_action(BlockJob *job, = BlockdevOnError on_err, */ job->job.user_paused =3D true; } + block_job_iostatus_set_err_locked(job, error); } - block_job_iostatus_set_err(job, error); } return action; } --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665148391; cv=none; d=zohomail.com; s=zohoarc; b=HWlB/xaTDhPoFPb+ZaVwj0Lfr9QCoVrBh9HLXfTt8ZjXURU9fJg1fXk8epcEmV6OSN48R/+wUsimJ01j/ngFPWopl8v9S2kn+tSa0ZWS9fMw9lDbxnTaFrkJ1jAhvkqJ9orpOcY5x+h/44PcLsYITz8imHp5x+YXW1/nquD6wB8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665148391; 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=SXOprbof5ZzjV+Qg8oww6F0SLAFGGrPH06mQ6uz1py0=; b=Syys9jFRTTmmEqHfwkB4VQTUQbRezP0sYK6aBVAaocXitW3pBrqd5OekFcYPvk66SR0/BZ+BwYAEgpEcGbHDYWrAkoMy95bn/jZeOFYW3PX6CEK8wcC9QvoE6q26wXL+R355Akqc6e76UTEdCBn1KvbcjKR/Rv+QM7Nfu587N48= 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 1665148391930876.3080870383482; Fri, 7 Oct 2022 06:13:11 -0700 (PDT) Received: from localhost ([::1]:56940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ognA6-00037S-FD for importer@patchew.org; Fri, 07 Oct 2022 09:13:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38228) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuO-0005zJ-Rl for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:42241) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuN-0003Jk-77 for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:48 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-194-Z3ykn96vP0-gS1cYgi5G8g-1; Fri, 07 Oct 2022 06:48:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 358CC3826244; Fri, 7 Oct 2022 10:48:45 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7543A2024CBB; Fri, 7 Oct 2022 10:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139726; 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=SXOprbof5ZzjV+Qg8oww6F0SLAFGGrPH06mQ6uz1py0=; b=aydGLN8YXf40GEFdeiEJ+glwsjq2bmumEZ0mWCnmQxTfUz5d1VYPo/Fw0e6yWLoeeEU17+ hM5sSStNbmIYfO8zTBgUfbXt9+JkBAH8R8mFummAkPHIp+ZryxvOjekr3477imc98/d5D+ fUkCU0tdwMCIgdf2IEFLRef14jEiadc= X-MC-Unique: Z3ykn96vP0-gS1cYgi5G8g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 45/50] job.h: categorize JobDriver callbacks that need the AioContext lock Date: Fri, 7 Oct 2022 12:47:47 +0200 Message-Id: <20221007104752.141361-46-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665148394290100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Some callbacks implementation use bdrv_* APIs that assume the AioContext lock is held. Make sure this invariant is documented. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-18-eesposit@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/qemu/job.h | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index c96387069d..b943d90e8f 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -65,7 +65,11 @@ typedef struct Job { /** True if this job should automatically dismiss itself */ bool auto_dismiss; =20 - /** The completion function that will be called when the job completes= . */ + /** + * The completion function that will be called when the job completes. + * Called with AioContext lock held, since many callback implementatio= ns + * use bdrv_* functions that require to hold the lock. + */ BlockCompletionFunc *cb; =20 /** The opaque value that is passed to the completion function. */ @@ -260,6 +264,9 @@ struct JobDriver { * * This callback will not be invoked if the job has already failed. * If it fails, abort and then clean will be called. + * + * Called with AioContext lock held, since many callbacs implementatio= ns + * use bdrv_* functions that require to hold the lock. */ int (*prepare)(Job *job); =20 @@ -270,6 +277,9 @@ struct JobDriver { * * All jobs will complete with a call to either .commit() or .abort() = but * never both. + * + * Called with AioContext lock held, since many callback implementatio= ns + * use bdrv_* functions that require to hold the lock. */ void (*commit)(Job *job); =20 @@ -280,6 +290,9 @@ struct JobDriver { * * All jobs will complete with a call to either .commit() or .abort() = but * never both. + * + * Called with AioContext lock held, since many callback implementatio= ns + * use bdrv_* functions that require to hold the lock. */ void (*abort)(Job *job); =20 @@ -288,6 +301,9 @@ struct JobDriver { * .commit() or .abort(). Regardless of which callback is invoked after * completion, .clean() will always be called, even if the job does not * belong to a transaction group. + * + * Called with AioContext lock held, since many callbacs implementatio= ns + * use bdrv_* functions that require to hold the lock. */ void (*clean)(Job *job); =20 @@ -302,11 +318,18 @@ struct JobDriver { * READY). * (If the callback is NULL, the job is assumed to terminate * without I/O.) + * + * Called with AioContext lock held, since many callback implementatio= ns + * use bdrv_* functions that require to hold the lock. */ bool (*cancel)(Job *job, bool force); =20 =20 - /** Called when the job is freed */ + /** + * Called when the job is freed. + * Called with AioContext lock held, since many callback implementatio= ns + * use bdrv_* functions that require to hold the lock. + */ void (*free)(Job *job); }; =20 --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665148404; cv=none; d=zohomail.com; s=zohoarc; b=Psho49yG1SPAfrddaJqww7LPsONS41k1ntfB+0oI2pZPBHlEb0yNVQTKDvHe+I9eVWoA96DEiTlalllLbhN6cpv0zB0dED97q47lpmZ+NzDUyaff0UjUeu7d3K91hB3yyg4maq1SNAq2iVt/Zvlp0EFDFqQUOplQYGe9/lees9I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665148404; 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=n2WdplvwTI6MIfo/zELfBqymRgLDY2/NxUe8BieTvEc=; b=dvpm+juI5jB+etUFDXkFI+60Z1pYWCmPkzSmAHY1ViwAu7iVJs24zNVm5pzIgJms3WilznE2d1ayEitgCA5aSs8euI5cBVwDSnDk3bkDe/UHcHWfvwN7n8bjXbkSRm5fbDZCF1oYE3ZVGjfxv3PvmuI+NIKSKQKlr6cfpCNzm+Q= 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 1665148404863339.1336604102946; Fri, 7 Oct 2022 06:13:24 -0700 (PDT) Received: from localhost ([::1]:56942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ognAI-0003BS-3T for importer@patchew.org; Fri, 07 Oct 2022 09:13:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38244) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuT-00064j-8L for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:41117) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuQ-0003Kr-8d for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:53 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-410-HD6FjsjAOYmCN-dzV6G9sQ-1; Fri, 07 Oct 2022 06:48:46 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 354D51C0515C; Fri, 7 Oct 2022 10:48:46 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7164B2028DC1; Fri, 7 Oct 2022 10:48:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139729; 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=n2WdplvwTI6MIfo/zELfBqymRgLDY2/NxUe8BieTvEc=; b=GhwkagUw2w+WPrR5IiVzR1u1iuwSmQeFJG4Qpge5r9LWEGA6DWLpLQEfg2sbo77k56Z3QN mcMGcncN7sM9rUa8kYv37zNLPv4K+fxDG9C5MdaHEo9QprQfRMEiEenMPOfAYAGM9j8XKT 10/VLDe87vFHIXY9kUtjbdp7yT7zTUE= X-MC-Unique: HD6FjsjAOYmCN-dzV6G9sQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 46/50] job.c: enable job lock/unlock and remove Aiocontext locks Date: Fri, 7 Oct 2022 12:47:48 +0200 Message-Id: <20221007104752.141361-47-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665148406064100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Change the job_{lock/unlock} and macros to use job_mutex. Now that they are not nop anymore, remove the aiocontext to avoid deadlocks. Therefore: - when possible, remove completely the aiocontext lock/unlock pair - if it is used by some other function too, reduce the locking section as much as possible, leaving the job API outside. - change AIO_WAIT_WHILE in AIO_WAIT_WHILE_UNLOCKED, since we are not using the aiocontext lock anymore The only functions that still need the aiocontext lock are: - the JobDriver callbacks, already documented in job.h - job_cancel_sync() in replication.c is called with aio_context_lock taken, but now job is using AIO_WAIT_WHILE_UNLOCKED so we need to release the lock. Reduce the locking section to only cover the callback invocation and document the functions that take the AioContext lock, to avoid taking it twice. Also remove real_job_{lock/unlock}, as they are replaced by the public functions. Signed-off-by: Emanuele Giuseppe Esposito Message-Id: <20220926093214.506243-19-eesposit@redhat.com> Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- include/qemu/job.h | 17 ++--- block/replication.c | 2 + blockdev.c | 72 +++----------------- job-qmp.c | 46 +++---------- job.c | 111 +++++++++---------------------- qemu-img.c | 2 - tests/unit/test-bdrv-drain.c | 4 +- tests/unit/test-block-iothread.c | 2 +- tests/unit/test-blockjob.c | 19 +++--- 9 files changed, 72 insertions(+), 203 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index b943d90e8f..a54fb83887 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -88,7 +88,7 @@ typedef struct Job { AioContext *aio_context; =20 =20 - /** Protected by AioContext lock */ + /** Protected by job_mutex */ =20 /** Reference count of the block job */ int refcnt; @@ -111,7 +111,7 @@ typedef struct Job { /** * Set to false by the job while the coroutine has yielded and may be * re-entered by job_enter(). There may still be I/O or event loop act= ivity - * pending. Accessed under block_job_mutex (in blockjob.c). + * pending. Accessed under job_mutex. * * When the job is deferred to the main loop, busy is true as long as = the * bottom half is still pending. @@ -346,9 +346,9 @@ typedef enum JobCreateFlags { =20 extern QemuMutex job_mutex; =20 -#define JOB_LOCK_GUARD() /* QEMU_LOCK_GUARD(&job_mutex) */ +#define JOB_LOCK_GUARD() QEMU_LOCK_GUARD(&job_mutex) =20 -#define WITH_JOB_LOCK_GUARD() /* WITH_QEMU_LOCK_GUARD(&job_mutex) */ +#define WITH_JOB_LOCK_GUARD() WITH_QEMU_LOCK_GUARD(&job_mutex) =20 /** * job_lock: @@ -422,6 +422,8 @@ void job_ref_locked(Job *job); /** * Release a reference that was previously acquired with job_ref() or * job_create(). If it's the last reference to the object, it will be free= d. + * + * Takes AioContext lock internally to invoke a job->driver callback. */ void job_unref(Job *job); =20 @@ -696,7 +698,7 @@ void job_user_cancel_locked(Job *job, bool force, Error= **errp); * Returns the return value from the job if the job actually completed * during the call, or -ECANCELED if it was canceled. * - * Callers must hold the AioContext lock of job->aio_context. + * Called with job_lock *not* held. */ int job_cancel_sync(Job *job, bool force); =20 @@ -721,8 +723,7 @@ void job_cancel_sync_all(void); * function). * * Returns the return value from the job. - * - * Callers must hold the AioContext lock of job->aio_context. + * Called with job_lock *not* held. */ int job_complete_sync(Job *job, Error **errp); =20 @@ -758,7 +759,7 @@ void job_dismiss_locked(Job **job, Error **errp); * Returns 0 if the job is successfully completed, -ECANCELED if the job w= as * cancelled before completing, and -errno in other error cases. * - * Callers must hold the AioContext lock of job->aio_context. + * Called with job_lock *not* held. */ int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error **errp); diff --git a/block/replication.c b/block/replication.c index 5977f7a833..c67f931f37 100644 --- a/block/replication.c +++ b/block/replication.c @@ -727,7 +727,9 @@ static void replication_stop(ReplicationState *rs, bool= failover, Error **errp) * disk, secondary disk in backup_job_completed(). */ if (s->backup_job) { + aio_context_release(aio_context); job_cancel_sync(&s->backup_job->job, true); + aio_context_acquire(aio_context); } =20 if (!failover) { diff --git a/blockdev.c b/blockdev.c index 46090bb0aa..a32bafc07a 100644 --- a/blockdev.c +++ b/blockdev.c @@ -155,12 +155,7 @@ void blockdev_mark_auto_del(BlockBackend *blk) for (job =3D block_job_next_locked(NULL); job; job =3D block_job_next_locked(job)) { if (block_job_has_bdrv(job, blk_bs(blk))) { - AioContext *aio_context =3D job->job.aio_context; - aio_context_acquire(aio_context); - job_cancel_locked(&job->job, false); - - aio_context_release(aio_context); } } =20 @@ -1847,14 +1842,7 @@ static void drive_backup_abort(BlkActionState *commo= n) DriveBackupState *state =3D DO_UPCAST(DriveBackupState, common, common= ); =20 if (state->job) { - AioContext *aio_context; - - aio_context =3D bdrv_get_aio_context(state->bs); - aio_context_acquire(aio_context); - job_cancel_sync(&state->job->job, true); - - aio_context_release(aio_context); } } =20 @@ -1948,14 +1936,7 @@ static void blockdev_backup_abort(BlkActionState *co= mmon) BlockdevBackupState *state =3D DO_UPCAST(BlockdevBackupState, common, = common); =20 if (state->job) { - AioContext *aio_context; - - aio_context =3D bdrv_get_aio_context(state->bs); - aio_context_acquire(aio_context); - job_cancel_sync(&state->job->job, true); - - aio_context_release(aio_context); } } =20 @@ -3317,19 +3298,14 @@ out: } =20 /* - * Get a block job using its ID and acquire its AioContext. - * Called with job_mutex held. + * Get a block job using its ID. Called with job_mutex held. */ -static BlockJob *find_block_job_locked(const char *id, - AioContext **aio_context, - Error **errp) +static BlockJob *find_block_job_locked(const char *id, Error **errp) { BlockJob *job; =20 assert(id !=3D NULL); =20 - *aio_context =3D NULL; - job =3D block_job_get_locked(id); =20 if (!job) { @@ -3338,36 +3314,30 @@ static BlockJob *find_block_job_locked(const char *= id, return NULL; } =20 - *aio_context =3D block_job_get_aio_context(job); - aio_context_acquire(*aio_context); - return job; } =20 void qmp_block_job_set_speed(const char *device, int64_t speed, Error **er= rp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(device, &aio_context, errp); + job =3D find_block_job_locked(device, errp); =20 if (!job) { return; } =20 block_job_set_speed_locked(job, speed, errp); - aio_context_release(aio_context); } =20 void qmp_block_job_cancel(const char *device, bool has_force, bool force, Error **errp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(device, &aio_context, errp); + job =3D find_block_job_locked(device, errp); =20 if (!job) { return; @@ -3380,22 +3350,19 @@ void qmp_block_job_cancel(const char *device, if (job_user_paused_locked(&job->job) && !force) { error_setg(errp, "The block job for device '%s' is currently pause= d", device); - goto out; + return; } =20 trace_qmp_block_job_cancel(job); job_user_cancel_locked(&job->job, force, errp); -out: - aio_context_release(aio_context); } =20 void qmp_block_job_pause(const char *device, Error **errp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(device, &aio_context, errp); + job =3D find_block_job_locked(device, errp); =20 if (!job) { return; @@ -3403,16 +3370,14 @@ void qmp_block_job_pause(const char *device, Error = **errp) =20 trace_qmp_block_job_pause(job); job_user_pause_locked(&job->job, errp); - aio_context_release(aio_context); } =20 void qmp_block_job_resume(const char *device, Error **errp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(device, &aio_context, errp); + job =3D find_block_job_locked(device, errp); =20 if (!job) { return; @@ -3420,16 +3385,14 @@ void qmp_block_job_resume(const char *device, Error= **errp) =20 trace_qmp_block_job_resume(job); job_user_resume_locked(&job->job, errp); - aio_context_release(aio_context); } =20 void qmp_block_job_complete(const char *device, Error **errp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(device, &aio_context, errp); + job =3D find_block_job_locked(device, errp); =20 if (!job) { return; @@ -3437,16 +3400,14 @@ void qmp_block_job_complete(const char *device, Err= or **errp) =20 trace_qmp_block_job_complete(job); job_complete_locked(&job->job, errp); - aio_context_release(aio_context); } =20 void qmp_block_job_finalize(const char *id, Error **errp) { - AioContext *aio_context; BlockJob *job; =20 JOB_LOCK_GUARD(); - job =3D find_block_job_locked(id, &aio_context, errp); + job =3D find_block_job_locked(id, errp); =20 if (!job) { return; @@ -3456,24 +3417,16 @@ void qmp_block_job_finalize(const char *id, Error *= *errp) job_ref_locked(&job->job); job_finalize_locked(&job->job, errp); =20 - /* - * Job's context might have changed via job_finalize (and job_txn_apply - * automatically acquires the new one), so make sure we release the co= rrect - * one. - */ - aio_context =3D block_job_get_aio_context(job); job_unref_locked(&job->job); - aio_context_release(aio_context); } =20 void qmp_block_job_dismiss(const char *id, Error **errp) { - AioContext *aio_context; BlockJob *bjob; Job *job; =20 JOB_LOCK_GUARD(); - bjob =3D find_block_job_locked(id, &aio_context, errp); + bjob =3D find_block_job_locked(id, errp); =20 if (!bjob) { return; @@ -3482,7 +3435,6 @@ void qmp_block_job_dismiss(const char *id, Error **er= rp) trace_qmp_block_job_dismiss(bjob); job =3D &bjob->job; job_dismiss_locked(&job, errp); - aio_context_release(aio_context); } =20 void qmp_change_backing_file(const char *device, @@ -3764,15 +3716,11 @@ BlockJobInfoList *qmp_query_block_jobs(Error **errp) for (job =3D block_job_next_locked(NULL); job; job =3D block_job_next_locked(job)) { BlockJobInfo *value; - AioContext *aio_context; =20 if (block_job_is_internal(job)) { continue; } - aio_context =3D block_job_get_aio_context(job); - aio_context_acquire(aio_context); value =3D block_job_query_locked(job, errp); - aio_context_release(aio_context); if (!value) { qapi_free_BlockJobInfoList(head); return NULL; diff --git a/job-qmp.c b/job-qmp.c index 393d3a5b81..d498fc89c0 100644 --- a/job-qmp.c +++ b/job-qmp.c @@ -30,36 +30,27 @@ #include "trace/trace-root.h" =20 /* - * Get a job using its ID and acquire its AioContext. - * Called with job_mutex held. + * Get a job using its ID. Called with job_mutex held. */ -static Job *find_job_locked(const char *id, - AioContext **aio_context, - Error **errp) +static Job *find_job_locked(const char *id, Error **errp) { Job *job; =20 - *aio_context =3D NULL; - job =3D job_get_locked(id); if (!job) { error_setg(errp, "Job not found"); return NULL; } =20 - *aio_context =3D job->aio_context; - aio_context_acquire(*aio_context); - return job; } =20 void qmp_job_cancel(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -67,16 +58,14 @@ void qmp_job_cancel(const char *id, Error **errp) =20 trace_qmp_job_cancel(job); job_user_cancel_locked(job, true, errp); - aio_context_release(aio_context); } =20 void qmp_job_pause(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -84,16 +73,14 @@ void qmp_job_pause(const char *id, Error **errp) =20 trace_qmp_job_pause(job); job_user_pause_locked(job, errp); - aio_context_release(aio_context); } =20 void qmp_job_resume(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -101,16 +88,14 @@ void qmp_job_resume(const char *id, Error **errp) =20 trace_qmp_job_resume(job); job_user_resume_locked(job, errp); - aio_context_release(aio_context); } =20 void qmp_job_complete(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -118,16 +103,14 @@ void qmp_job_complete(const char *id, Error **errp) =20 trace_qmp_job_complete(job); job_complete_locked(job, errp); - aio_context_release(aio_context); } =20 void qmp_job_finalize(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -137,23 +120,15 @@ void qmp_job_finalize(const char *id, Error **errp) job_ref_locked(job); job_finalize_locked(job, errp); =20 - /* - * Job's context might have changed via job_finalize (and job_txn_apply - * automatically acquires the new one), so make sure we release the co= rrect - * one. - */ - aio_context =3D job->aio_context; job_unref_locked(job); - aio_context_release(aio_context); } =20 void qmp_job_dismiss(const char *id, Error **errp) { - AioContext *aio_context; Job *job; =20 JOB_LOCK_GUARD(); - job =3D find_job_locked(id, &aio_context, errp); + job =3D find_job_locked(id, errp); =20 if (!job) { return; @@ -161,7 +136,6 @@ void qmp_job_dismiss(const char *id, Error **errp) =20 trace_qmp_job_dismiss(job); job_dismiss_locked(&job, errp); - aio_context_release(aio_context); } =20 /* Called with job_mutex held. */ @@ -199,15 +173,11 @@ JobInfoList *qmp_query_jobs(Error **errp) =20 for (job =3D job_next_locked(NULL); job; job =3D job_next_locked(job))= { JobInfo *value; - AioContext *aio_context; =20 if (job_is_internal(job)) { continue; } - aio_context =3D job->aio_context; - aio_context_acquire(aio_context); value =3D job_query_single_locked(job, errp); - aio_context_release(aio_context); if (!value) { qapi_free_JobInfoList(head); return NULL; diff --git a/job.c b/job.c index 3e6f61c523..76c6d7f79d 100644 --- a/job.c +++ b/job.c @@ -44,8 +44,6 @@ * * The second includes functions used by the job drivers and sometimes * by the core block layer. These delegate the locking to the callee inste= ad. - * - * TODO Actually make this true */ =20 /* @@ -98,21 +96,11 @@ struct JobTxn { }; =20 void job_lock(void) -{ - /* nop */ -} - -void job_unlock(void) -{ - /* nop */ -} - -static void real_job_lock(void) { qemu_mutex_lock(&job_mutex); } =20 -static void real_job_unlock(void) +void job_unlock(void) { qemu_mutex_unlock(&job_mutex); } @@ -187,7 +175,6 @@ static void job_txn_del_job_locked(Job *job) /* Called with job_mutex held, but releases it temporarily. */ static int job_txn_apply_locked(Job *job, int fn(Job *)) { - AioContext *inner_ctx; Job *other_job, *next; JobTxn *txn =3D job->txn; int rc =3D 0; @@ -199,23 +186,14 @@ static int job_txn_apply_locked(Job *job, int fn(Job = *)) * break AIO_WAIT_WHILE from within fn. */ job_ref_locked(job); - aio_context_release(job->aio_context); =20 QLIST_FOREACH_SAFE(other_job, &txn->jobs, txn_list, next) { - inner_ctx =3D other_job->aio_context; - aio_context_acquire(inner_ctx); rc =3D fn(other_job); - aio_context_release(inner_ctx); if (rc) { break; } } =20 - /* - * Note that job->aio_context might have been changed by calling fn, s= o we - * can't use a local variable to cache it. - */ - aio_context_acquire(job->aio_context); job_unref_locked(job); return rc; } @@ -503,8 +481,12 @@ void job_unref_locked(Job *job) assert(!job->txn); =20 if (job->driver->free) { + AioContext *aio_context =3D job->aio_context; job_unlock(); + /* FIXME: aiocontext lock is required because cb calls blk_unr= ef */ + aio_context_acquire(aio_context); job->driver->free(job); + aio_context_release(aio_context); job_lock(); } =20 @@ -583,21 +565,17 @@ void job_enter_cond_locked(Job *job, bool(*fn)(Job *j= ob)) return; } =20 - real_job_lock(); if (job->busy) { - real_job_unlock(); return; } =20 if (fn && !fn(job)) { - real_job_unlock(); return; } =20 assert(!job->deferred_to_main_loop); timer_del(&job->sleep_timer); job->busy =3D true; - real_job_unlock(); job_unlock(); aio_co_wake(job->co); job_lock(); @@ -628,13 +606,11 @@ static void coroutine_fn job_do_yield_locked(Job *job= , uint64_t ns) { AioContext *next_aio_context; =20 - real_job_lock(); if (ns !=3D -1) { timer_mod(&job->sleep_timer, ns); } job->busy =3D false; job_event_idle_locked(job); - real_job_unlock(); job_unlock(); qemu_coroutine_yield(); job_lock(); @@ -920,10 +896,14 @@ static void job_clean(Job *job) } } =20 -/* Called with job_mutex held, but releases it temporarily */ +/* + * Called with job_mutex held, but releases it temporarily. + * Takes AioContext lock internally to invoke a job->driver callback. + */ static int job_finalize_single_locked(Job *job) { int job_ret; + AioContext *ctx =3D job->aio_context; =20 assert(job_is_completed_locked(job)); =20 @@ -932,6 +912,7 @@ static int job_finalize_single_locked(Job *job) =20 job_ret =3D job->ret; job_unlock(); + aio_context_acquire(ctx); =20 if (!job_ret) { job_commit(job); @@ -940,15 +921,13 @@ static int job_finalize_single_locked(Job *job) } job_clean(job); =20 - job_lock(); - if (job->cb) { - job_ret =3D job->ret; - job_unlock(); job->cb(job->opaque, job_ret); - job_lock(); } =20 + aio_context_release(ctx); + job_lock(); + /* Emit events only if we actually started */ if (job_started_locked(job)) { if (job_is_cancelled_locked(job)) { @@ -963,13 +942,19 @@ static int job_finalize_single_locked(Job *job) return 0; } =20 -/* Called with job_mutex held, but releases it temporarily */ +/* + * Called with job_mutex held, but releases it temporarily. + * Takes AioContext lock internally to invoke a job->driver callback. + */ static void job_cancel_async_locked(Job *job, bool force) { + AioContext *ctx =3D job->aio_context; GLOBAL_STATE_CODE(); if (job->driver->cancel) { job_unlock(); + aio_context_acquire(ctx); force =3D job->driver->cancel(job, force); + aio_context_release(ctx); job_lock(); } else { /* No .cancel() means the job will behave as if force-cancelled */ @@ -1002,10 +987,12 @@ static void job_cancel_async_locked(Job *job, bool f= orce) } } =20 -/* Called with job_mutex held, but releases it temporarily. */ +/* + * Called with job_mutex held, but releases it temporarily. + * Takes AioContext lock internally to invoke a job->driver callback. + */ static void job_completed_txn_abort_locked(Job *job) { - AioContext *ctx; JobTxn *txn =3D job->txn; Job *other_job; =20 @@ -1018,54 +1005,31 @@ static void job_completed_txn_abort_locked(Job *job) txn->aborting =3D true; job_txn_ref_locked(txn); =20 - /* - * We can only hold the single job's AioContext lock while calling - * job_finalize_single() because the finalization callbacks can involve - * calls of AIO_WAIT_WHILE(), which could deadlock otherwise. - * Note that the job's AioContext may change when it is finalized. - */ job_ref_locked(job); - aio_context_release(job->aio_context); =20 /* Other jobs are effectively cancelled by us, set the status for * them; this job, however, may or may not be cancelled, depending * on the caller, so leave it. */ QLIST_FOREACH(other_job, &txn->jobs, txn_list) { if (other_job !=3D job) { - ctx =3D other_job->aio_context; - aio_context_acquire(ctx); /* * This is a transaction: If one job failed, no result will ma= tter. * Therefore, pass force=3Dtrue to terminate all other jobs as= quickly * as possible. */ job_cancel_async_locked(other_job, true); - aio_context_release(ctx); } } while (!QLIST_EMPTY(&txn->jobs)) { other_job =3D QLIST_FIRST(&txn->jobs); - /* - * The job's AioContext may change, so store it in @ctx so we - * release the same context that we have acquired before. - */ - ctx =3D other_job->aio_context; - aio_context_acquire(ctx); if (!job_is_completed_locked(other_job)) { assert(job_cancel_requested_locked(other_job)); job_finish_sync_locked(other_job, NULL, NULL); } job_finalize_single_locked(other_job); - aio_context_release(ctx); } =20 - /* - * Use job_ref()/job_unref() so we can read the AioContext here - * even if the job went away during job_finalize_single(). - */ - aio_context_acquire(job->aio_context); job_unref_locked(job); - job_txn_unref_locked(txn); } =20 @@ -1073,15 +1037,20 @@ static void job_completed_txn_abort_locked(Job *job) static int job_prepare_locked(Job *job) { int ret; + AioContext *ctx =3D job->aio_context; =20 GLOBAL_STATE_CODE(); + if (job->ret =3D=3D 0 && job->driver->prepare) { job_unlock(); + aio_context_acquire(ctx); ret =3D job->driver->prepare(job); + aio_context_release(ctx); job_lock(); job->ret =3D ret; job_update_rc_locked(job); } + return job->ret; } =20 @@ -1186,11 +1155,8 @@ static void job_completed_locked(Job *job) static void job_exit(void *opaque) { Job *job =3D (Job *)opaque; - AioContext *ctx; JOB_LOCK_GUARD(); - job_ref_locked(job); - aio_context_acquire(job->aio_context); =20 /* This is a lie, we're not quiescent, but still doing the completion * callbacks. However, completion callbacks tend to involve operations= that @@ -1200,16 +1166,7 @@ static void job_exit(void *opaque) job_event_idle_locked(job); =20 job_completed_locked(job); - - /* - * Note that calling job_completed can move the job to a different - * aio_context, so we cannot cache from above. job_txn_apply takes car= e of - * acquiring the new lock, and we ref/unref to avoid job_completed fre= eing - * the job underneath us. - */ - ctx =3D job->aio_context; job_unref_locked(job); - aio_context_release(ctx); } =20 /** @@ -1337,14 +1294,10 @@ int job_cancel_sync(Job *job, bool force) void job_cancel_sync_all(void) { Job *job; - AioContext *aio_context; JOB_LOCK_GUARD(); =20 while ((job =3D job_next_locked(NULL))) { - aio_context =3D job->aio_context; - aio_context_acquire(aio_context); job_cancel_sync_locked(job, true); - aio_context_release(aio_context); } } =20 @@ -1404,8 +1357,8 @@ int job_finish_sync_locked(Job *job, } =20 job_unlock(); - AIO_WAIT_WHILE(job->aio_context, - (job_enter(job), !job_is_completed(job))); + AIO_WAIT_WHILE_UNLOCKED(job->aio_context, + (job_enter(job), !job_is_completed(job))); job_lock(); =20 ret =3D (job_is_cancelled_locked(job) && job->ret =3D=3D 0) diff --git a/qemu-img.c b/qemu-img.c index e0a30b1f4c..ace3adf8ae 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -911,7 +911,6 @@ static void run_block_job(BlockJob *job, Error **errp) AioContext *aio_context =3D block_job_get_aio_context(job); int ret =3D 0; =20 - aio_context_acquire(aio_context); job_lock(); job_ref_locked(&job->job); do { @@ -936,7 +935,6 @@ static void run_block_job(BlockJob *job, Error **errp) } job_unref_locked(&job->job); job_unlock(); - aio_context_release(aio_context); =20 /* publish completion progress only when success */ if (!ret) { diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index 0db056ea63..4924ceb562 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -930,9 +930,9 @@ static void test_blockjob_common_drain_node(enum drain_= type drain_type, tjob->prepare_ret =3D -EIO; break; } + aio_context_release(ctx); =20 job_start(&job->job); - aio_context_release(ctx); =20 if (use_iothread) { /* job_co_entry() is run in the I/O thread, wait for the actual job @@ -1016,12 +1016,12 @@ static void test_blockjob_common_drain_node(enum dr= ain_type drain_type, g_assert_true(job->job.busy); /* We're in qemu_co_sleep_ns() */ } =20 - aio_context_acquire(ctx); WITH_JOB_LOCK_GUARD() { ret =3D job_complete_sync_locked(&job->job, &error_abort); } g_assert_cmpint(ret, =3D=3D, (result =3D=3D TEST_JOB_SUCCESS ? 0 : -EI= O)); =20 + aio_context_acquire(ctx); if (use_iothread) { blk_set_aio_context(blk_src, qemu_get_aio_context(), &error_abort); assert(blk_get_aio_context(blk_target) =3D=3D qemu_get_aio_context= ()); diff --git a/tests/unit/test-block-iothread.c b/tests/unit/test-block-iothr= ead.c index 96fd21c00a..def0709b2b 100644 --- a/tests/unit/test-block-iothread.c +++ b/tests/unit/test-block-iothread.c @@ -582,10 +582,10 @@ static void test_attach_blockjob(void) aio_poll(qemu_get_aio_context(), false); } =20 - aio_context_acquire(ctx); WITH_JOB_LOCK_GUARD() { job_complete_sync_locked(&tjob->common.job, &error_abort); } + aio_context_acquire(ctx); blk_set_aio_context(blk, qemu_get_aio_context(), &error_abort); aio_context_release(ctx); =20 diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index e4f126bb6d..f88e10e356 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -228,10 +228,7 @@ static void cancel_common(CancelJob *s) BlockJob *job =3D &s->common; BlockBackend *blk =3D s->blk; JobStatus sts =3D job->job.status; - AioContext *ctx; - - ctx =3D job->job.aio_context; - aio_context_acquire(ctx); + AioContext *ctx =3D job->job.aio_context; =20 job_cancel_sync(&job->job, true); WITH_JOB_LOCK_GUARD() { @@ -242,9 +239,11 @@ static void cancel_common(CancelJob *s) assert(job->job.status =3D=3D JOB_STATUS_NULL); job_unref_locked(&job->job); } - destroy_blk(blk); =20 + aio_context_acquire(ctx); + destroy_blk(blk); aio_context_release(ctx); + } =20 static void test_cancel_created(void) @@ -384,12 +383,10 @@ static void test_cancel_concluded(void) aio_poll(qemu_get_aio_context(), true); assert_job_status_is(job, JOB_STATUS_PENDING); =20 - aio_context_acquire(job->aio_context); WITH_JOB_LOCK_GUARD() { job_finalize_locked(job, &error_abort); + assert(job->status =3D=3D JOB_STATUS_CONCLUDED); } - aio_context_release(job->aio_context); - assert_job_status_is(job, JOB_STATUS_CONCLUDED); =20 cancel_common(s); } @@ -481,13 +478,11 @@ static void test_complete_in_standby(void) =20 /* Wait for the job to become READY */ job_start(job); - aio_context_acquire(ctx); /* * Here we are waiting for the status to change, so don't bother * protecting the read every time. */ - AIO_WAIT_WHILE(ctx, job->status !=3D JOB_STATUS_READY); - aio_context_release(ctx); + AIO_WAIT_WHILE_UNLOCKED(ctx, job->status !=3D JOB_STATUS_READY); =20 /* Begin the drained section, pausing the job */ bdrv_drain_all_begin(); @@ -497,6 +492,7 @@ static void test_complete_in_standby(void) aio_context_acquire(ctx); /* This will schedule the job to resume it */ bdrv_drain_all_end(); + aio_context_release(ctx); =20 WITH_JOB_LOCK_GUARD() { /* But the job cannot run, so it will remain on standby */ @@ -515,6 +511,7 @@ static void test_complete_in_standby(void) job_dismiss_locked(&job, &error_abort); } =20 + aio_context_acquire(ctx); destroy_blk(blk); aio_context_release(ctx); iothread_join(iothread); --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665144841; cv=none; d=zohomail.com; s=zohoarc; b=Sd6qt/f/nWalbNzyYqhd8xRPpDxbqvxeekF6LUDhBIAZ7s8Elb2jPj+gKW8sZBQwfGoVjxb6uf/ijhsqXrLPeRMlA9L1Tf9uIrPuuPdGVZSV2RHmhDYuai44ARV5lk3dfIHXdswKQbqN+E+vb93pvzce6jiNdX1fuzUQWKYqCOo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665144841; 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=3Qe31bWZzB3g1O7E5Ha8N3VwT1R1GmaP1RgMnXpW+VE=; b=WKadSOpLRr8FAKKQw0KQHFuPMtN3hlLcwjPG48IFZSihhKp0HI88H64hfye9aRm+8fBgWZd4EHdkc1hHPdmNvlQX0XYmh15MBCtIn4RlHDYeCr4j456OAZ3Z/JEjBHEzgq4g/kJCaYYL44bMN8n5RmdisMwhtPAqUOIiimTEYjs= 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 1665144841976373.4680328333071; Fri, 7 Oct 2022 05:14:01 -0700 (PDT) Received: from localhost ([::1]:33904 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmEq-0002w4-Jb for importer@patchew.org; Fri, 07 Oct 2022 08:14:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38242) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuS-000649-Ub for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:43506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuR-0003L5-FB for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:52 -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-625-KGPQUsIlOpmOwbxPNHxsnw-1; Fri, 07 Oct 2022 06:48:47 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D9E6101A528; Fri, 7 Oct 2022 10:48:47 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CCC72024CBB; Fri, 7 Oct 2022 10:48:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139730; 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=3Qe31bWZzB3g1O7E5Ha8N3VwT1R1GmaP1RgMnXpW+VE=; b=OjigoSQKDxBvp1eQv/QACsTaYNAZM1ZTSVhbsMckXOiFSvPSYKBy2jmFZdjaxo4gE7mWQy 0viYsbkr16pAPmu2dSXwHR8XbvLheASOiHufHaGEggECaLoBb1O/peTat2QV32C6NAUp75 ghV36/Zp0nLT+nVHdOd8tIQqMJYSJyM= X-MC-Unique: KGPQUsIlOpmOwbxPNHxsnw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 47/50] block_job_query: remove atomic read Date: Fri, 7 Oct 2022 12:47:49 +0200 Message-Id: <20221007104752.141361-48-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665144844108100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito Not sure what the atomic here was supposed to do, since job.busy is protected by the job lock. Since the whole function is called under job_mutex, just remove the atomic. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-20-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- blockjob.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blockjob.c b/blockjob.c index d04f804001..120c1b7ead 100644 --- a/blockjob.c +++ b/blockjob.c @@ -338,7 +338,7 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Err= or **errp) info =3D g_new0(BlockJobInfo, 1); info->type =3D g_strdup(job_type_str(&job->job)); info->device =3D g_strdup(job->job.id); - info->busy =3D qatomic_read(&job->job.busy); + info->busy =3D job->job.busy; info->paused =3D job->job.pause_count > 0; info->offset =3D progress_current; info->len =3D progress_total; --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665149641; cv=none; d=zohomail.com; s=zohoarc; b=cJnXjc1mP9s8jeKGc3P8+XUaBvtRn8ZY2zGd7Cu2WPxv+4sjkoR4l9rkUzCaWDIV0SfJ3TQtIu/oZ6ziWWnu5sxKX3k5gM3Vt9qrZck6gX8Oj3oRguDNLScIIF6cfriApYofpGOvRpA7K3Jlw4gkU7PZUGn+2a8CJLkpMN1nLK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665149641; 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=3tHqFxjjgYAMvT9vj/ekyEpvwe4umzhCJ5s9O8/QSjQ=; b=NgQ91Dj2OhoCdhtRH+xR2pevp1wzqVoWHM/Oa1ZZHn6d2ui05309vPPPHd9mIPTncHMDoMMJxWeB/tQ3gWPyIeWbSAPahhz/u58Yu9w6JbFa0yEf3msxK0hmaHa5K8qysFoeuP9b1a6nbqqWHSntqyzmyMwMzBWtSiGM26i0Pic= 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 16651496417721015.1943771905001; Fri, 7 Oct 2022 06:34:01 -0700 (PDT) Received: from localhost ([::1]:42680 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ognUG-0001Dz-HJ for importer@patchew.org; Fri, 07 Oct 2022 09:34:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuU-00065Y-FH for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:27263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuS-0003LW-6x for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:53 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-357-AwJyQ7esNj64Rn8A-gDmTg-1; Fri, 07 Oct 2022 06:48:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 253A11C0515C; Fri, 7 Oct 2022 10:48:48 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 643F2200C0DE; Fri, 7 Oct 2022 10:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139731; 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=3tHqFxjjgYAMvT9vj/ekyEpvwe4umzhCJ5s9O8/QSjQ=; b=HbaUHpTLz26KnoAescte5v0MJ/Lyv0zIgKKjodOB2Lb0BDvrm3btMpv+wfThuptEmTcrOY pE1p6rGBWLGbZCmLMnArjKDnL/nKVuBEBMlQV3bG6c2dDRR0tvL1FzpinTjXsY4eT/VxqF Gkewm7PjnipTYxHPT6F7Hkp82S4Kj/I= X-MC-Unique: AwJyQ7esNj64Rn8A-gDmTg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 48/50] blockjob: remove unused functions Date: Fri, 7 Oct 2022 12:47:50 +0200 Message-Id: <20221007104752.141361-49-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665149642635100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito These public functions are not used anywhere, thus can be dropped. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Reviewed-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220926093214.506243-21-eesposit@redhat.com> Signed-off-by: Kevin Wolf --- include/block/blockjob.h | 31 ++++++++++++------------------- blockjob.c | 16 ++-------------- 2 files changed, 14 insertions(+), 33 deletions(-) diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 10c24e240a..03032b2eca 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -102,17 +102,15 @@ typedef struct BlockJob { */ =20 /** - * block_job_next: + * block_job_next_locked: * @job: A block job, or %NULL. * * Get the next element from the list of block jobs after @job, or the * first one if @job is %NULL. * * Returns the requested job, or %NULL if there are no more jobs left. + * Called with job lock held. */ -BlockJob *block_job_next(BlockJob *job); - -/* Same as block_job_next(), but called with job lock held. */ BlockJob *block_job_next_locked(BlockJob *job); =20 /** @@ -122,6 +120,7 @@ BlockJob *block_job_next_locked(BlockJob *job); * Get the block job identified by @id (which must not be %NULL). * * Returns the requested job, or %NULL if it doesn't exist. + * Called with job lock *not* held. */ BlockJob *block_job_get(const char *id); =20 @@ -161,43 +160,37 @@ void block_job_remove_all_bdrv(BlockJob *job); bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs); =20 /** - * block_job_set_speed: + * block_job_set_speed_locked: * @job: The job to set the speed for. * @speed: The new value * @errp: Error object. * * Set a rate-limiting parameter for the job; the actual meaning may * vary depending on the job type. - */ -bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp); - -/* - * Same as block_job_set_speed(), but called with job lock held. - * Might release the lock temporarily. + * + * Called with job lock held, but might release it temporarily. */ bool block_job_set_speed_locked(BlockJob *job, int64_t speed, Error **errp= ); =20 /** - * block_job_query: + * block_job_query_locked: * @job: The job to get information about. * * Return information about a job. + * + * Called with job lock held. */ -BlockJobInfo *block_job_query(BlockJob *job, Error **errp); - -/* Same as block_job_query(), but called with job lock held. */ BlockJobInfo *block_job_query_locked(BlockJob *job, Error **errp); =20 /** - * block_job_iostatus_reset: + * block_job_iostatus_reset_locked: * @job: The job whose I/O status should be reset. * * Reset I/O status on @job and on BlockDriverState objects it uses, * other than job->blk. + * + * Called with job lock held. */ -void block_job_iostatus_reset(BlockJob *job); - -/* Same as block_job_iostatus_reset(), but called with job lock held. */ void block_job_iostatus_reset_locked(BlockJob *job); =20 /* diff --git a/blockjob.c b/blockjob.c index 120c1b7ead..bdf20a0e35 100644 --- a/blockjob.c +++ b/blockjob.c @@ -56,12 +56,6 @@ BlockJob *block_job_next_locked(BlockJob *bjob) return job ? container_of(job, BlockJob, job) : NULL; } =20 -BlockJob *block_job_next(BlockJob *bjob) -{ - JOB_LOCK_GUARD(); - return block_job_next_locked(bjob); -} - BlockJob *block_job_get_locked(const char *id) { Job *job =3D job_get_locked(id); @@ -308,7 +302,7 @@ bool block_job_set_speed_locked(BlockJob *job, int64_t = speed, Error **errp) return true; } =20 -bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) +static bool block_job_set_speed(BlockJob *job, int64_t speed, Error **errp) { JOB_LOCK_GUARD(); return block_job_set_speed_locked(job, speed, errp); @@ -357,12 +351,6 @@ BlockJobInfo *block_job_query_locked(BlockJob *job, Er= ror **errp) return info; } =20 -BlockJobInfo *block_job_query(BlockJob *job, Error **errp) -{ - JOB_LOCK_GUARD(); - return block_job_query_locked(job, errp); -} - /* Called with job lock held */ static void block_job_iostatus_set_err_locked(BlockJob *job, int error) { @@ -525,7 +513,7 @@ void block_job_iostatus_reset_locked(BlockJob *job) job->iostatus =3D BLOCK_DEVICE_IO_STATUS_OK; } =20 -void block_job_iostatus_reset(BlockJob *job) +static void block_job_iostatus_reset(BlockJob *job) { JOB_LOCK_GUARD(); block_job_iostatus_reset_locked(job); --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665149089; cv=none; d=zohomail.com; s=zohoarc; b=TOXNfCBFlB05BBQX9Mkle1VvNCFALT+9Xr9gP2xTdrrxhAHZi8PByasU2Y0KjPrXgHeCb+Fmo07a+OkA+A39GztI/y18n7aG0DsLdv6I/r7ZDbBQNULtFZRfOG268YH98yNiWo50S5MHBIYOsYxNvvN7yd9mTCGMwIMSYJtuOlg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665149089; 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=BPjqDBQAGVNVJZCOf2BviyXXO0kmdhohAGrGjSFZqf0=; b=cbHx6B0CnH5S8PuVye1zeg5wx7k81FBjVpLDW2MMfBVFriXjOINwTkyN0GigqEJXSNzZ+q5u2DyQAc9SgBdatk6f/MuSfJj0c8+fxRKQoMqwS48zs1xTfienuPY9mMRSlA3ZSJAdZWRAxNg5nf0ZnGkVG4i/dHO0xMzWJS/Qds8= 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 1665149089585531.4478879505522; Fri, 7 Oct 2022 06:24:49 -0700 (PDT) Received: from localhost ([::1]:34146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ognLK-0001j7-Mk for importer@patchew.org; Fri, 07 Oct 2022 09:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuT-00065W-Vn for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24048) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuR-0003L7-EQ for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:53 -0400 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-644-L4SKyD9eOzamz1TILOcXBA-1; Fri, 07 Oct 2022 06:48:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 283DF1C0515C; Fri, 7 Oct 2022 10:48:49 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 60C08200BC6D; Fri, 7 Oct 2022 10:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139730; 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=BPjqDBQAGVNVJZCOf2BviyXXO0kmdhohAGrGjSFZqf0=; b=IV8Iz/ncENvPhjpw1ylcuTk5td6LgxiRY3KaLd12e4Oa6jIHRcEhlIq2LPjRIh7gxK57ey IX5U0Fw2dPbA20X4D93NZW1SsyT1ZCu6OJWl1aoNL8jldcmTxo5NyTxHq1KwQGdaMfVPOs 4G3xWMZNaUnXV4bIKkwoGuMjD8GLh/0= X-MC-Unique: L4SKyD9eOzamz1TILOcXBA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 49/50] job: remove unused functions Date: Fri, 7 Oct 2022 12:47:51 +0200 Message-Id: <20221007104752.141361-50-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665149091228100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito These public functions are not used anywhere, thus can be dropped. Also, since this is the final job API that doesn't use AioContext lock and replaces it with job_lock, adjust all remaining function documentation to clearly specify if the job lock is taken or not. Also document the locking requirements for a few functions where the second version is not removed. Signed-off-by: Emanuele Giuseppe Esposito Reviewed-by: Stefan Hajnoczi Reviewed-by: Kevin Wolf Message-Id: <20220926093214.506243-22-eesposit@redhat.com> Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- include/qemu/job.h | 110 +++++++++++++------------------------ job.c | 107 ++---------------------------------- tests/unit/test-blockjob.c | 4 +- 3 files changed, 46 insertions(+), 175 deletions(-) diff --git a/include/qemu/job.h b/include/qemu/job.h index a54fb83887..e502787dd8 100644 --- a/include/qemu/job.h +++ b/include/qemu/job.h @@ -384,6 +384,8 @@ JobTxn *job_txn_new(void); /** * Release a reference that was previously acquired with job_txn_add_job or * job_txn_new. If it's the last reference to the object, it will be freed. + * + * Called with job lock *not* held. */ void job_txn_unref(JobTxn *txn); =20 @@ -413,21 +415,18 @@ void *job_create(const char *job_id, const JobDriver = *driver, JobTxn *txn, /** * Add a reference to Job refcnt, it will be decreased with job_unref, and= then * be freed if it comes to be the last reference. + * + * Called with job lock held. */ -void job_ref(Job *job); - -/* Same as job_ref(), but called with job lock held. */ void job_ref_locked(Job *job); =20 /** - * Release a reference that was previously acquired with job_ref() or + * Release a reference that was previously acquired with job_ref_locked() = or * job_create(). If it's the last reference to the object, it will be free= d. * * Takes AioContext lock internally to invoke a job->driver callback. + * Called with job lock held. */ -void job_unref(Job *job); - -/* Same as job_unref(), but called with job lock held. */ void job_unref_locked(Job *job); =20 /** @@ -473,12 +472,8 @@ void job_progress_increase_remaining(Job *job, uint64_= t delta); * Conditionally enter the job coroutine if the job is ready to run, not * already busy and fn() returns true. fn() is called while under the job_= lock * critical section. - */ -void job_enter_cond(Job *job, bool(*fn)(Job *job)); - -/* - * Same as job_enter_cond(), but called with job lock held. - * Might release the lock temporarily. + * + * Called with job lock held, but might release it temporarily. */ void job_enter_cond_locked(Job *job, bool(*fn)(Job *job)); =20 @@ -557,11 +552,8 @@ bool job_cancel_requested(Job *job); =20 /** * Returns whether the job is in a completed state. - * Called with job_mutex *not* held. + * Called with job lock held. */ -bool job_is_completed(Job *job); - -/* Same as job_is_completed(), but called with job lock held. */ bool job_is_completed_locked(Job *job); =20 /** @@ -576,14 +568,16 @@ bool job_is_ready_locked(Job *job); /** * Request @job to pause at the next pause point. Must be paired with * job_resume(). If the job is supposed to be resumed by user action, call - * job_user_pause() instead. + * job_user_pause_locked() instead. + * + * Called with job lock *not* held. */ void job_pause(Job *job); =20 /* Same as job_pause(), but called with job lock held. */ void job_pause_locked(Job *job); =20 -/** Resumes a @job paused with job_pause. */ +/** Resumes a @job paused with job_pause. Called with job lock *not* held.= */ void job_resume(Job *job); =20 /* @@ -595,27 +589,20 @@ void job_resume_locked(Job *job); /** * Asynchronously pause the specified @job. * Do not allow a resume until a matching call to job_user_resume. + * Called with job lock held. */ -void job_user_pause(Job *job, Error **errp); - -/* Same as job_user_pause(), but called with job lock held. */ void job_user_pause_locked(Job *job, Error **errp); =20 -/** Returns true if the job is user-paused. */ -bool job_user_paused(Job *job); - -/* Same as job_user_paused(), but called with job lock held. */ +/** + * Returns true if the job is user-paused. + * Called with job lock held. + */ bool job_user_paused_locked(Job *job); =20 /** * Resume the specified @job. - * Must be paired with a preceding job_user_pause. - */ -void job_user_resume(Job *job, Error **errp); - -/* - * Same as job_user_resume(), but called with job lock held. - * Might release the lock temporarily. + * Must be paired with a preceding job_user_pause_locked. + * Called with job lock held, but might release it temporarily. */ void job_user_resume_locked(Job *job, Error **errp); =20 @@ -624,6 +611,7 @@ void job_user_resume_locked(Job *job, Error **errp); * first one if @job is %NULL. * * Returns the requested job, or %NULL if there are no more jobs left. + * Called with job lock *not* held. */ Job *job_next(Job *job); =20 @@ -634,20 +622,17 @@ Job *job_next_locked(Job *job); * Get the job identified by @id (which must not be %NULL). * * Returns the requested job, or %NULL if it doesn't exist. + * Called with job lock held. */ -Job *job_get(const char *id); - -/* Same as job_get(), but called with job lock held. */ Job *job_get_locked(const char *id); =20 /** * Check whether the verb @verb can be applied to @job in its current stat= e. * Returns 0 if the verb can be applied; otherwise errp is set and -EPERM * returned. + * + * Called with job lock held. */ -int job_apply_verb(Job *job, JobVerb verb, Error **errp); - -/* Same as job_apply_verb, but called with job lock held. */ int job_apply_verb_locked(Job *job, JobVerb verb, Error **errp); =20 /** @@ -662,31 +647,24 @@ void job_early_fail(Job *job); */ void job_transition_to_ready(Job *job); =20 -/** Asynchronously complete the specified @job. */ -void job_complete(Job *job, Error **errp); - -/* - * Same as job_complete(), but called with job lock held. - * Might release the lock temporarily. +/** + * Asynchronously complete the specified @job. + * Called with job lock held, but might release it temporarily. */ void job_complete_locked(Job *job, Error **errp); =20 /** * Asynchronously cancel the specified @job. If @force is true, the job sh= ould * be cancelled immediately without waiting for a consistent state. + * Called with job lock held. */ -void job_cancel(Job *job, bool force); - -/* Same as job_cancel(), but called with job lock held. */ void job_cancel_locked(Job *job, bool force); =20 /** - * Cancels the specified job like job_cancel(), but may refuse to do so if= the - * operation isn't meaningful in the current state of the job. + * Cancels the specified job like job_cancel_locked(), but may refuse + * to do so if the operation isn't meaningful in the current state of the = job. + * Called with job lock held. */ -void job_user_cancel(Job *job, bool force, Error **errp); - -/* Same as job_user_cancel(), but called with job lock held. */ void job_user_cancel_locked(Job *job, bool force, Error **errp); =20 /** @@ -714,7 +692,7 @@ void job_cancel_sync_all(void); =20 /** * @job: The job to be completed. - * @errp: Error object which may be set by job_complete(); this is not + * @errp: Error object which may be set by job_complete_locked(); this is = not * necessarily set on every error, the job return value has to be * checked as well. * @@ -723,11 +701,8 @@ void job_cancel_sync_all(void); * function). * * Returns the return value from the job. - * Called with job_lock *not* held. + * Called with job_lock held. */ -int job_complete_sync(Job *job, Error **errp); - -/* Same as job_complete_sync, but called with job lock held. */ int job_complete_sync_locked(Job *job, Error **errp); =20 /** @@ -737,19 +712,17 @@ int job_complete_sync_locked(Job *job, Error **errp); * FIXME: Make the below statement universally true: * For jobs that support the manual workflow mode, all graph changes that = occur * as a result will occur after this command and before a successful reply. + * + * Called with job lock held. */ -void job_finalize(Job *job, Error **errp); - -/* Same as job_finalize(), but called with job lock held. */ void job_finalize_locked(Job *job, Error **errp); =20 /** * Remove the concluded @job from the query list and resets the passed poi= nter * to %NULL. Returns an error if the job is not actually concluded. + * + * Called with job lock held. */ -void job_dismiss(Job **job, Error **errp); - -/* Same as job_dismiss(), but called with job lock held. */ void job_dismiss_locked(Job **job, Error **errp); =20 /** @@ -759,14 +732,7 @@ void job_dismiss_locked(Job **job, Error **errp); * Returns 0 if the job is successfully completed, -ECANCELED if the job w= as * cancelled before completing, and -errno in other error cases. * - * Called with job_lock *not* held. - */ -int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), - Error **errp); - -/* - * Same as job_finish_sync(), but called with job lock held. - * Might release the lock temporarily. + * Called with job_lock held, but might release it temporarily. */ int job_finish_sync_locked(Job *job, void (*finish)(Job *, Error **errp), Error **errp); diff --git a/job.c b/job.c index 76c6d7f79d..78feae05fb 100644 --- a/job.c +++ b/job.c @@ -233,12 +233,6 @@ int job_apply_verb_locked(Job *job, JobVerb verb, Erro= r **errp) return -EPERM; } =20 -int job_apply_verb(Job *job, JobVerb verb, Error **errp) -{ - JOB_LOCK_GUARD(); - return job_apply_verb_locked(job, verb, errp); -} - JobType job_type(const Job *job) { return job->driver->job_type; @@ -324,7 +318,7 @@ bool job_is_completed_locked(Job *job) return false; } =20 -bool job_is_completed(Job *job) +static bool job_is_completed(Job *job) { JOB_LOCK_GUARD(); return job_is_completed_locked(job); @@ -368,12 +362,6 @@ Job *job_get_locked(const char *id) return NULL; } =20 -Job *job_get(const char *id) -{ - JOB_LOCK_GUARD(); - return job_get_locked(id); -} - void job_set_aio_context(Job *job, AioContext *ctx) { /* protect against read in job_finish_sync_locked and job_start */ @@ -465,12 +453,6 @@ void job_ref_locked(Job *job) ++job->refcnt; } =20 -void job_ref(Job *job) -{ - JOB_LOCK_GUARD(); - job_ref_locked(job); -} - void job_unref_locked(Job *job) { GLOBAL_STATE_CODE(); @@ -499,12 +481,6 @@ void job_unref_locked(Job *job) } } =20 -void job_unref(Job *job) -{ - JOB_LOCK_GUARD(); - job_unref_locked(job); -} - void job_progress_update(Job *job, uint64_t done) { progress_work_done(&job->progress, done); @@ -581,12 +557,6 @@ void job_enter_cond_locked(Job *job, bool(*fn)(Job *jo= b)) job_lock(); } =20 -void job_enter_cond(Job *job, bool(*fn)(Job *job)) -{ - JOB_LOCK_GUARD(); - job_enter_cond_locked(job, fn); -} - void job_enter(Job *job) { JOB_LOCK_GUARD(); @@ -674,8 +644,9 @@ void coroutine_fn job_pause_point(Job *job) job_pause_point_locked(job); } =20 -static void coroutine_fn job_yield_locked(Job *job) +void coroutine_fn job_yield(Job *job) { + JOB_LOCK_GUARD(); assert(job->busy); =20 /* Check cancellation *before* setting busy =3D false, too! */ @@ -690,12 +661,6 @@ static void coroutine_fn job_yield_locked(Job *job) job_pause_point_locked(job); } =20 -void coroutine_fn job_yield(Job *job) -{ - JOB_LOCK_GUARD(); - job_yield_locked(job); -} - void coroutine_fn job_sleep_ns(Job *job, int64_t ns) { JOB_LOCK_GUARD(); @@ -764,23 +729,11 @@ void job_user_pause_locked(Job *job, Error **errp) job_pause_locked(job); } =20 -void job_user_pause(Job *job, Error **errp) -{ - JOB_LOCK_GUARD(); - job_user_pause_locked(job, errp); -} - bool job_user_paused_locked(Job *job) { return job->user_paused; } =20 -bool job_user_paused(Job *job) -{ - JOB_LOCK_GUARD(); - return job_user_paused_locked(job); -} - void job_user_resume_locked(Job *job, Error **errp) { assert(job); @@ -801,12 +754,6 @@ void job_user_resume_locked(Job *job, Error **errp) job_resume_locked(job); } =20 -void job_user_resume(Job *job, Error **errp) -{ - JOB_LOCK_GUARD(); - job_user_resume_locked(job, errp); -} - /* Called with job_mutex held, but releases it temporarily. */ static void job_do_dismiss_locked(Job *job) { @@ -834,12 +781,6 @@ void job_dismiss_locked(Job **jobptr, Error **errp) *jobptr =3D NULL; } =20 -void job_dismiss(Job **jobptr, Error **errp) -{ - JOB_LOCK_GUARD(); - job_dismiss_locked(jobptr, errp); -} - void job_early_fail(Job *job) { JOB_LOCK_GUARD(); @@ -1084,12 +1025,6 @@ void job_finalize_locked(Job *job, Error **errp) job_do_finalize_locked(job); } =20 -void job_finalize(Job *job, Error **errp) -{ - JOB_LOCK_GUARD(); - job_finalize_locked(job, errp); -} - /* Called with job_mutex held. */ static int job_transition_to_pending_locked(Job *job) { @@ -1236,12 +1171,6 @@ void job_cancel_locked(Job *job, bool force) } } =20 -void job_cancel(Job *job, bool force) -{ - JOB_LOCK_GUARD(); - job_cancel_locked(job, force); -} - void job_user_cancel_locked(Job *job, bool force, Error **errp) { if (job_apply_verb_locked(job, JOB_VERB_CANCEL, errp)) { @@ -1250,15 +1179,9 @@ void job_user_cancel_locked(Job *job, bool force, Er= ror **errp) job_cancel_locked(job, force); } =20 -void job_user_cancel(Job *job, bool force, Error **errp) -{ - JOB_LOCK_GUARD(); - job_user_cancel_locked(job, force, errp); -} - -/* A wrapper around job_cancel() taking an Error ** parameter so it may be - * used with job_finish_sync() without the need for (rather nasty) function - * pointer casts there. +/* A wrapper around job_cancel_locked() taking an Error ** parameter so it= may + * be used with job_finish_sync_locked() without the need for (rather nast= y) + * function pointer casts there. * * Called with job_mutex held. */ @@ -1306,12 +1229,6 @@ int job_complete_sync_locked(Job *job, Error **errp) return job_finish_sync_locked(job, job_complete_locked, errp); } =20 -int job_complete_sync(Job *job, Error **errp) -{ - JOB_LOCK_GUARD(); - return job_complete_sync_locked(job, errp); -} - void job_complete_locked(Job *job, Error **errp) { /* Should not be reachable via external interface for internal jobs */ @@ -1331,12 +1248,6 @@ void job_complete_locked(Job *job, Error **errp) job_lock(); } =20 -void job_complete(Job *job, Error **errp) -{ - JOB_LOCK_GUARD(); - job_complete_locked(job, errp); -} - int job_finish_sync_locked(Job *job, void (*finish)(Job *, Error **errp), Error **errp) @@ -1366,9 +1277,3 @@ int job_finish_sync_locked(Job *job, job_unref_locked(job); return ret; } - -int job_finish_sync(Job *job, void (*finish)(Job *, Error **errp), Error *= *errp) -{ - JOB_LOCK_GUARD(); - return job_finish_sync_locked(job, finish, errp); -} diff --git a/tests/unit/test-blockjob.c b/tests/unit/test-blockjob.c index f88e10e356..c0426bd10c 100644 --- a/tests/unit/test-blockjob.c +++ b/tests/unit/test-blockjob.c @@ -432,7 +432,7 @@ static const BlockJobDriver test_yielding_driver =3D { }; =20 /* - * Test that job_complete() works even on jobs that are in a paused + * Test that job_complete_locked() works even on jobs that are in a paused * state (i.e., STANDBY). * * To do this, run YieldingJob in an IO thread, get it into the READY @@ -440,7 +440,7 @@ static const BlockJobDriver test_yielding_driver =3D { * acquire the context so the job will not be entered and will thus * remain on STANDBY. * - * job_complete() should still work without error. + * job_complete_locked() should still work without error. * * Note that on the QMP interface, it is impossible to lock an IO * thread before a drained section ends. In practice, the --=20 2.37.3 From nobody Fri Apr 11 22:47:16 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=1665145536; cv=none; d=zohomail.com; s=zohoarc; b=NXUh/bRpQzlso7YmA9L4rt412WtFcANmrURbuvf+eaSptNmzwPCfMWH6u2ZVnh4Qe/wEKJbMym3ezny/7a3PK+G/3jr0kHfneoAk6DWmI7/v6TZVOkhhI6hKB9diZQF6t0UqcJzL9boo1QYWhCbacranGgIyW6ITAKNPcUvETEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1665145536; 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=nCbxNZFOXn0xQq9rHwPRyECSDQTke15H3NzZPZlYns0=; b=RJ6X9zPiYPMPzPMvAcgRmL6j/jUEK5je9/R8uLTkHwxvz42zKJewsY3FT14jxwAwEz1Aog4UY+ZO/Of8Zi8YYA2wFAuw9flKk72MnFdVqgJGaVt7S5CrKjMRSTO7prRf3FMCq3M/JQKUNuoikfjEsfDWAu5MK4re8HyIhJJxagw= 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 1665145536770749.5244459846423; Fri, 7 Oct 2022 05:25:36 -0700 (PDT) Received: from localhost ([::1]:49212 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ogmQ3-0001Cz-P1 for importer@patchew.org; Fri, 07 Oct 2022 08:25:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuT-00065D-Dj for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59147) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ogkuR-0003LP-Vg for qemu-devel@nongnu.org; Fri, 07 Oct 2022 06:48:53 -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-606-Uykhbyo3NnK5gpYBKiWnOQ-1; Fri, 07 Oct 2022 06:48:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2335680206D; Fri, 7 Oct 2022 10:48:50 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.192.109]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6240E2024CBB; Fri, 7 Oct 2022 10:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1665139731; 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=nCbxNZFOXn0xQq9rHwPRyECSDQTke15H3NzZPZlYns0=; b=SJDMUQOVRyJGNnDlW2SIYJacKykG+SXMlgM9k7IvUadpJvS+RZHQaD65MIhUWO0n8k3nXM R501Y8vacFxZHKtdUzH6YRot1jkdd+SI3Hr5n07QPU6ITwnk8byqDkG9J3zL2eaYsUS50d Hx50wVO3RIdAEFaa+kqUee7bFQsU+GI= X-MC-Unique: Uykhbyo3NnK5gpYBKiWnOQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org Subject: [PULL 50/50] file-posix: Remove unused s->discard_zeroes Date: Fri, 7 Oct 2022 12:47:52 +0200 Message-Id: <20221007104752.141361-51-kwolf@redhat.com> In-Reply-To: <20221007104752.141361-1-kwolf@redhat.com> References: <20221007104752.141361-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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.133.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1665145538327100001 Content-Type: text/plain; charset="utf-8" The field is unused (only ever set, but never read) since commit ac9185603. Additionally, the commit message of commit 34fa110e already explained earlier why it's unreliable. Remove it. Signed-off-by: Kevin Wolf Message-Id: <20220923142838.91043-1-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/file-posix.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/block/file-posix.c b/block/file-posix.c index ad3021938b..23acffb9a4 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -154,7 +154,6 @@ typedef struct BDRVRawState { =20 bool has_discard:1; bool has_write_zeroes:1; - bool discard_zeroes:1; bool use_linux_aio:1; bool use_linux_io_uring:1; int page_cache_inconsistent; /* errno from fdatasync failure */ @@ -755,7 +754,6 @@ static int raw_open_common(BlockDriverState *bs, QDict = *options, ret =3D -EINVAL; goto fail; } else { - s->discard_zeroes =3D true; s->has_fallocate =3D true; } } else { @@ -769,19 +767,12 @@ static int raw_open_common(BlockDriverState *bs, QDic= t *options, } =20 if (S_ISBLK(st.st_mode)) { -#ifdef BLKDISCARDZEROES - unsigned int arg; - if (ioctl(s->fd, BLKDISCARDZEROES, &arg) =3D=3D 0 && arg) { - s->discard_zeroes =3D true; - } -#endif #ifdef __linux__ /* On Linux 3.10, BLKDISCARD leaves stale data in the page cache. = Do * not rely on the contents of discarded blocks unless using O_DIR= ECT. * Same for BLKZEROOUT. */ if (!(bs->open_flags & BDRV_O_NOCACHE)) { - s->discard_zeroes =3D false; s->has_write_zeroes =3D false; } #endif --=20 2.37.3