From nobody Mon May 20 20:10:12 2024 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=1683721456; cv=none; d=zohomail.com; s=zohoarc; b=mkcvQO9LfDGmCTGc+LdUa1NFnNgB61wLkF9oi+DjL/DOq8pACXZGEu7DNSvH2Yk0dsn4y/8/XKQ04uhTOuS8iduPqkYHUdNMFQkqjphcnIPeAanmhV81TBK5E+UTh2sSyEIcwaDzl4/sHLBKXgsckN6CLP3k4IdA44dta/rYqYA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721456; 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=4XhrI/hBklLNCRzyxYw9XXqOEC8GBhPMNojClKhNsHU=; b=lmdp+Bx75zYqyhj/EGCu4itYP0qDBef1BAmZDGx87A8ETW+JrWOtAXEYCuZLAjqdYTYzeXg2rY6dStmqw59JayrChFU5SwDaH2fxCtCTLZGdSygtd/TeOAq7ym5i5MKLdPD6AQ7f/maiQ7CQe23dBOHOWjT1Ab1VIsPcxX3bl54= 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 1683721456458134.59908772678546; Wed, 10 May 2023 05:24:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipK-000296-H4; Wed, 10 May 2023 08:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipI-00027u-7a for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipC-0007dP-Hc for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21: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-288-gNm6pp6tN62q14pQDkUopg-1; Wed, 10 May 2023 08:21:37 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86787867956; Wed, 10 May 2023 12:21:37 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C756F18EC1; Wed, 10 May 2023 12:21:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721301; 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=4XhrI/hBklLNCRzyxYw9XXqOEC8GBhPMNojClKhNsHU=; b=cqCC/YPC4KmXZsABSTpZqLuF1gYbyt/bBnUxmh1ht4WQde/LLswdOtCqwG1W+poRU/LXUe B2lnMveH4AgVoUHuwcX0UlZ4nmevxqSdCqCXpzaHqvmLtRDHvIJ83nujUyKI39aW/v+pud ys8YkTqWYUQhI75JAgf7RovvuU7K/90= X-MC-Unique: gNm6pp6tN62q14pQDkUopg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 01/28] block: add configure options for excluding vmdk, vhdx and vpc Date: Wed, 10 May 2023 14:20:44 +0200 Message-Id: <20230510122111.46566-2-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721457670100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Let's add --enable / --disable configure options for these formats, so that those who don't need them may not build them. Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20230421092758.814122-1-vsementsov@yandex-team.ru> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- meson_options.txt | 6 ++++++ block/meson.build | 18 +++++++++++++----- meson.build | 3 +++ scripts/meson-buildoptions.sh | 9 +++++++++ 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/meson_options.txt b/meson_options.txt index ae2017702a..66ca350029 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -301,6 +301,12 @@ option('qcow1', type: 'feature', value: 'auto', description: 'qcow1 image format support') option('vdi', type: 'feature', value: 'auto', description: 'vdi image format support') +option('vhdx', type: 'feature', value: 'auto', + description: 'vhdx image format support') +option('vmdk', type: 'feature', value: 'auto', + description: 'vmdk image format support') +option('vpc', type: 'feature', value: 'auto', + description: 'vpc image format support') option('vvfat', type: 'feature', value: 'auto', description: 'vvfat image format support') option('qed', type: 'feature', value: 'auto', diff --git a/block/meson.build b/block/meson.build index 382bec0e7d..13337bd070 100644 --- a/block/meson.build +++ b/block/meson.build @@ -38,11 +38,6 @@ block_ss.add(files( 'snapshot-access.c', 'throttle-groups.c', 'throttle.c', - 'vhdx-endian.c', - 'vhdx-log.c', - 'vhdx.c', - 'vmdk.c', - 'vpc.c', 'write-threshold.c', ), zstd, zlib, gnutls) =20 @@ -55,6 +50,19 @@ endif if get_option('vdi').allowed() block_ss.add(files('vdi.c')) endif +if get_option('vhdx').allowed() + block_ss.add(files( + 'vhdx-endian.c', + 'vhdx-log.c', + 'vhdx.c' + )) +endif +if get_option('vmdk').allowed() + block_ss.add(files('vmdk.c')) +endif +if get_option('vpc').allowed() + block_ss.add(files('vpc.c')) +endif if get_option('cloop').allowed() block_ss.add(files('cloop.c')) endif diff --git a/meson.build b/meson.build index 27782f8f52..c56e0fec9e 100644 --- a/meson.build +++ b/meson.build @@ -3929,6 +3929,9 @@ if have_block summary_info +=3D {'dmg support': get_option('dmg').allowed()} summary_info +=3D {'qcow v1 support': get_option('qcow1').allowed()} summary_info +=3D {'vdi support': get_option('vdi').allowed()} + summary_info +=3D {'vhdx support': get_option('vhdx').allowed()} + summary_info +=3D {'vmdk support': get_option('vmdk').allowed()} + summary_info +=3D {'vpc support': get_option('vpc').allowed()} summary_info +=3D {'vvfat support': get_option('vvfat').allowed()} summary_info +=3D {'qed support': get_option('qed').allowed()} summary_info +=3D {'parallels support': get_option('parallels').allowed(= )} diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 0e888e6ecd..34d82dec53 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -169,6 +169,7 @@ meson_options_help() { printf "%s\n" ' VDUSE block export support' printf "%s\n" ' vfio-user-server' printf "%s\n" ' vfio-user server support' + printf "%s\n" ' vhdx vhdx image format support' printf "%s\n" ' vhost-crypto vhost-user crypto backend support' printf "%s\n" ' vhost-kernel vhost kernel backend support' printf "%s\n" ' vhost-net vhost-net kernel acceleration support' @@ -178,10 +179,12 @@ meson_options_help() { printf "%s\n" ' vhost-vdpa vhost-vdpa kernel backend support' printf "%s\n" ' virglrenderer virgl rendering support' printf "%s\n" ' virtfs virtio-9p support' + printf "%s\n" ' vmdk vmdk image format support' printf "%s\n" ' vmnet vmnet.framework network backend support' printf "%s\n" ' vnc VNC server' printf "%s\n" ' vnc-jpeg JPEG lossy compression for VNC server' printf "%s\n" ' vnc-sasl SASL authentication for VNC server' + printf "%s\n" ' vpc vpc image format support' printf "%s\n" ' vte vte support for the gtk UI' printf "%s\n" ' vvfat vvfat image format support' printf "%s\n" ' whpx WHPX acceleration support' @@ -449,6 +452,8 @@ _meson_option_parse() { --disable-vduse-blk-export) printf "%s" -Dvduse_blk_export=3Ddisabled = ;; --enable-vfio-user-server) printf "%s" -Dvfio_user_server=3Denabled ;; --disable-vfio-user-server) printf "%s" -Dvfio_user_server=3Ddisabled = ;; + --enable-vhdx) printf "%s" -Dvhdx=3Denabled ;; + --disable-vhdx) printf "%s" -Dvhdx=3Ddisabled ;; --enable-vhost-crypto) printf "%s" -Dvhost_crypto=3Denabled ;; --disable-vhost-crypto) printf "%s" -Dvhost_crypto=3Ddisabled ;; --enable-vhost-kernel) printf "%s" -Dvhost_kernel=3Denabled ;; @@ -465,6 +470,8 @@ _meson_option_parse() { --disable-virglrenderer) printf "%s" -Dvirglrenderer=3Ddisabled ;; --enable-virtfs) printf "%s" -Dvirtfs=3Denabled ;; --disable-virtfs) printf "%s" -Dvirtfs=3Ddisabled ;; + --enable-vmdk) printf "%s" -Dvmdk=3Denabled ;; + --disable-vmdk) printf "%s" -Dvmdk=3Ddisabled ;; --enable-vmnet) printf "%s" -Dvmnet=3Denabled ;; --disable-vmnet) printf "%s" -Dvmnet=3Ddisabled ;; --enable-vnc) printf "%s" -Dvnc=3Denabled ;; @@ -473,6 +480,8 @@ _meson_option_parse() { --disable-vnc-jpeg) printf "%s" -Dvnc_jpeg=3Ddisabled ;; --enable-vnc-sasl) printf "%s" -Dvnc_sasl=3Denabled ;; --disable-vnc-sasl) printf "%s" -Dvnc_sasl=3Ddisabled ;; + --enable-vpc) printf "%s" -Dvpc=3Denabled ;; + --disable-vpc) printf "%s" -Dvpc=3Ddisabled ;; --enable-vte) printf "%s" -Dvte=3Denabled ;; --disable-vte) printf "%s" -Dvte=3Ddisabled ;; --enable-vvfat) printf "%s" -Dvvfat=3Denabled ;; --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721464; cv=none; d=zohomail.com; s=zohoarc; b=Vm53bJO6S12LPGKbHwUv6QOa8H1Eh14rhN0iuS5W/VBJC739I3Kf13GeJ/86CioSFnemBz7Nwp09FC1uFo4g0YFEt2jhCi5JVN+PjqaJcxZ2kZj8elA6Gsi/Tp+IuThDktpT/5jKH8SeV4OP+4avzAdvYzo2zQYutGgKUlcpmhg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721464; 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=JcRNvZSPnrgA8YiicWbaOcxWwhN1YUXNnWyb8q0QHvM=; b=MetPYPraZ+jowhxRPFiX16en2ks1DfvdC1Ty/U2G6OgfeR5DiU1qvBZvVvW2/jZMEhwF0n6zn353hCgHo338nJf2eCkvuHkVYmyffKibpEfWXxhT1W0dO8cpqvgMLbVv04BfQ7fb9lobL4f7wR3y+BCTh3OFJWQY5+JogvX/uCM= 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 1683721464194584.0430362913804; Wed, 10 May 2023 05:24:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipK-00029F-IJ; Wed, 10 May 2023 08:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipH-00026w-NS for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipC-0007de-SK for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:47 -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-117-K-JtKfxaNnOb3pGS4142Ng-1; Wed, 10 May 2023 08:21:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8E4411C087AB; Wed, 10 May 2023 12:21:38 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CAF3918EC1; Wed, 10 May 2023 12:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721302; 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=JcRNvZSPnrgA8YiicWbaOcxWwhN1YUXNnWyb8q0QHvM=; b=GEVxdlXIq2iatPzqaHbf+v9d1zPKKrc8cyOAI5TnbrRxXyBaOKaNJ39K9jKzWtiNlkAopg DbWfBzhncw6oLoagmqXFHYF+RxhNYgqK+cvk4Yk5ktgTiMRJktplDEUIUM/0eZCXrPvXWW uheLUFdaSselClcbQ+m0SB6H+cYwkHU= X-MC-Unique: K-JtKfxaNnOb3pGS4142Ng-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 02/28] block: add missing coroutine_fn annotations Date: Wed, 10 May 2023 14:20:45 +0200 Message-Id: <20230510122111.46566-3-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721466154100009 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini After the recent introduction of many new coroutine callbacks, a couple calls from non-coroutine_fn to coroutine_fn have sneaked in; fix them. Signed-off-by: Paolo Bonzini Message-Id: <20230406101752.242125-1-pbonzini@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/graph-lock.h | 4 ++-- block/mirror.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h index 18cc14de22..ac0fef8605 100644 --- a/include/block/graph-lock.h +++ b/include/block/graph-lock.h @@ -208,14 +208,14 @@ typedef struct GraphLockable { } GraphLockable; * unlocked. TSA_ASSERT() makes sure that the following calls know that we * hold the lock while unlocking is left unchecked. */ -static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA +static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA coroutine_= fn graph_lockable_auto_lock(GraphLockable *x) { bdrv_graph_co_rdlock(); return x; } =20 -static inline void TSA_NO_TSA +static inline void TSA_NO_TSA coroutine_fn graph_lockable_auto_unlock(GraphLockable *x) { bdrv_graph_co_rdunlock(); diff --git a/block/mirror.c b/block/mirror.c index af9bbd23d4..80fa345071 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -270,8 +270,8 @@ static inline int64_t mirror_clip_bytes(MirrorBlockJob = *s, =20 /* Round offset and/or bytes to target cluster if COW is needed, and * return the offset of the adjusted tail against original. */ -static int mirror_cow_align(MirrorBlockJob *s, int64_t *offset, - uint64_t *bytes) +static int coroutine_fn mirror_cow_align(MirrorBlockJob *s, int64_t *offse= t, + uint64_t *bytes) { bool need_cow; int ret =3D 0; --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721373; cv=none; d=zohomail.com; s=zohoarc; b=mzN4xNe7Heug2qCwSFyqYVn/w9QN2wvLfMlhNTJxkZQR2ZyZZO7fQWQgfL6v8H1Aw+ZiP8/OLtM35dvIYW7GZXN3sPYfEijZQTGDrez4JqIyPIeogkG4196shCuioAhgouRDkW1bxgcHcgYlIrHTT45wKf6AG/2eMtKqkZjZ0tc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721373; 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=vNE3CJeOLQVWGF1AGDrraNJimEbx96RxU0HYWENLISw=; b=MDnAQj8Esub+6SIkg8i465zdHiJJfG4QbzhSsHaf3uEn4w5LhkR7r93xOOc++Nwuw3YrlxBjsXT+TjdZu7KnJQkp/VYbZ7x+Qb5JTvzhxVRuFKFBGHqIOmPsNoaPmN3Wa+/lSoOKdlHMVI+9QNjXxKu7WclLYl1hs001bwSt9kE= 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 1683721373931707.9832301533941; Wed, 10 May 2023 05:22:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipS-0002J2-3Y; Wed, 10 May 2023 08:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipJ-00028m-0s for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipD-0007do-RF for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:48 -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-505-xKwbkq9cNEqsgamw35O5qQ-1; Wed, 10 May 2023 08:21:39 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 817C0100F651; Wed, 10 May 2023 12:21:39 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C555518EC1; Wed, 10 May 2023 12:21:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721303; 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=vNE3CJeOLQVWGF1AGDrraNJimEbx96RxU0HYWENLISw=; b=dOpu3J+aGmcRUtgT3UcFkqQFL1Pv8+CXJIl665Hydy0GN2m+Jjdm2axTEKb6GVjZbG2BdN DGMaxLGSW5ZQ2Ww+tYEVmQSZ+PsmQ4X/M5pvUzqZz6jWfddNs22Ts3dfGXROAxwrrnuKHE /4GBguWVVzrdFP6caIIZ6mFUjCaxZO4= X-MC-Unique: xKwbkq9cNEqsgamw35O5qQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 03/28] aio-wait: avoid AioContext lock in aio_wait_bh_oneshot() Date: Wed, 10 May 2023 14:20:46 +0200 Message-Id: <20230510122111.46566-4-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721374466100001 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi There is no need for the AioContext lock in aio_wait_bh_oneshot(). It's easy to remove the lock from existing callers and then switch from AIO_WAIT_WHILE() to AIO_WAIT_WHILE_UNLOCKED() in aio_wait_bh_oneshot(). Document that the AioContext lock should not be held across aio_wait_bh_oneshot(). Holding a lock across aio_poll() can cause deadlock so we don't want callers to do that. This is a step towards getting rid of the AioContext lock. Cc: Paolo Bonzini Signed-off-by: Stefan Hajnoczi Message-Id: <20230404153307.458883-1-stefanha@redhat.com> Reviewed-by: Paolo Bonzini Reviewed-by: Emanuele Giuseppe Esposito Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- include/block/aio-wait.h | 2 +- hw/block/dataplane/virtio-blk.c | 3 ++- hw/scsi/virtio-scsi-dataplane.c | 2 -- util/aio-wait.c | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/block/aio-wait.h b/include/block/aio-wait.h index 6e43e3b7bb..5449b6d742 100644 --- a/include/block/aio-wait.h +++ b/include/block/aio-wait.h @@ -131,7 +131,7 @@ void aio_wait_kick(void); * * Run a BH in @ctx and wait for it to complete. * - * Must be called from the main loop thread with @ctx acquired exactly onc= e. + * Must be called from the main loop thread without @ctx acquired. * Note that main loop event processing may occur. */ void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb, void *opaque); diff --git a/hw/block/dataplane/virtio-blk.c b/hw/block/dataplane/virtio-bl= k.c index a6202997ee..af1c24c40c 100644 --- a/hw/block/dataplane/virtio-blk.c +++ b/hw/block/dataplane/virtio-blk.c @@ -315,9 +315,10 @@ void virtio_blk_data_plane_stop(VirtIODevice *vdev) s->stopping =3D true; trace_virtio_blk_data_plane_stop(s); =20 - aio_context_acquire(s->ctx); aio_wait_bh_oneshot(s->ctx, virtio_blk_data_plane_stop_bh, s); =20 + aio_context_acquire(s->ctx); + /* Wait for virtio_blk_dma_restart_bh() and in flight I/O to complete = */ blk_drain(s->conf->conf.blk); =20 diff --git a/hw/scsi/virtio-scsi-dataplane.c b/hw/scsi/virtio-scsi-dataplan= e.c index 20bb91766e..f3214e1c57 100644 --- a/hw/scsi/virtio-scsi-dataplane.c +++ b/hw/scsi/virtio-scsi-dataplane.c @@ -197,9 +197,7 @@ void virtio_scsi_dataplane_stop(VirtIODevice *vdev) } s->dataplane_stopping =3D true; =20 - aio_context_acquire(s->ctx); aio_wait_bh_oneshot(s->ctx, virtio_scsi_dataplane_stop_bh, s); - aio_context_release(s->ctx); =20 blk_drain_all(); /* ensure there are no in-flight requests */ =20 diff --git a/util/aio-wait.c b/util/aio-wait.c index 98c5accd29..b5336cf5fd 100644 --- a/util/aio-wait.c +++ b/util/aio-wait.c @@ -82,5 +82,5 @@ void aio_wait_bh_oneshot(AioContext *ctx, QEMUBHFunc *cb,= void *opaque) assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); =20 aio_bh_schedule_oneshot(ctx, aio_wait_bh, &data); - AIO_WAIT_WHILE(ctx, !data.done); + AIO_WAIT_WHILE_UNLOCKED(NULL, !data.done); } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721399; cv=none; d=zohomail.com; s=zohoarc; b=OwIbg7LvpbC+FMF+VV2Xk8PcKwxXDzzpLmC1yygiDEvbvbRn28PWrW5FJea2nk3Myl0caJ7ez53Vcjfkr//ro6IIZDv4PSv0r43r0YeN5f4/tSIK+uohJ2p4UALT/EP4sLfJpGiLIBlnWk28OcvrENU8eoAF6WGpTvM5ZqIiUaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721399; 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=Nb1wed0zq4TydEORbcgD6A7N63EQBgP+y1JKZQIPgBg=; b=Dpgvv1iFZjHdKuaMIOTM+uxzG5wXG1+XGKH5klC0LO5m8mgrWyNt1aEs6dsgRWftK4SjvlfJW+slnLkIIMnC0xNhc4yQ8ZOYNKH7JtBJ9yYtlgJQ0XnvWMX4QygQwyoW1HyIM5Gswd5s6awr5IXrcnpRvIeU9s0+nUz9Oe4Eb4w= 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 1683721399036946.739909103884; Wed, 10 May 2023 05:23:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipR-0002Gd-2Q; Wed, 10 May 2023 08:21:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipJ-000292-IX for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipG-0007e9-6M for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21: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-569-1w_hvY5VORi3K7nLoWUz8A-1; Wed, 10 May 2023 08:21:40 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8491285A5A3; Wed, 10 May 2023 12:21:40 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C7E3247CD0; Wed, 10 May 2023 12:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721305; 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=Nb1wed0zq4TydEORbcgD6A7N63EQBgP+y1JKZQIPgBg=; b=bX+TW0zRvStHZDyAj3Ci719doCqu9GE1RDir9SNAuiULI73wWyyTU+h1HgcrOHmQzYEt8G 5ePCnKsZGomccwjdSdR4LXTrtMQ0gUMpOxgv0F82w8XxiapVUjmbVRh6Yn+/pjpHgfvzJP qBm+pOGaYaLokiprW7kIin6fSujnHHU= X-MC-Unique: 1w_hvY5VORi3K7nLoWUz8A-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 04/28] block: Fix use after free in blockdev_mark_auto_del() Date: Wed, 10 May 2023 14:20:47 +0200 Message-Id: <20230510122111.46566-5-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721400506100003 Content-Type: text/plain; charset="utf-8" job_cancel_locked() drops the job list lock temporarily and it may call aio_poll(). We must assume that the list has changed after this call. Also, with unlucky timing, it can end up freeing the job during job_completed_txn_abort_locked(), making the job pointer invalid, too. For both reasons, we can't just continue at block_job_next_locked(job). Instead, start at the head of the list again after job_cancel_locked() and skip those jobs that we already cancelled (or that are completing anyway). Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Message-Id: <20230503140142.474404-1-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- blockdev.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/blockdev.c b/blockdev.c index d7b5c18f0a..2c1752a403 100644 --- a/blockdev.c +++ b/blockdev.c @@ -153,12 +153,22 @@ void blockdev_mark_auto_del(BlockBackend *blk) =20 JOB_LOCK_GUARD(); =20 - 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))) { + do { + job =3D block_job_next_locked(NULL); + while (job && (job->job.cancelled || + job->job.deferred_to_main_loop || + !block_job_has_bdrv(job, blk_bs(blk)))) + { + job =3D block_job_next_locked(job); + } + if (job) { + /* + * This drops the job lock temporarily and polls, so we need to + * restart processing the list from the start after this. + */ job_cancel_locked(&job->job, false); } - } + } while (job); =20 dinfo->auto_del =3D 1; } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721338; cv=none; d=zohomail.com; s=zohoarc; b=BU5kB/l1O3lA9e2F0LsFMQNzN9FjezRpU/Jf7RWrZwyKYTcE5sD/xk3yN42e22X4YsXLSjVz14kC3sMCETi+qrpxuSFDFfPM949ywTovEQ9grdSiv6e0InMQqP0rnMyOSAX/6q4ATKl1hfBUm8Hm22D27DiQ2MvLCPubDqRIEKw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721338; 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=uG/abzHmBjyRvmEjMOps4dBGC+FhEn+vCirBzpiWzjk=; b=Ex0pGI/lZzfh7CL/IANTx3iG/YSGVS6ek/LHnuXBNuceGBZGDHhYOzLndDl4UHRQ2QkwLu1VrMlZae/Vl4krZCvvKIWQOET7VmpzPad/DBwPvTm8ePR4DMckBvtrV0H6awK6oYt1H+Q0ZhRluq+GLoq2xMIH4aEmI+GeN6ndgDs= 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 1683721338697267.7631851757134; Wed, 10 May 2023 05:22:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipT-0002LT-3w; Wed, 10 May 2023 08:21:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipJ-000293-Ik for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipD-0007dq-Uo for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21: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-591-QhP2aSWBM9-9G0Jy43pZNw-1; Wed, 10 May 2023 08:21:41 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 76A86185A790; Wed, 10 May 2023 12:21:41 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB6E263F88; Wed, 10 May 2023 12:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721303; 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=uG/abzHmBjyRvmEjMOps4dBGC+FhEn+vCirBzpiWzjk=; b=P5YBJhzMYFbqff7z/tndoQqr4V1fdc8zyyi1BndH9BCmV8uB8i1k3NDfCrKZ2OcCaJy5lu TZxrrCOr+JQvsjO9wRM5GTO34J5Nff3SjfcfUxgmt14U1MEPfPeTuHDchezUFaiDyN91qv XNOqLJIGCsrQ1icpGs4GpmR73fvrtVA= X-MC-Unique: QhP2aSWBM9-9G0Jy43pZNw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 05/28] iotests/nbd-reconnect-on-open: Fix NBD socket path Date: Wed, 10 May 2023 14:20:48 +0200 Message-Id: <20230510122111.46566-6-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721339824100003 Content-Type: text/plain; charset="utf-8" Socket paths need to be short to avoid failures. This is why there is a iotests.sock_dir (defaulting to /tmp) separate from the disk image base directory. Make use of it to fix failures in too deeply nested test directories. Fixes: ab7f7e67a7e7b49964109501dfcde4ec29bae60e Signed-off-by: Kevin Wolf Message-Id: <20230503165019.8867-1-kwolf@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy Signed-off-by: Kevin Wolf --- tests/qemu-iotests/tests/nbd-reconnect-on-open | 3 ++- tests/qemu-iotests/tests/nbd-reconnect-on-open.out | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open b/tests/qemu-io= tests/tests/nbd-reconnect-on-open index d0b401b060..3ce52021c3 100755 --- a/tests/qemu-iotests/tests/nbd-reconnect-on-open +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open @@ -26,7 +26,8 @@ from iotests import qemu_img_create, file_path, qemu_io_p= open, qemu_nbd, \ =20 iotests.script_initialize(supported_fmts=3D['qcow2']) =20 -disk, nbd_sock =3D file_path('disk', 'nbd-sock') +disk =3D file_path('disk') +nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) =20 =20 def create_args(open_timeout): diff --git a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out b/tests/qem= u-iotests/tests/nbd-reconnect-on-open.out index a35ae30ea4..b3dd90f2a3 100644 --- a/tests/qemu-iotests/tests/nbd-reconnect-on-open.out +++ b/tests/qemu-iotests/tests/nbd-reconnect-on-open.out @@ -2,10 +2,10 @@ read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =20 Check fail to connect with 0 seconds of timeout -qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such= file or directory +qemu-io: can't open: Failed to connect to 'SOCK_DIR/PID-nbd-sock': No such= file or directory =20 qemu_io finished in 0..0.2 seconds, OK Check fail to connect with 1 seconds of timeout -qemu-io: can't open: Failed to connect to 'TEST_DIR/PID-nbd-sock': No such= file or directory +qemu-io: can't open: Failed to connect to 'SOCK_DIR/PID-nbd-sock': No such= file or directory =20 qemu_io finished in 1..1.2 seconds, OK --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721555; cv=none; d=zohomail.com; s=zohoarc; b=CcIE0tGbiFZtoCfeUWBo5gRqLXmSa31vbF2GNjma2+IWHI3gX0bvIR0KnpDLvTSE+AA1/jCrhcKmY396/fRBUjuCXMJUbT++YVCIryupUD4C9Y6EN0bhpiLKZPx2CP6WWYSJ/INGSFSKKyDBXDJr73ZJNf1TJQwTTocbF0RTJEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721555; 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=FvKW2OuouZ46xuFzokD/lmO75krMaQgi8ET/8yU3aoc=; b=Tkqe+hUYGXUfnLbu7yeXtzSc9fRpJxmjmVusjYvE0YqmXik2txCZ7s9IJhUkqRkGqQFnyM9zfaBbSULEerfs5+22QtCWyDxpVn9+abWaUrnrFBXUpz8vyOjN+eeMkgk8OCiBKK7MUi99Hj/oGG7jsWgwvrWl+9K82BkjnvUVwjU= 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 1683721555133284.5388845527193; Wed, 10 May 2023 05:25:55 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiqA-0003sI-Ci; Wed, 10 May 2023 08:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0002C3-Uf for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipH-0007eo-Pu for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:51 -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-18-wtHP0wogO2-E-QKG2d5jEw-1; Wed, 10 May 2023 08:21:42 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8067D3C0CF0E; Wed, 10 May 2023 12:21:42 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C25F518EC1; Wed, 10 May 2023 12:21:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721307; 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=FvKW2OuouZ46xuFzokD/lmO75krMaQgi8ET/8yU3aoc=; b=QTeclRDF8pbmEHpE9/GhqnWfxheEmQRA/a0UcmbaA9bqAv4vpfkl71oGg/hszj3+j6TJrK 0dpy7a8M84IrQ+E0Db3jUj5m+RkDmKwBhuASwLYXLT/VuWIxhNIzTFfTXIBNX9P7WQVBlH Rr394xVPpHVxLwO/Pg1Fat70a/SBmSI= X-MC-Unique: wtHP0wogO2-E-QKG2d5jEw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 06/28] migration: Attempt disk reactivation in more failure scenarios Date: Wed, 10 May 2023 14:20:49 +0200 Message-Id: <20230510122111.46566-7-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721556172100003 Content-Type: text/plain; charset="utf-8" From: Eric Blake Commit fe904ea824 added a fail_inactivate label, which tries to reactivate disks on the source after a failure while s->state =3D=3D MIGRATION_STATUS_ACTIVE, but didn't actually use the label if qemu_savevm_state_complete_precopy() failed. This failure to reactivate is also present in commit 6039dd5b1c (also covering the new s->state =3D=3D MIGRATION_STATUS_DEVICE state) and 403d18ae (ensuring s->block_inactive is set more reliably). Consolidate the two labels back into one - no matter HOW migration is failed, if there is any chance we can reach vm_start() after having attempted inactivation, it is essential that we have tried to restart disks before then. This also makes the cleanup more like migrate_fd_cancel(). Suggested-by: Kevin Wolf Signed-off-by: Eric Blake Message-Id: <20230502205212.134680-1-eblake@redhat.com> Acked-by: Peter Xu Reviewed-by: Juan Quintela Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- migration/migration.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/migration/migration.c b/migration/migration.c index 0ee07802a5..f9f12a17b5 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2309,6 +2309,11 @@ static void migration_completion(MigrationState *s) MIGRATION_STATUS_DEVICE); } if (ret >=3D 0) { + /* + * Inactivate disks except in COLO, and track that we + * have done so in order to remember to reactivate + * them if migration fails or is cancelled. + */ s->block_inactive =3D !migrate_colo(); qemu_file_set_rate_limit(s->to_dst_file, INT64_MAX); ret =3D qemu_savevm_state_complete_precopy(s->to_dst_file,= false, @@ -2353,13 +2358,13 @@ static void migration_completion(MigrationState *s) rp_error =3D await_return_path_close_on_source(s); trace_migration_return_path_end_after(rp_error); if (rp_error) { - goto fail_invalidate; + goto fail; } } =20 if (qemu_file_get_error(s->to_dst_file)) { trace_migration_completion_file_err(); - goto fail_invalidate; + goto fail; } =20 if (migrate_colo() && s->state =3D=3D MIGRATION_STATUS_ACTIVE) { @@ -2373,26 +2378,25 @@ static void migration_completion(MigrationState *s) =20 return; =20 -fail_invalidate: - /* If not doing postcopy, vm_start() will be called: let's regain - * control on images. - */ - if (s->state =3D=3D MIGRATION_STATUS_ACTIVE || - s->state =3D=3D MIGRATION_STATUS_DEVICE) { +fail: + if (s->block_inactive && (s->state =3D=3D MIGRATION_STATUS_ACTIVE || + s->state =3D=3D MIGRATION_STATUS_DEVICE)) { + /* + * If not doing postcopy, vm_start() will be called: let's + * regain control on images. + */ Error *local_err =3D NULL; =20 qemu_mutex_lock_iothread(); bdrv_activate_all(&local_err); if (local_err) { error_report_err(local_err); - s->block_inactive =3D true; } else { s->block_inactive =3D false; } qemu_mutex_unlock_iothread(); } =20 -fail: migrate_set_state(&s->state, current_active_state, MIGRATION_STATUS_FAILED); } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721558; cv=none; d=zohomail.com; s=zohoarc; b=QxhWzEUCXZWHt5K8UyVctxa73w7BZGdBEPLDtPYGnJ+9Kmh2vU0SR5SnPXgiehh/4982IvMJoBFXS5VA3W4im7QFm94/g3XoHr8GvBGvYXsfpWM303L9yznzTYe/LAAQ4PE+RHBgmHL17euJ6b02IQKv9UNslnvUsguqsMJOB9Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721558; 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=wiYbfM1BFtrE9B7YCeWYRhn++DPxJa/SXeKYhDM5e80=; b=V882pax9Hkei4Gi1QMVhzObKY6MQKq6cyJUTeYs0TLtHmLgHDFGZ8XN96QhTTQdv+lM5ViPAoxaQ7f+W1M6wUaU1Juy4c2XZhBPykZpElNnWbWN/DXy3bJkk1TE3ghap8SJX/kUOtzKulvfV5nKHcxRfT7bpX2S10sRzE+dcC3A= 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 1683721558678122.21083737628555; Wed, 10 May 2023 05:25:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipR-0002HI-Ih; Wed, 10 May 2023 08:21:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0002Bs-RQ for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipG-0007eS-UR for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:50 -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-83-HMrj322-PWOmmrsyYCf-kw-1; Wed, 10 May 2023 08:21:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 743AD100F650; Wed, 10 May 2023 12:21:43 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B78FE47CD0; Wed, 10 May 2023 12:21:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721306; 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=wiYbfM1BFtrE9B7YCeWYRhn++DPxJa/SXeKYhDM5e80=; b=BhwBKGvqLomDQZKIY2d4NAj9P0EVfGVVMluUzw0FU4UyxD5618xChkzkNL4x4O8AH0QB41 7odnMcjN5uPlwkhZC6YHrXfQNk70YGR7YTXy1sRlP8dHiUoO1xYnuiRQQIzVdmLKJxspUx VJiqaxj97kYmilyQJJSks9bo1yUA/oM= X-MC-Unique: HMrj322-PWOmmrsyYCf-kw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 07/28] qcow2: Don't call bdrv_getlength() in coroutine_fns Date: Wed, 10 May 2023 14:20:50 +0200 Message-Id: <20230510122111.46566-8-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721559728100003 Content-Type: text/plain; charset="utf-8" There is a bdrv_co_getlength() now, which should be used in coroutine context. This requires adding GRAPH_RDLOCK to some functions so that this still compiles with TSA because bdrv_co_getlength() is GRAPH_RDLOCK. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-2-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/qcow2.h | 4 +++- block/qcow2-refcount.c | 2 +- block/qcow2.c | 19 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/block/qcow2.h b/block/qcow2.h index c75decc38a..4f67eb912a 100644 --- a/block/qcow2.h +++ b/block/qcow2.h @@ -895,7 +895,9 @@ int qcow2_change_refcount_order(BlockDriverState *bs, i= nt refcount_order, void *cb_opaque, Error **errp); int coroutine_fn GRAPH_RDLOCK qcow2_shrink_reftable(BlockDriverState *bs); int64_t coroutine_fn qcow2_get_last_cluster(BlockDriverState *bs, int64_t = size); -int coroutine_fn qcow2_detect_metadata_preallocation(BlockDriverState *bs); + +int coroutine_fn GRAPH_RDLOCK +qcow2_detect_metadata_preallocation(BlockDriverState *bs); =20 /* qcow2-cluster.c functions */ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t min_size, diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index b2a81ff707..4cf91bd955 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -3715,7 +3715,7 @@ int coroutine_fn qcow2_detect_metadata_preallocation(= BlockDriverState *bs) =20 qemu_co_mutex_assert_locked(&s->lock); =20 - file_length =3D bdrv_getlength(bs->file->bs); + file_length =3D bdrv_co_getlength(bs->file->bs); if (file_length < 0) { return file_length; } diff --git a/block/qcow2.c b/block/qcow2.c index fe5def438e..94cf59af8b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2089,11 +2089,10 @@ static void qcow2_join_options(QDict *options, QDic= t *old_options) } } =20 -static int coroutine_fn qcow2_co_block_status(BlockDriverState *bs, - bool want_zero, - int64_t offset, int64_t coun= t, - int64_t *pnum, int64_t *map, - BlockDriverState **file) +static int coroutine_fn GRAPH_RDLOCK +qcow2_co_block_status(BlockDriverState *bs, bool want_zero, int64_t offset, + int64_t count, int64_t *pnum, int64_t *map, + BlockDriverState **file) { BDRVQcow2State *s =3D bs->opaque; uint64_t host_offset; @@ -3235,7 +3234,7 @@ preallocate_co(BlockDriverState *bs, uint64_t offset,= uint64_t new_length, * all of the allocated clusters (otherwise we get failing reads after * EOF). Extend the image to the last allocated sector. */ - file_length =3D bdrv_getlength(s->data_file->bs); + file_length =3D bdrv_co_getlength(s->data_file->bs); if (file_length < 0) { error_setg_errno(errp, -file_length, "Could not get file size"); ret =3D file_length; @@ -4098,7 +4097,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, case QCOW2_SUBCLUSTER_UNALLOCATED_PLAIN: case QCOW2_SUBCLUSTER_UNALLOCATED_ALLOC: if (bs->backing && bs->backing->bs) { - int64_t backing_length =3D bdrv_getlength(bs->backing->bs); + int64_t backing_length =3D bdrv_co_getlength(bs->backing->= bs); if (src_offset >=3D backing_length) { cur_write_flags |=3D BDRV_REQ_ZERO_WRITE; } else { @@ -4293,7 +4292,7 @@ qcow2_co_truncate(BlockDriverState *bs, int64_t offse= t, bool exact, goto fail; } =20 - old_file_size =3D bdrv_getlength(bs->file->bs); + old_file_size =3D bdrv_co_getlength(bs->file->bs); if (old_file_size < 0) { error_setg_errno(errp, -old_file_size, "Failed to inquire current file length"); @@ -4386,7 +4385,7 @@ qcow2_co_truncate(BlockDriverState *bs, int64_t offse= t, bool exact, break; } =20 - old_file_size =3D bdrv_getlength(bs->file->bs); + old_file_size =3D bdrv_co_getlength(bs->file->bs); if (old_file_size < 0) { error_setg_errno(errp, -old_file_size, "Failed to inquire current file length"); @@ -4694,7 +4693,7 @@ qcow2_co_pwritev_compressed_part(BlockDriverState *bs, * align end of file to a sector boundary to ease reading with * sector based I/Os */ - int64_t len =3D bdrv_getlength(bs->file->bs); + int64_t len =3D bdrv_co_getlength(bs->file->bs); if (len < 0) { return len; } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721562; cv=none; d=zohomail.com; s=zohoarc; b=jJNRPp/vRL3cUgcouxYe8u5JOCOvpylYqtVzLXDwpXd5dCo+NxJCrffWhRxvpMO86Mf+pdywOpqn1v3K2rnXWBB/lBNvGgluShgK7q8jZ/5NGL2H08MVI6yYI89JtZrhstyochcRLWOO47SBKL7IGcO+Qo2efskxLyOvtoCxLnU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721562; 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=n6NgxL3Ny4N+o7FNz1jS3NWEGhSnpXMSIMsKhoPZ220=; b=kXi1Z8L+LRITDEIJh4wB+TlHPQoLEjWSOlG+/Z35SnGFDFyjuzM9fQRxeCFESaLTLT/Ppxq3gg08kTedDXAlAupUu/M45Y/NivyEIEYwgsHEqHuWFvT8hDqOIeol97g8ZgskH+U7XXmYvdwzQqiY6k4K9jngzBnftS/P5PDkU4o= 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 1683721562584331.16293882814693; Wed, 10 May 2023 05:26:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipv-0002sE-3D; Wed, 10 May 2023 08:22:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0002C2-V3 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipG-0007eW-Tm for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:50 -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-76-Ok9pn10NPYWm0I4AGsAjXQ-1; Wed, 10 May 2023 08:21:44 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7CD27101A55C; Wed, 10 May 2023 12:21:44 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C162D47CD0; Wed, 10 May 2023 12:21:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721306; 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=n6NgxL3Ny4N+o7FNz1jS3NWEGhSnpXMSIMsKhoPZ220=; b=LkHSG+ri4tb4Uzf6gJSQ/DKbQ2ZMB18//ilofv1yIIyR7Toq0mwHu11wtJKBMRB1FDzT2H 2hu3Cg5Hx05RmvOA6wEDl6Hf7qkpIQL6fntfBYToexSw/xyCzMppRVQbkA/onhfALIAEyG fSfLj51WN87tXjVJQeeADXTChUYy2Ok= X-MC-Unique: Ok9pn10NPYWm0I4AGsAjXQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 08/28] block: Consistently call bdrv_activate() outside coroutine Date: Wed, 10 May 2023 14:20:51 +0200 Message-Id: <20230510122111.46566-9-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721563119100002 Content-Type: text/plain; charset="utf-8" Migration code can call bdrv_activate() in coroutine context, whereas other callers call it outside of coroutines. As it calls other code that is not supposed to run in coroutines, standardise on running outside of coroutines. This adds a no_co_wrapper to switch to the main loop before calling bdrv_activate(). Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-3-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 6 +++++- block/block-backend.c | 10 +++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 399200a9a3..2c312cc774 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -166,7 +166,11 @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuO= pts *opts, BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, Error **err= p); =20 -int bdrv_activate(BlockDriverState *bs, Error **errp); +int no_coroutine_fn bdrv_activate(BlockDriverState *bs, Error **errp); + +int coroutine_fn no_co_wrapper +bdrv_co_activate(BlockDriverState *bs, Error **errp); + void bdrv_activate_all(Error **errp); int bdrv_inactivate_all(void); =20 diff --git a/block/block-backend.c b/block/block-backend.c index fc530ded6a..e37d55d3e9 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2024,7 +2024,15 @@ void blk_activate(BlockBackend *blk, Error **errp) return; } =20 - bdrv_activate(bs, errp); + /* + * Migration code can call this function in coroutine context, so leave + * coroutine context if necessary. + */ + if (qemu_in_coroutine()) { + bdrv_co_activate(bs, errp); + } else { + bdrv_activate(bs, errp); + } } =20 bool coroutine_fn blk_co_is_inserted(BlockBackend *blk) --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721460; cv=none; d=zohomail.com; s=zohoarc; b=hb4SoX4R0tqQXMVS49x8/i817pcF6GW0BfynS+ju1+kjluWPaQqjGKdlLelvtx6WHqbd0UUyzECLaippxZlwpB7ujWAJXIs6vEx0mpo0oSaO+/q7cLQajifD4xMhDvAoFCW0vOrOhohiuSHf97lml7aHGJcj9TbEtMFPD5Osh08= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721460; 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=SV6i/MFggBhc38DGTnVoz5sNSPDNa6H6jRBW2eN1zZo=; b=Ia8gFbv+zXSqrPIxKVUTCthlIjkVIChCD2OrFUbtOfXdakiFbGZh2fxG1YT0tpHfJV2XabZDLgxKzbhGZlfKr5akpdUO9u0hozU3njB8FKNtwXsn6sWc3sU7izOLmhxY0xKEH4sXtk6YgAhWvTaMrc0OX4gT9r8rYQKqHjUhmVI= 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 1683721460312415.26028289540534; Wed, 10 May 2023 05:24:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipU-0002NW-LO; Wed, 10 May 2023 08:22:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipR-0002Iy-TA for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0007gT-IA for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:57 -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-404-rxqWpRZoPA-C_S1f95XzfQ-1; Wed, 10 May 2023 08:21:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6FF37101A5C5; Wed, 10 May 2023 12:21:45 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B4D5F47CD0; Wed, 10 May 2023 12:21:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721311; 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=SV6i/MFggBhc38DGTnVoz5sNSPDNa6H6jRBW2eN1zZo=; b=NypHWa/ZcVWAT5Q3jxFdKZbUQvmXt3rsyr0RuRfrObUB/g+kJXoPg9WaiIiEmf6AUEyeCB 5ZTI05VU7pKf49uQd7EKnth/xQAhhzI+UxMOidrJ07QyB8IBmdCkbq068HXx0RGwGBjaqR smMaB14j68UqHJa2A1Lt51zAXjpoMUQ= X-MC-Unique: rxqWpRZoPA-C_S1f95XzfQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 09/28] block: bdrv/blk_co_unref() for calls in coroutine context Date: Wed, 10 May 2023 14:20:52 +0200 Message-Id: <20230510122111.46566-10-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721462196100007 Content-Type: text/plain; charset="utf-8" These functions must not be called in coroutine context, because they need write access to the graph. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-4-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 3 ++- include/sysemu/block-backend-global-state.h | 5 ++++- block.c | 2 +- block/crypto.c | 6 +++--- block/parallels.c | 6 +++--- block/qcow.c | 6 +++--- block/qcow2.c | 14 +++++++------- block/qed.c | 6 +++--- block/vdi.c | 6 +++--- block/vhdx.c | 6 +++--- block/vmdk.c | 18 +++++++++--------- block/vpc.c | 6 +++--- 12 files changed, 44 insertions(+), 40 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index 2c312cc774..ec3ddb17a8 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -218,7 +218,8 @@ void bdrv_img_create(const char *filename, const char *= fmt, bool quiet, Error **errp); =20 void bdrv_ref(BlockDriverState *bs); -void bdrv_unref(BlockDriverState *bs); +void no_coroutine_fn bdrv_unref(BlockDriverState *bs); +void coroutine_fn no_co_wrapper bdrv_co_unref(BlockDriverState *bs); void bdrv_unref_child(BlockDriverState *parent, BdrvChild *child); BdrvChild *bdrv_attach_child(BlockDriverState *parent_bs, BlockDriverState *child_bs, diff --git a/include/sysemu/block-backend-global-state.h b/include/sysemu/b= lock-backend-global-state.h index 2b6d27db7c..fa83f9389c 100644 --- a/include/sysemu/block-backend-global-state.h +++ b/include/sysemu/block-backend-global-state.h @@ -42,7 +42,10 @@ blk_co_new_open(const char *filename, const char *refere= nce, QDict *options, =20 int blk_get_refcnt(BlockBackend *blk); void blk_ref(BlockBackend *blk); -void blk_unref(BlockBackend *blk); + +void no_coroutine_fn blk_unref(BlockBackend *blk); +void coroutine_fn no_co_wrapper blk_co_unref(BlockBackend *blk); + void blk_remove_all_bs(void); BlockBackend *blk_by_name(const char *name); BlockBackend *blk_next(BlockBackend *blk); diff --git a/block.c b/block.c index 5ec1a3897e..20d5ee0959 100644 --- a/block.c +++ b/block.c @@ -680,7 +680,7 @@ int coroutine_fn bdrv_co_create_opts_simple(BlockDriver= *drv, =20 ret =3D 0; out: - blk_unref(blk); + blk_co_unref(blk); return ret; } =20 diff --git a/block/crypto.c b/block/crypto.c index ca67289187..8fd3ad0054 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -355,7 +355,7 @@ block_crypto_co_create_generic(BlockDriverState *bs, in= t64_t size, ret =3D 0; cleanup: qcrypto_block_free(crypto); - blk_unref(blk); + blk_co_unref(blk); return ret; } =20 @@ -661,7 +661,7 @@ block_crypto_co_create_luks(BlockdevCreateOptions *crea= te_options, Error **errp) =20 ret =3D 0; fail: - bdrv_unref(bs); + bdrv_co_unref(bs); return ret; } =20 @@ -730,7 +730,7 @@ fail: bdrv_co_delete_file_noerr(bs); } =20 - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_QCryptoBlockCreateOptions(create_opts); qobject_unref(cryptoopts); return ret; diff --git a/block/parallels.c b/block/parallels.c index 013684801a..b49c35929e 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -613,8 +613,8 @@ static int coroutine_fn parallels_co_create(BlockdevCre= ateOptions* opts, =20 ret =3D 0; out: - blk_unref(blk); - bdrv_unref(bs); + blk_co_unref(blk); + bdrv_co_unref(bs); return ret; =20 exit: @@ -691,7 +691,7 @@ parallels_co_create_opts(BlockDriver *drv, const char *= filename, =20 done: qobject_unref(qdict); - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } diff --git a/block/qcow.c b/block/qcow.c index 490e4f819e..a0c701f578 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -915,8 +915,8 @@ static int coroutine_fn qcow_co_create(BlockdevCreateOp= tions *opts, g_free(tmp); ret =3D 0; exit: - blk_unref(qcow_blk); - bdrv_unref(bs); + blk_co_unref(qcow_blk); + bdrv_co_unref(bs); qcrypto_block_free(crypto); return ret; } @@ -1015,7 +1015,7 @@ qcow_co_create_opts(BlockDriver *drv, const char *fil= ename, fail: g_free(backing_fmt); qobject_unref(qdict); - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } diff --git a/block/qcow2.c b/block/qcow2.c index 94cf59af8b..01742b3ebe 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -3705,7 +3705,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) goto out; } =20 - blk_unref(blk); + blk_co_unref(blk); blk =3D NULL; =20 /* @@ -3785,7 +3785,7 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) } } =20 - blk_unref(blk); + blk_co_unref(blk); blk =3D NULL; =20 /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returni= ng. @@ -3810,9 +3810,9 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) =20 ret =3D 0; out: - blk_unref(blk); - bdrv_unref(bs); - bdrv_unref(data_bs); + blk_co_unref(blk); + bdrv_co_unref(bs); + bdrv_co_unref(data_bs); return ret; } =20 @@ -3943,8 +3943,8 @@ finish: } =20 qobject_unref(qdict); - bdrv_unref(bs); - bdrv_unref(data_bs); + bdrv_co_unref(bs); + bdrv_co_unref(data_bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } diff --git a/block/qed.c b/block/qed.c index 0705a7b4e2..aff2a2076e 100644 --- a/block/qed.c +++ b/block/qed.c @@ -748,8 +748,8 @@ static int coroutine_fn bdrv_qed_co_create(BlockdevCrea= teOptions *opts, ret =3D 0; /* success */ out: g_free(l1_table); - blk_unref(blk); - bdrv_unref(bs); + blk_co_unref(blk); + bdrv_co_unref(bs); return ret; } =20 @@ -819,7 +819,7 @@ bdrv_qed_co_create_opts(BlockDriver *drv, const char *f= ilename, =20 fail: qobject_unref(qdict); - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } diff --git a/block/vdi.c b/block/vdi.c index f2434d6153..08331d2dd7 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -886,8 +886,8 @@ static int coroutine_fn vdi_co_do_create(BlockdevCreate= Options *create_options, =20 ret =3D 0; exit: - blk_unref(blk); - bdrv_unref(bs_file); + blk_co_unref(blk); + bdrv_co_unref(bs_file); g_free(bmap); return ret; } @@ -975,7 +975,7 @@ vdi_co_create_opts(BlockDriver *drv, const char *filena= me, done: qobject_unref(qdict); qapi_free_BlockdevCreateOptions(create_options); - bdrv_unref(bs_file); + bdrv_co_unref(bs_file); return ret; } =20 diff --git a/block/vhdx.c b/block/vhdx.c index 81420722a1..00777da91a 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2053,8 +2053,8 @@ static int coroutine_fn vhdx_co_create(BlockdevCreate= Options *opts, =20 ret =3D 0; delete_and_exit: - blk_unref(blk); - bdrv_unref(bs); + blk_co_unref(blk); + bdrv_co_unref(bs); g_free(creator); return ret; } @@ -2144,7 +2144,7 @@ vhdx_co_create_opts(BlockDriver *drv, const char *fil= ename, =20 fail: qobject_unref(qdict); - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } diff --git a/block/vmdk.c b/block/vmdk.c index 3f8c731e32..11b553ef25 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2306,7 +2306,7 @@ exit: if (pbb) { *pbb =3D blk; } else { - blk_unref(blk); + blk_co_unref(blk); blk =3D NULL; } } @@ -2516,12 +2516,12 @@ vmdk_co_do_create(int64_t size, if (strcmp(blk_bs(backing)->drv->format_name, "vmdk")) { error_setg(errp, "Invalid backing file format: %s. Must be vmd= k", blk_bs(backing)->drv->format_name); - blk_unref(backing); + blk_co_unref(backing); ret =3D -EINVAL; goto exit; } ret =3D vmdk_read_cid(blk_bs(backing), 0, &parent_cid); - blk_unref(backing); + blk_co_unref(backing); if (ret) { error_setg(errp, "Failed to read parent CID"); goto exit; @@ -2542,14 +2542,14 @@ vmdk_co_do_create(int64_t size, blk_bs(extent_blk)->filename); created_size +=3D cur_size; extent_idx++; - blk_unref(extent_blk); + blk_co_unref(extent_blk); } =20 /* Check whether we got excess extents */ extent_blk =3D extent_fn(-1, extent_idx, flat, split, compress, zeroed= _grain, opaque, NULL); if (extent_blk) { - blk_unref(extent_blk); + blk_co_unref(extent_blk); error_setg(errp, "List of extents contains unused extents"); ret =3D -EINVAL; goto exit; @@ -2590,7 +2590,7 @@ vmdk_co_do_create(int64_t size, ret =3D 0; exit: if (blk) { - blk_unref(blk); + blk_co_unref(blk); } g_free(desc); g_free(parent_desc_line); @@ -2641,7 +2641,7 @@ vmdk_co_create_opts_cb(int64_t size, int idx, bool fl= at, bool split, errp)) { goto exit; } - bdrv_unref(bs); + bdrv_co_unref(bs); exit: g_free(ext_filename); return blk; @@ -2797,12 +2797,12 @@ static BlockBackend * coroutine_fn vmdk_co_create_c= b(int64_t size, int idx, return NULL; } blk_set_allow_write_beyond_eof(blk, true); - bdrv_unref(bs); + bdrv_co_unref(bs); =20 if (size !=3D -1) { ret =3D vmdk_init_extent(blk, size, flat, compress, zeroed_grain, = errp); if (ret) { - blk_unref(blk); + blk_co_unref(blk); blk =3D NULL; } } diff --git a/block/vpc.c b/block/vpc.c index b89b0ff8e2..07ddda5b99 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -1082,8 +1082,8 @@ static int coroutine_fn vpc_co_create(BlockdevCreateO= ptions *opts, } =20 out: - blk_unref(blk); - bdrv_unref(bs); + blk_co_unref(blk); + bdrv_co_unref(bs); return ret; } =20 @@ -1162,7 +1162,7 @@ vpc_co_create_opts(BlockDriver *drv, const char *file= name, =20 fail: qobject_unref(qdict); - bdrv_unref(bs); + bdrv_co_unref(bs); qapi_free_BlockdevCreateOptions(create_options); return ret; } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721476; cv=none; d=zohomail.com; s=zohoarc; b=Le60TtTOKTb9eRm4rD+x4uXAdThA/qC2En56Mw++t1S6ZY2Ej5juqRf48fCU8X8U5xwDY+btGT1VmILeAIH/+5jWhreUXwAnbOP+SPaLd1FbCRB02pYe1BHL1dZ7CjdnQKxj0WDwOnKRMx5CNkwi69kVFh2otDBnRazh7imZc3k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721476; 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=5wPF/D6xG50TILO+rElitlgzqrIaI35kTFVdGBa/kNM=; b=jzDe3ZtcVrS6mhCNNvQO/+qaabEVGYDPZ2P+TkQjMrzznsohQdCxG2xFbAEMeGioQaGQ/UBXSogu79HtIdM82VZwMsfo+fsqFTNLBa+3cF3VxNQWRkJzDJzy1+YVHN/obXD/2IgweBTiNs73N1d/WqJqiPvwCAP9qLU8FLqCCCw= 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 1683721476028941.9949679992533; Wed, 10 May 2023 05:24:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq1-0003D5-Pn; Wed, 10 May 2023 08:22:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0002CE-Vy for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:55 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipI-0007fS-TL for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:51 -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-369-ikvKvj5AMUaf6Tpphkq6Tw-1; Wed, 10 May 2023 08:21:46 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7C45F3825BAD; Wed, 10 May 2023 12:21:46 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC3B363F86; Wed, 10 May 2023 12:21:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721308; 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=5wPF/D6xG50TILO+rElitlgzqrIaI35kTFVdGBa/kNM=; b=BUljV15ZuFbsSPu+nHmQ5n62vpdGT5ib0lZM7mYpRx5sW1D2jaNF7rC5p6hDSK7pDvpxgl w/o4ohhWGYNaBQhcI5RDMBb2hzBa1oUf+bn32fcAEDMcRlMJ0eSxA89JwNEWswiOhJTimh NcYAv9ZXhM5kIw/owmQXG3Fr9AlXo0g= X-MC-Unique: ikvKvj5AMUaf6Tpphkq6Tw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 10/28] block: Don't call no_coroutine_fns in qmp_block_resize() Date: Wed, 10 May 2023 14:20:53 +0200 Message-Id: <20230510122111.46566-11-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721476459100001 Content-Type: text/plain; charset="utf-8" This QMP handler runs in a coroutine, so it must use the corresponding no_co_wrappers instead. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D2185688 Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-5-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- blockdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/blockdev.c b/blockdev.c index 2c1752a403..e464daea58 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2440,7 +2440,7 @@ void coroutine_fn qmp_block_resize(const char *device= , const char *node_name, return; } =20 - blk =3D blk_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp); + blk =3D blk_co_new_with_bs(bs, BLK_PERM_RESIZE, BLK_PERM_ALL, errp); if (!blk) { return; } @@ -2455,7 +2455,7 @@ void coroutine_fn qmp_block_resize(const char *device= , const char *node_name, =20 bdrv_co_lock(bs); bdrv_drained_end(bs); - blk_unref(blk); + blk_co_unref(blk); bdrv_co_unlock(bs); } =20 --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721482; cv=none; d=zohomail.com; s=zohoarc; b=iAFB3vqqWss7CkC9bOTH4PWlgm823rIsNsSsE2J+fARJjj0Oq/fUgK78ghzqFDCp+d2YCN0XlUXQyed18gppcqxENJrKRVdwFidQhT3xZGt7rHkgXsrTHaL0eHKGaXzYrpnVSkyOncEH2OWX5x+mYG1iQ1T5JFNuRFR++y0SPDA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721482; 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=16elKj0ExiVWpz4Ea0AN5VTPrU5DO9G+aBqGtGoJ+VA=; b=Iy1twfxUdU4qhUrXFxWYAowIM3QqyhJHutJchMFeZAiJJZbuq7eOEiV2mTJ+frw+g+qO6IMLuqXg8g61XLThYTsryFQ/TwgK3DResbjn7BEdMuCjZ+fV/AJILqv/6Q6sTWP7k8h84D6XRps18Mai5YVg7DOvy0ex+6bhpK7kcUE= 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 1683721482297716.5301936772537; Wed, 10 May 2023 05:24:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwirt-0001wZ-2X; Wed, 10 May 2023 08:24:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwirr-0001l6-I5 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:24:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwirp-0008Et-Pk for qemu-devel@nongnu.org; Wed, 10 May 2023 08:24:27 -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-454-kymeAUKBMmqpck9koWLoAQ-1; Wed, 10 May 2023 08:21:47 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D8C62812959; Wed, 10 May 2023 12:21:47 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B30A218EC1; Wed, 10 May 2023 12:21:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721465; 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=16elKj0ExiVWpz4Ea0AN5VTPrU5DO9G+aBqGtGoJ+VA=; b=RLnYtHuCw/cPDyVV8xSOUEfJhAJrPt7RRrYzxaJCmBD2nCHyaYsNTUSSxpzTeCTwYTK7N7 Mcz/UEiY9A02zxPkrrJ4GRrXiXATSAMA3XiXZplC3WmBhBfafdVHdSXVnx+dJmXX1ExcBS 8BgRUFjg20NZaSFy0/V9D1rijpYhS7g= X-MC-Unique: kymeAUKBMmqpck9koWLoAQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 11/28] iotests: Test resizing image attached to an iothread Date: Wed, 10 May 2023 14:20:54 +0200 Message-Id: <20230510122111.46566-12-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721483033100007 Content-Type: text/plain; charset="utf-8" This tests that trying to resize an image with QMP block_resize doesn't hang or otherwise fail when the image is attached to a device running in an iothread. This is a regression test for the recent fix that changed qmp_block_resize, which is a coroutine based QMP handler, to avoid calling no_coroutine_fns directly. Signed-off-by: Kevin Wolf Message-Id: <20230509134133.373408-1-kwolf@redhat.com> Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- tests/qemu-iotests/tests/iothreads-resize | 71 +++++++++++++++++++ tests/qemu-iotests/tests/iothreads-resize.out | 11 +++ 2 files changed, 82 insertions(+) create mode 100755 tests/qemu-iotests/tests/iothreads-resize create mode 100644 tests/qemu-iotests/tests/iothreads-resize.out diff --git a/tests/qemu-iotests/tests/iothreads-resize b/tests/qemu-iotests= /tests/iothreads-resize new file mode 100755 index 0000000000..36e4598c62 --- /dev/null +++ b/tests/qemu-iotests/tests/iothreads-resize @@ -0,0 +1,71 @@ +#!/usr/bin/env bash +# group: rw auto quick +# +# Test resizing an image that is attached to a separate iothread +# +# Copyright (C) 2023 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=3Dkwolf@redhat.com + +seq=3D`basename $0` +echo "QA output created by $seq" + +status=3D1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +cd .. +. ./common.rc +. ./common.filter + +# Resizing images is only supported by a few block drivers +_supported_fmt raw qcow2 qed +_supported_proto file +_require_devices virtio-scsi-pci + +size=3D64M +_make_test_img $size + +qmp() { +cat < (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 1683721600662988.2874659295979; Wed, 10 May 2023 05:26:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipW-0002Rg-Kc; Wed, 10 May 2023 08:22:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipS-0002KK-Il for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0007gn-GW for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21: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-197-jBtg1uvkPP-z25plukRvtw-1; Wed, 10 May 2023 08:21:48 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 77C5D867959; Wed, 10 May 2023 12:21:48 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BD46F18EC1; Wed, 10 May 2023 12:21:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721312; 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=jR082N6zcTPKGpYiFSTu7phJVcAHAz2j2JUJqeamQ8c=; b=g6Tv3LFe+xHLHySyEK4cpEbJttJRBl0kxk0GtKRDPo0pEmVmOzGEkmH0rnDscN/xgTCZNz I2tHE8x2eJJ6vVSzgHngoo2wydqp/PBn8iIvbgF2VtVb5nyICxXUrf0g66Ip0nV4gHBXKa 4QgGda54lApv2t8Vjw2vI5SDEQ+1jwU= X-MC-Unique: jBtg1uvkPP-z25plukRvtw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 12/28] test-bdrv-drain: Don't modify the graph in coroutines Date: Wed, 10 May 2023 14:20:55 +0200 Message-Id: <20230510122111.46566-13-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721602394100002 Content-Type: text/plain; charset="utf-8" test-bdrv-drain contains a few test cases that are run both in coroutine and non-coroutine context. Running the entire code including the setup and shutdown in coroutines is incorrect because graph modifications can generally not happen in coroutines. Change the test so that creating and destroying the test nodes and BlockBackends always happens outside of coroutine context. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20230504115750.54437-6-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- tests/unit/test-bdrv-drain.c | 112 +++++++++++++++++++++++------------ 1 file changed, 75 insertions(+), 37 deletions(-) diff --git a/tests/unit/test-bdrv-drain.c b/tests/unit/test-bdrv-drain.c index d9d3807062..9a4c5e59d6 100644 --- a/tests/unit/test-bdrv-drain.c +++ b/tests/unit/test-bdrv-drain.c @@ -188,6 +188,25 @@ static void do_drain_begin_unlocked(enum drain_type dr= ain_type, BlockDriverState } } =20 +static BlockBackend * no_coroutine_fn test_setup(void) +{ + BlockBackend *blk; + BlockDriverState *bs, *backing; + + blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); + bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, + &error_abort); + blk_insert_bs(blk, bs, &error_abort); + + backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); + bdrv_set_backing_hd(bs, backing, &error_abort); + + bdrv_unref(backing); + bdrv_unref(bs); + + return blk; +} + static void do_drain_end_unlocked(enum drain_type drain_type, BlockDriverS= tate *bs) { if (drain_type !=3D BDRV_DRAIN_ALL) { @@ -199,25 +218,19 @@ static void do_drain_end_unlocked(enum drain_type dra= in_type, BlockDriverState * } } =20 -static void test_drv_cb_common(enum drain_type drain_type, bool recursive) +static void test_drv_cb_common(BlockBackend *blk, enum drain_type drain_ty= pe, + bool recursive) { - BlockBackend *blk; - BlockDriverState *bs, *backing; + BlockDriverState *bs =3D blk_bs(blk); + BlockDriverState *backing =3D bs->backing->bs; BDRVTestState *s, *backing_s; BlockAIOCB *acb; int aio_ret; =20 QEMUIOVector qiov =3D QEMU_IOVEC_INIT_BUF(qiov, NULL, 0); =20 - blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); - bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, - &error_abort); s =3D bs->opaque; - blk_insert_bs(blk, bs, &error_abort); - - backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); backing_s =3D backing->opaque; - bdrv_set_backing_hd(bs, backing, &error_abort); =20 /* Simple bdrv_drain_all_begin/end pair, check that CBs are called */ g_assert_cmpint(s->drain_count, =3D=3D, 0); @@ -252,44 +265,53 @@ static void test_drv_cb_common(enum drain_type drain_= type, bool recursive) =20 g_assert_cmpint(s->drain_count, =3D=3D, 0); g_assert_cmpint(backing_s->drain_count, =3D=3D, 0); - - bdrv_unref(backing); - bdrv_unref(bs); - blk_unref(blk); } =20 static void test_drv_cb_drain_all(void) { - test_drv_cb_common(BDRV_DRAIN_ALL, true); + BlockBackend *blk =3D test_setup(); + test_drv_cb_common(blk, BDRV_DRAIN_ALL, true); + blk_unref(blk); } =20 static void test_drv_cb_drain(void) { - test_drv_cb_common(BDRV_DRAIN, false); + BlockBackend *blk =3D test_setup(); + test_drv_cb_common(blk, BDRV_DRAIN, false); + blk_unref(blk); +} + +static void coroutine_fn test_drv_cb_co_drain_all_entry(void) +{ + BlockBackend *blk =3D blk_all_next(NULL); + test_drv_cb_common(blk, BDRV_DRAIN_ALL, true); } =20 static void test_drv_cb_co_drain_all(void) { - call_in_coroutine(test_drv_cb_drain_all); + BlockBackend *blk =3D test_setup(); + call_in_coroutine(test_drv_cb_co_drain_all_entry); + blk_unref(blk); } =20 -static void test_drv_cb_co_drain(void) +static void coroutine_fn test_drv_cb_co_drain_entry(void) { - call_in_coroutine(test_drv_cb_drain); + BlockBackend *blk =3D blk_all_next(NULL); + test_drv_cb_common(blk, BDRV_DRAIN, false); } =20 -static void test_quiesce_common(enum drain_type drain_type, bool recursive) +static void test_drv_cb_co_drain(void) { - BlockBackend *blk; - BlockDriverState *bs, *backing; - - blk =3D blk_new(qemu_get_aio_context(), BLK_PERM_ALL, BLK_PERM_ALL); - bs =3D bdrv_new_open_driver(&bdrv_test, "test-node", BDRV_O_RDWR, - &error_abort); - blk_insert_bs(blk, bs, &error_abort); + BlockBackend *blk =3D test_setup(); + call_in_coroutine(test_drv_cb_co_drain_entry); + blk_unref(blk); +} =20 - backing =3D bdrv_new_open_driver(&bdrv_test, "backing", 0, &error_abor= t); - bdrv_set_backing_hd(bs, backing, &error_abort); +static void test_quiesce_common(BlockBackend *blk, enum drain_type drain_t= ype, + bool recursive) +{ + BlockDriverState *bs =3D blk_bs(blk); + BlockDriverState *backing =3D bs->backing->bs; =20 g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); @@ -307,30 +329,46 @@ static void test_quiesce_common(enum drain_type drain= _type, bool recursive) =20 g_assert_cmpint(bs->quiesce_counter, =3D=3D, 0); g_assert_cmpint(backing->quiesce_counter, =3D=3D, 0); - - bdrv_unref(backing); - bdrv_unref(bs); - blk_unref(blk); } =20 static void test_quiesce_drain_all(void) { - test_quiesce_common(BDRV_DRAIN_ALL, true); + BlockBackend *blk =3D test_setup(); + test_quiesce_common(blk, BDRV_DRAIN_ALL, true); + blk_unref(blk); } =20 static void test_quiesce_drain(void) { - test_quiesce_common(BDRV_DRAIN, false); + BlockBackend *blk =3D test_setup(); + test_quiesce_common(blk, BDRV_DRAIN, false); + blk_unref(blk); +} + +static void coroutine_fn test_quiesce_co_drain_all_entry(void) +{ + BlockBackend *blk =3D blk_all_next(NULL); + test_quiesce_common(blk, BDRV_DRAIN_ALL, true); } =20 static void test_quiesce_co_drain_all(void) { - call_in_coroutine(test_quiesce_drain_all); + BlockBackend *blk =3D test_setup(); + call_in_coroutine(test_quiesce_co_drain_all_entry); + blk_unref(blk); +} + +static void coroutine_fn test_quiesce_co_drain_entry(void) +{ + BlockBackend *blk =3D blk_all_next(NULL); + test_quiesce_common(blk, BDRV_DRAIN, false); } =20 static void test_quiesce_co_drain(void) { - call_in_coroutine(test_quiesce_drain); + BlockBackend *blk =3D test_setup(); + call_in_coroutine(test_quiesce_co_drain_entry); + blk_unref(blk); } =20 static void test_nested(void) --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721328; cv=none; d=zohomail.com; s=zohoarc; b=WMmP8m/xG/ReT6Y3b+lXKP2Qw9rLrVq6rRqBkGDUZ3SCiWdHN67xaN+QnkBkCKD3BfH1FSebDHgjyofZ9iG0buCwHQlcjq5ZqS7Ydo1YEAJjPnyrGueV42QUSR2O5DFH7RzvlKZeTjYhh1OvcW7s9MSpplZJXVe4pTw3sLe5DfE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721328; 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=UV1e7ryXEoMrxU75TJz1ZNQYdNcfJhb6y3OGomc2H7A=; b=HcJMCziSQBSD8XM2Kb6LnztAnmTjAB3mgbxmCTPqcLyaEhJnqEI+EBqQlHf3sHvJZi+YmU5Swl4c1ifrlzj4ZMYibDsoNdKyAOh54/Fhtqxdq5u2TFILG5nAb+9R5Mgs+IpeAuFmaQUi1Lp34QyjSRpLPTrDtlUn3i+ryqIn/jc= 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 1683721328767130.64840081705233; Wed, 10 May 2023 05:22:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipS-0002Ke-Rt; Wed, 10 May 2023 08:21:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipQ-0002G0-Bb for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0007gX-5T for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:55 -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-92-Q43Us-MPN425xHKdTlS7_A-1; Wed, 10 May 2023 08:21:49 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F020185A79C; Wed, 10 May 2023 12:21:49 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF19518EC1; Wed, 10 May 2023 12:21:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721311; 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=UV1e7ryXEoMrxU75TJz1ZNQYdNcfJhb6y3OGomc2H7A=; b=Cyw3qse6SwK8vbRHIl3ydSRZ0t8NvGftOBJDxwtAIqFg1y3IgFIjyHnRyB/yJ3QgHAQC16 RygEDftqvusFT3mcZJB7lIm+3Ct2GK6KRYqA/Du5qkSFwqpX6pzcuqTd16cjcY3hj+ytUr OWE1QstfgrQSflxURaEp0Ctv/Htd7Cc= X-MC-Unique: Q43Us-MPN425xHKdTlS7_A-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 13/28] graph-lock: Add GRAPH_UNLOCKED(_PTR) Date: Wed, 10 May 2023 14:20:56 +0200 Message-Id: <20230510122111.46566-14-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721330191100003 Content-Type: text/plain; charset="utf-8" For some functions, it is part of their interface to be called without holding the graph lock. Add a new macro to document this. The macro expands to TSA_EXCLUDES(), which is a relatively weak check because it passes in cases where the compiler just doesn't know if the lock is held. Function pointers can't be checked at all. Therefore, its primary purpose is documentation. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-7-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/graph-lock.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h index ac0fef8605..f17d1588e7 100644 --- a/include/block/graph-lock.h +++ b/include/block/graph-lock.h @@ -73,6 +73,7 @@ extern BdrvGraphLock graph_lock; */ #define GRAPH_WRLOCK TSA_REQUIRES(graph_lock) #define GRAPH_RDLOCK TSA_REQUIRES_SHARED(graph_lock) +#define GRAPH_UNLOCKED TSA_EXCLUDES(graph_lock) =20 /* * TSA annotations are not part of function types, so checks are defeated = when @@ -83,6 +84,7 @@ extern BdrvGraphLock graph_lock; */ #define GRAPH_RDLOCK_PTR TSA_GUARDED_BY(graph_lock) #define GRAPH_WRLOCK_PTR TSA_GUARDED_BY(graph_lock) +#define GRAPH_UNLOCKED_PTR =20 /* * register_aiocontext: --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721446; cv=none; d=zohomail.com; s=zohoarc; b=G2ObnjJJPP9nQPmAhuu7mb5S3iJhL34S6R4sd1tagt32O85IOrRsuYch+tLGmezcKIYiqKzuuDNTCXpoMqDiIzNGjfzkKCe4CvMvTruyi7tlZSI6HrSXLHDlfbBV3OMVKBzTpS/Gls4UpolmAStGJf102duZCo4NK4F0+Wi/Npw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721446; 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=gLnN8XK3FCorQV8RrwvIzuunYAR2X0BmI4Yvvv8hScc=; b=DaMVEnPuFwXv+LCJpnkIGYR52J0Hb55agYOLGko2vAWC6mL2pG8e6xWQVa8Vd6R0xRbkIuZaIKdgqDxCkgo1+cCq3J+gQ7ld8fqftqmgZN6WdptQDAwWNsPzXNOHUOvNNhglZ4UxeIOxah7xNvzRBL8KinuAxxB5gDxixZxWIzU= 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 1683721446566793.7229177217598; Wed, 10 May 2023 05:24:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipw-00031p-Ub; Wed, 10 May 2023 08:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipR-0002Gs-DG for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipO-0007gr-Gj for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:57 -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-73-A6LEOrulP9-JZUc2qNF09g-1; Wed, 10 May 2023 08:21:50 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 757643C0CF17; Wed, 10 May 2023 12:21:50 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BB75347CD0; Wed, 10 May 2023 12:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721312; 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=gLnN8XK3FCorQV8RrwvIzuunYAR2X0BmI4Yvvv8hScc=; b=ilnCzZAyAEHrrQ3mY5K3lxTArmKWc03Zbjfz2JyoRg0kXfDL6bwM/FnlPpSmT2ANdzQN+I tS8adGDJNAkTZX+S5+F+npC1aX6tOk6acVVsCROiI4A81JdtuyEJQpur+VUQeV4MNKOgFi /VzGhFlnoduRWVFk49JV4onCHnABaEw= X-MC-Unique: A6LEOrulP9-JZUc2qNF09g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 14/28] graph-lock: Fix GRAPH_RDLOCK_GUARD*() to be reader lock Date: Wed, 10 May 2023 14:20:57 +0200 Message-Id: <20230510122111.46566-15-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721448003100001 Content-Type: text/plain; charset="utf-8" GRAPH_RDLOCK_GUARD() and GRAPH_RDLOCK_GUARD_MAINLOOP() only take a reader lock for the graph, so the correct annotation for them to use is TSA_ASSERT_SHARED rather than TSA_ASSERT. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20230504115750.54437-8-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/graph-lock.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/include/block/graph-lock.h b/include/block/graph-lock.h index f17d1588e7..7574a2de5b 100644 --- a/include/block/graph-lock.h +++ b/include/block/graph-lock.h @@ -205,12 +205,12 @@ typedef struct GraphLockable { } GraphLockable; #define GML_OBJ_() (&(GraphLockable) { }) =20 /* - * This is not marked as TSA_ACQUIRE() because TSA doesn't understand the + * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understa= nd the * cleanup attribute and would therefore complain that the graph is never - * unlocked. TSA_ASSERT() makes sure that the following calls know that we - * hold the lock while unlocking is left unchecked. + * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know = that + * we hold the lock while unlocking is left unchecked. */ -static inline GraphLockable * TSA_ASSERT(graph_lock) TSA_NO_TSA coroutine_= fn +static inline GraphLockable * TSA_ASSERT_SHARED(graph_lock) TSA_NO_TSA cor= outine_fn graph_lockable_auto_lock(GraphLockable *x) { bdrv_graph_co_rdlock(); @@ -249,12 +249,12 @@ typedef struct GraphLockableMainloop { } GraphLockabl= eMainloop; #define GMLML_OBJ_() (&(GraphLockableMainloop) { }) =20 /* - * This is not marked as TSA_ACQUIRE() because TSA doesn't understand the + * This is not marked as TSA_ACQUIRE_SHARED() because TSA doesn't understa= nd the * cleanup attribute and would therefore complain that the graph is never - * unlocked. TSA_ASSERT() makes sure that the following calls know that we - * hold the lock while unlocking is left unchecked. + * unlocked. TSA_ASSERT_SHARED() makes sure that the following calls know = that + * we hold the lock while unlocking is left unchecked. */ -static inline GraphLockableMainloop * TSA_ASSERT(graph_lock) TSA_NO_TSA +static inline GraphLockableMainloop * TSA_ASSERT_SHARED(graph_lock) TSA_NO= _TSA graph_lockable_auto_lock_mainloop(GraphLockableMainloop *x) { bdrv_graph_rdlock_main_loop(); --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721540; cv=none; d=zohomail.com; s=zohoarc; b=Mp/T8d+xPMJVyaTQsTc9Mq0mAcN3F0xk8nHcwZssdezCwrgaQTc6NllMO/lBMi3uZY0IGH7oap9hN7o3YhFEWeFVV3rLkX7uHLgFggAMy3wOpjzItvhS/61jEmV+RCSHs55grymm4vI0tfbgx4u/JeFr+aGEUwMCPFlnjGtRJ8g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721540; 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=WyhxTjUgre9dUUM6WypXz+Uc5mCB7VL0d8P8oj8plNw=; b=VpBGLXzHflDYfbR4CLQoWWY/cjLbGtbdwMraikHf0IJU/F6YqOxlii0KNE45kl9Bl6AuXK34d/ualXercTMke9Axky/sZ4FNSjfWKuEQ1sD40hOkPmyAMB/SnUnWSuzkUDKT19YxebAkcHsll0g+/4kqk4P+TmGX6q2e4/R6o3M= 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 1683721540235204.16003121889446; Wed, 10 May 2023 05:25:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipe-0002Tz-9c; Wed, 10 May 2023 08:22:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipT-0002M0-Fi for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipP-0007iE-UE for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:59 -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-656-eZZtQ_mPOiCYVmY7CE13gA-1; Wed, 10 May 2023 08:21:51 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 883401C087A9; Wed, 10 May 2023 12:21:51 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE36918EC1; Wed, 10 May 2023 12:21:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721315; 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=WyhxTjUgre9dUUM6WypXz+Uc5mCB7VL0d8P8oj8plNw=; b=fVClXrutbdwpuhFKbu1xh7vjECJ18SslngcERW6AjETi7wHBfQPxBwJep7vdfgj+r0IGQj y+6cuZ8pMPzu30j6sN74ZuHmXahcs/RCatUAhgq9n+FfzSMFNfcZLZrTEtEsfdjRveKoqd sh9Tvk4hCv2M2X/YBuk1yThFWofIsFw= X-MC-Unique: eZZtQ_mPOiCYVmY7CE13gA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 15/28] block: .bdrv_open is non-coroutine and unlocked Date: Wed, 10 May 2023 14:20:58 +0200 Message-Id: <20230510122111.46566-16-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721541351100003 Content-Type: text/plain; charset="utf-8" Drivers were a bit confused about whether .bdrv_open can run in a coroutine and whether or not it holds a graph lock. It cannot keep a graph lock from the caller across the whole function because it both changes the graph (requires a writer lock) and does I/O (requires a reader lock). Therefore, it should take these locks internally as needed. The functions used to be called in coroutine context during image creation. This was buggy for other reasons, and as of commit 32192301, all block drivers go through no_co_wrappers. So it is not called in coroutine context any more. Fix qcow2 and qed to work with the correct assumptions: The graph lock needs to be taken internally instead of just assuming it's already there, and the coroutine path is dead code that can be removed. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-9-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 8 ++++---- block.c | 6 +++--- block/qcow2.c | 15 ++++++--------- block/qed.c | 18 ++++++++---------- 4 files changed, 21 insertions(+), 26 deletions(-) diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 013d419444..6fb28cd8fa 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -236,12 +236,12 @@ struct BlockDriver { void (*bdrv_reopen_abort)(BDRVReopenState *reopen_state); void (*bdrv_join_options)(QDict *options, QDict *old_options); =20 - int (*bdrv_open)(BlockDriverState *bs, QDict *options, int flags, - Error **errp); + int GRAPH_UNLOCKED_PTR (*bdrv_open)( + BlockDriverState *bs, QDict *options, int flags, Error **errp); =20 /* Protocol drivers should implement this instead of bdrv_open */ - int (*bdrv_file_open)(BlockDriverState *bs, QDict *options, int flags, - Error **errp); + int GRAPH_UNLOCKED_PTR (*bdrv_file_open)( + BlockDriverState *bs, QDict *options, int flags, Error **errp); void (*bdrv_close)(BlockDriverState *bs); =20 int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_create)( diff --git a/block.c b/block.c index 20d5ee0959..abec940867 100644 --- a/block.c +++ b/block.c @@ -1610,9 +1610,9 @@ out: * bdrv_refresh_total_sectors() which polls when called from non-coroutine * context. */ -static int bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, - const char *node_name, QDict *options, - int open_flags, Error **errp) +static int no_coroutine_fn GRAPH_UNLOCKED +bdrv_open_driver(BlockDriverState *bs, BlockDriver *drv, const char *node_= name, + QDict *options, int open_flags, Error **errp) { Error *local_err =3D NULL; int i, ret; diff --git a/block/qcow2.c b/block/qcow2.c index 01742b3ebe..5bde3b8401 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1891,7 +1891,7 @@ static void coroutine_fn qcow2_open_entry(void *opaqu= e) QCow2OpenCo *qoc =3D opaque; BDRVQcow2State *s =3D qoc->bs->opaque; =20 - assume_graph_lock(); /* FIXME */ + GRAPH_RDLOCK_GUARD(); =20 qemu_co_mutex_lock(&s->lock); qoc->ret =3D qcow2_do_open(qoc->bs, qoc->options, qoc->flags, true, @@ -1920,14 +1920,11 @@ static int qcow2_open(BlockDriverState *bs, QDict *= options, int flags, /* Initialise locks */ qemu_co_mutex_init(&s->lock); =20 - if (qemu_in_coroutine()) { - /* From bdrv_co_create. */ - qcow2_open_entry(&qoc); - } else { - assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context(= )); - qemu_coroutine_enter(qemu_coroutine_create(qcow2_open_entry, &qoc)= ); - BDRV_POLL_WHILE(bs, qoc.ret =3D=3D -EINPROGRESS); - } + assert(!qemu_in_coroutine()); + assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); + qemu_coroutine_enter(qemu_coroutine_create(qcow2_open_entry, &qoc)); + BDRV_POLL_WHILE(bs, qoc.ret =3D=3D -EINPROGRESS); + return qoc.ret; } =20 diff --git a/block/qed.c b/block/qed.c index aff2a2076e..be9ff0fb34 100644 --- a/block/qed.c +++ b/block/qed.c @@ -557,11 +557,13 @@ typedef struct QEDOpenCo { int ret; } QEDOpenCo; =20 -static void coroutine_fn GRAPH_RDLOCK bdrv_qed_open_entry(void *opaque) +static void coroutine_fn bdrv_qed_open_entry(void *opaque) { QEDOpenCo *qoc =3D opaque; BDRVQEDState *s =3D qoc->bs->opaque; =20 + GRAPH_RDLOCK_GUARD(); + qemu_co_mutex_lock(&s->table_lock); qoc->ret =3D bdrv_qed_do_open(qoc->bs, qoc->options, qoc->flags, qoc->= errp); qemu_co_mutex_unlock(&s->table_lock); @@ -579,21 +581,17 @@ static int bdrv_qed_open(BlockDriverState *bs, QDict = *options, int flags, }; int ret; =20 - assume_graph_lock(); /* FIXME */ - ret =3D bdrv_open_file_child(NULL, options, "file", bs, errp); if (ret < 0) { return ret; } =20 bdrv_qed_init_state(bs); - if (qemu_in_coroutine()) { - bdrv_qed_open_entry(&qoc); - } else { - assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context(= )); - qemu_coroutine_enter(qemu_coroutine_create(bdrv_qed_open_entry, &q= oc)); - BDRV_POLL_WHILE(bs, qoc.ret =3D=3D -EINPROGRESS); - } + assert(!qemu_in_coroutine()); + assert(qemu_get_current_aio_context() =3D=3D qemu_get_aio_context()); + qemu_coroutine_enter(qemu_coroutine_create(bdrv_qed_open_entry, &qoc)); + BDRV_POLL_WHILE(bs, qoc.ret =3D=3D -EINPROGRESS); + return qoc.ret; } =20 --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721602; cv=none; d=zohomail.com; s=zohoarc; b=gjzsl2ppqwF5xzTSodQSlezM+PfrJL/MDSFlrIRzCZ1dXSyZGncgvn+cFZNOUeSIPeOGUHdZJWI/mFMLdof/SonWxfLUhPNixayQI/wfL3ZpNpxll7ap0Ah3QBR/wdY9Dhhb9/mfasWR5M83dQxNTG04Ivm5eniQ/DHMEhWXTR0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721602; 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=objLSR21raOkPHDne/OHUBC6wnBI54u8nXlzwPvyU2o=; b=dDNCL3P8seLsbz7sedubRUXCdCS65ToOiTCQVq5Ni/8NfEqCjL7v0DkJFA4kYspz6P3kRhLfklrH4Ly6iljdeYrwXhPp/Sm3+xF4ru9T9jHFcmkBp3fFyAIVnhF7YFTuMcVzqh3KSLRb2QybJz79u9Y5SmflYs5XbsQz141HVdo= 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 1683721602790736.8124065298706; Wed, 10 May 2023 05:26:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipW-0002RE-6P; Wed, 10 May 2023 08:22:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipU-0002Ns-NS for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipQ-0007iI-0e for qemu-devel@nongnu.org; Wed, 10 May 2023 08:21:59 -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-52-nM-4ZoheOVyfBcFpyoRdyw-1; Wed, 10 May 2023 08:21:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B028867940; Wed, 10 May 2023 12:21:52 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id CD18A18EC1; Wed, 10 May 2023 12:21:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721315; 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=objLSR21raOkPHDne/OHUBC6wnBI54u8nXlzwPvyU2o=; b=PX2MuK8Zyj9R9RPui+y5+Ham4vUkdZ3W1bboR2QQXsKasKg2/2wwwUeISrqIEDpoqc3Fig /tbyHrOZjU5GbBEOBkMqMuI5vQZ9mvGlDts/wWCQpUp+sMKo7H7j5RvbqfLlvPvlXRYmW9 Rr7wgCi4XrptrhEM2zWgoNNs7161Npw= X-MC-Unique: nM-4ZoheOVyfBcFpyoRdyw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 16/28] nbd: Remove nbd_co_flush() wrapper function Date: Wed, 10 May 2023 14:20:59 +0200 Message-Id: <20230510122111.46566-17-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721604364100007 Content-Type: text/plain; charset="utf-8" The only thing nbd_co_flush() does is call nbd_client_co_flush(). Just use that function directly in the BlockDriver definitions and remove the wrapper. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-10-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/nbd.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index bf2894ad5c..d3ee256844 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -1920,11 +1920,6 @@ fail: return ret; } =20 -static int coroutine_fn nbd_co_flush(BlockDriverState *bs) -{ - return nbd_client_co_flush(bs); -} - static void nbd_refresh_limits(BlockDriverState *bs, Error **errp) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; @@ -2120,7 +2115,7 @@ static BlockDriver bdrv_nbd =3D { .bdrv_co_pwritev =3D nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes =3D nbd_client_co_pwrite_zeroes, .bdrv_close =3D nbd_close, - .bdrv_co_flush_to_os =3D nbd_co_flush, + .bdrv_co_flush_to_os =3D nbd_client_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, @@ -2148,7 +2143,7 @@ static BlockDriver bdrv_nbd_tcp =3D { .bdrv_co_pwritev =3D nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes =3D nbd_client_co_pwrite_zeroes, .bdrv_close =3D nbd_close, - .bdrv_co_flush_to_os =3D nbd_co_flush, + .bdrv_co_flush_to_os =3D nbd_client_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, @@ -2176,7 +2171,7 @@ static BlockDriver bdrv_nbd_unix =3D { .bdrv_co_pwritev =3D nbd_client_co_pwritev, .bdrv_co_pwrite_zeroes =3D nbd_client_co_pwrite_zeroes, .bdrv_close =3D nbd_close, - .bdrv_co_flush_to_os =3D nbd_co_flush, + .bdrv_co_flush_to_os =3D nbd_client_co_flush, .bdrv_co_pdiscard =3D nbd_client_co_pdiscard, .bdrv_refresh_limits =3D nbd_refresh_limits, .bdrv_co_truncate =3D nbd_co_truncate, --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721516; cv=none; d=zohomail.com; s=zohoarc; b=e0uv1HT3ouv25WvRPhJ7SSfUTTHG9QjseShB2t2r76ILYleS7E7WfcYEjoN3HyX+uCTOlz3VHcShfltjJKaSYY9Bifsm9m72EeXOmM45jI4sTks3s9JYQf9VbG2yNiAMpIjegEADQERloACpbVUIkm5Umbd31bFDWL+beFlXJNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721516; 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=5FGDsBO0hzAObUWgVBgpsrbM4FoKiPkMCuG+mecsfQE=; b=gBCLRNfsV7RzmNO0FHUWwtu2DlQI+2h47yCGddNFciL+BOlQxtWd54imI3RnJy9f8ojHS9Qw6EDKiElhaI62g9Up5SWy09CIwWz3+QbfNSUE9tJMeTnFkk7cajyPTLMRardpI03oqeEf4VRuRZuucIeD82vYn5PM0khol4SfPOg= 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 1683721516819777.9350821222833; Wed, 10 May 2023 05:25:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq5-0003Y3-Va; Wed, 10 May 2023 08:22:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipZ-0002TY-65 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:05 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipV-0007mQ-M6 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:04 -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-435-fqjPpu0hMTeG9l4ecJX2Pw-1; Wed, 10 May 2023 08:21:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7D661281295A; Wed, 10 May 2023 12:21:53 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C32E163F8B; Wed, 10 May 2023 12:21:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721321; 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=5FGDsBO0hzAObUWgVBgpsrbM4FoKiPkMCuG+mecsfQE=; b=cqgUBFQKzZQpPC2IK9I109qk7vmZJNzhyQ56cmH+1u8x457PxJ2U1rj2TMIzbA5Az0Q9aJ yL/yPQRxqLHvZCLQuAdhZFHuZhWmFEPGRa0wb09bMtz01aiuFWUcKQN9YAoT1/3g4BSzmP AQpU5P1a2GOEaUMMBCQdFTDAgCNT5aI= X-MC-Unique: fqjPpu0hMTeG9l4ecJX2Pw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 17/28] nbd: Mark nbd_co_do_establish_connection() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:00 +0200 Message-Id: <20230510122111.46566-18-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721518917100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of nbd_co_do_establish_connection() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-11-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/coroutines.h | 5 +++-- block/nbd.c | 39 +++++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/block/coroutines.h b/block/coroutines.h index dd9f3d449b..f3226682d6 100644 --- a/block/coroutines.h +++ b/block/coroutines.h @@ -61,7 +61,7 @@ bdrv_co_readv_vmstate(BlockDriverState *bs, QEMUIOVector = *qiov, int64_t pos); int coroutine_fn GRAPH_RDLOCK bdrv_co_writev_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, int64_t p= os); =20 -int coroutine_fn +int coroutine_fn GRAPH_RDLOCK nbd_co_do_establish_connection(BlockDriverState *bs, bool blocking, Error **errp); =20 @@ -85,7 +85,8 @@ bdrv_common_block_status_above(BlockDriverState *bs, int64_t *map, BlockDriverState **file, int *depth); -int co_wrapper_mixed + +int co_wrapper_mixed_bdrv_rdlock nbd_do_establish_connection(BlockDriverState *bs, bool blocking, Error **e= rrp); =20 #endif /* BLOCK_COROUTINES_H */ diff --git a/block/nbd.c b/block/nbd.c index d3ee256844..a3f8f8a9d5 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -322,6 +322,7 @@ int coroutine_fn nbd_co_do_establish_connection(BlockDr= iverState *bs, int ret; IO_CODE(); =20 + assert_bdrv_graph_readable(); assert(!s->ioc); =20 s->ioc =3D nbd_co_establish_connection(s->conn, &s->info, blocking, er= rp); @@ -369,7 +370,7 @@ static bool nbd_client_connecting(BDRVNBDState *s) } =20 /* Called with s->requests_lock taken. */ -static coroutine_fn void nbd_reconnect_attempt(BDRVNBDState *s) +static void coroutine_fn GRAPH_RDLOCK nbd_reconnect_attempt(BDRVNBDState *= s) { int ret; bool blocking =3D s->state =3D=3D NBD_CLIENT_CONNECTING_WAIT; @@ -480,9 +481,9 @@ static coroutine_fn int nbd_receive_replies(BDRVNBDStat= e *s, uint64_t handle) } } =20 -static int coroutine_fn nbd_co_send_request(BlockDriverState *bs, - NBDRequest *request, - QEMUIOVector *qiov) +static int coroutine_fn GRAPH_RDLOCK +nbd_co_send_request(BlockDriverState *bs, NBDRequest *request, + QEMUIOVector *qiov) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; int rc, i =3D -1; @@ -1171,8 +1172,9 @@ static int coroutine_fn nbd_co_receive_blockstatus_re= ply(BDRVNBDState *s, return iter.ret; } =20 -static int coroutine_fn nbd_co_request(BlockDriverState *bs, NBDRequest *r= equest, - QEMUIOVector *write_qiov) +static int coroutine_fn GRAPH_RDLOCK +nbd_co_request(BlockDriverState *bs, NBDRequest *request, + QEMUIOVector *write_qiov) { int ret, request_ret; Error *local_err =3D NULL; @@ -1208,9 +1210,9 @@ static int coroutine_fn nbd_co_request(BlockDriverSta= te *bs, NBDRequest *request return ret ? ret : request_ret; } =20 -static int coroutine_fn nbd_client_co_preadv(BlockDriverState *bs, int64_t= offset, - int64_t bytes, QEMUIOVector *= qiov, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +nbd_client_co_preadv(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { int ret, request_ret; Error *local_err =3D NULL; @@ -1266,9 +1268,9 @@ static int coroutine_fn nbd_client_co_preadv(BlockDri= verState *bs, int64_t offse return ret ? ret : request_ret; } =20 -static int coroutine_fn nbd_client_co_pwritev(BlockDriverState *bs, int64_= t offset, - int64_t bytes, QEMUIOVector = *qiov, - BdrvRequestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +nbd_client_co_pwritev(BlockDriverState *bs, int64_t offset, int64_t bytes, + QEMUIOVector *qiov, BdrvRequestFlags flags) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { @@ -1291,8 +1293,9 @@ static int coroutine_fn nbd_client_co_pwritev(BlockDr= iverState *bs, int64_t offs return nbd_co_request(bs, &request, qiov); } =20 -static int coroutine_fn nbd_client_co_pwrite_zeroes(BlockDriverState *bs, = int64_t offset, - int64_t bytes, BdrvReq= uestFlags flags) +static int coroutine_fn GRAPH_RDLOCK +nbd_client_co_pwrite_zeroes(BlockDriverState *bs, int64_t offset, int64_t = bytes, + BdrvRequestFlags flags) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { @@ -1326,7 +1329,7 @@ static int coroutine_fn nbd_client_co_pwrite_zeroes(B= lockDriverState *bs, int64_ return nbd_co_request(bs, &request, NULL); } =20 -static int coroutine_fn nbd_client_co_flush(BlockDriverState *bs) +static int coroutine_fn GRAPH_RDLOCK nbd_client_co_flush(BlockDriverState = *bs) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { .type =3D NBD_CMD_FLUSH }; @@ -1341,8 +1344,8 @@ static int coroutine_fn nbd_client_co_flush(BlockDriv= erState *bs) return nbd_co_request(bs, &request, NULL); } =20 -static int coroutine_fn nbd_client_co_pdiscard(BlockDriverState *bs, int64= _t offset, - int64_t bytes) +static int coroutine_fn GRAPH_RDLOCK +nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int64_t bytes) { BDRVNBDState *s =3D (BDRVNBDState *)bs->opaque; NBDRequest request =3D { @@ -1361,7 +1364,7 @@ static int coroutine_fn nbd_client_co_pdiscard(BlockD= riverState *bs, int64_t off return nbd_co_request(bs, &request, NULL); } =20 -static int coroutine_fn nbd_client_co_block_status( +static int coroutine_fn GRAPH_RDLOCK nbd_client_co_block_status( BlockDriverState *bs, bool want_zero, int64_t offset, int64_t byte= s, int64_t *pnum, int64_t *map, BlockDriverState **file) { --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721442; cv=none; d=zohomail.com; s=zohoarc; b=myRAP15EaI07RS4ektIbDCqUEsYPHDxQlyVrYogGgvEPe6Lo00BJhe7ukObGvCrfxX2jvMjhGvVZmgnBzVgXgdpozTGag4rUV4E1dPuE0HnKScfl9K3zOFsrjfSlUF6Tzpai0JUWU0/J5y0KYj4lUrc3STI13174f2GYocWl1Vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721442; 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=TZKnymPVz37ONlR09m9ICN/Oo+XGr4hw8xFRmMr3UL8=; b=EcbnFrXJIgnvHC51sCp0OI9Y7LOM5wKep5LS+Kk5FCNjJkrHviP322TiEbQzgBRto0qP4NG3EZEs2WfMA4nSXYX3C8Ts/DiSHEaSMbY4M5hg5vxEpUvecK9DJqY5TeMaqZdMWRHq0/VPjhBs4hgppKXHn0rXXOAv0bJvtXaN/6Y= 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 1683721442382471.41880719569565; Wed, 10 May 2023 05:24:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq1-0003Bv-PO; Wed, 10 May 2023 08:22:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipV-0002QF-EL for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipS-0007kp-9E for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:01 -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-573--zaqORm9O7mrm_ghtLI6lw-1; Wed, 10 May 2023 08:21:54 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E7CE2812964; Wed, 10 May 2023 12:21:54 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C409147CD0; Wed, 10 May 2023 12:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721317; 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=TZKnymPVz37ONlR09m9ICN/Oo+XGr4hw8xFRmMr3UL8=; b=CCWStAX3Oe6Tv8Nv5gwCCcG16kGuvWJnPSrXVKN5PTnfMh4pcZQ9MpKEIhjCRIW5NjjP7s fxUyn9BoinRrt4q9MEHLkkSmTzj2kYmTYi3PGrTXDzEym0ZVlsPsSy1m8kV/wUpuO8JnoD 1VWicDFEN6+ahI5wNYuee6CNl7H6A6M= X-MC-Unique: -zaqORm9O7mrm_ghtLI6lw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 18/28] vhdx: Require GRAPH_RDLOCK for accessing a node's parent list Date: Wed, 10 May 2023 14:21:01 +0200 Message-Id: <20230510122111.46566-19-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721443950100007 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-12-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/vhdx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index 00777da91a..b20b1edf11 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1506,8 +1506,9 @@ exit: * There are 2 headers, and the highest sequence number will represent * the active header */ -static int vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size, - uint32_t log_size) +static int coroutine_fn GRAPH_RDLOCK +vhdx_create_new_headers(BlockBackend *blk, uint64_t image_size, + uint32_t log_size) { BlockDriverState *bs =3D blk_bs(blk); BdrvChild *child; @@ -1897,8 +1898,8 @@ exit: * .---- ~ ----------- ~ ------------ ~ ---------------- ~ -----------. * 1MB */ -static int coroutine_fn vhdx_co_create(BlockdevCreateOptions *opts, - Error **errp) +static int coroutine_fn GRAPH_RDLOCK +vhdx_co_create(BlockdevCreateOptions *opts, Error **errp) { BlockdevCreateOptionsVhdx *vhdx_opts; BlockBackend *blk =3D NULL; --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721520; cv=none; d=zohomail.com; s=zohoarc; b=lQ/Gla0UCVADDJDi8QVCoCnTxsfIgy5i0cptgpRvDxAGO4ZBn5O036fgBb9tbf3WG/YNuKMcu5tj76qeZlFKQ5Ly84kdxj2cDwKal16elQEkcgTxSAFNeiRuXIxbSe/zzJPMy0im/BBUaKPLud5cuvUlHfBgvPj/t9WaziMcD+A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721520; 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=13KzO7cO0INxOtlji+JfatqzVwQHTJnxBdhVQXFCE2E=; b=n9IHzY6wUz+1FT2V2BvxnxZIHPvrOj0SkFXcd52Ci18stKXcwfRFkdABGuPTWqgLXgQCqrzvCKnVf8AXnKPLBbT65tu9FjFdK29YvyviFplybm4DhneZn3k69SsJdKJJxsvyLPBrq4iZy9iW/PgC1GVSz6i8fuC2Gs1aBoFtekA= 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 1683721520176338.70634988283416; Wed, 10 May 2023 05:25:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq3-0003IT-Bb; Wed, 10 May 2023 08:22:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipX-0002SV-Ql for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipR-0007kQ-Nb for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:03 -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-595-mdjoE-nrPR2JVxGAcY2oOQ-1; Wed, 10 May 2023 08:21:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6F959886462; Wed, 10 May 2023 12:21:55 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B581A63F8A; Wed, 10 May 2023 12:21:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721317; 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=13KzO7cO0INxOtlji+JfatqzVwQHTJnxBdhVQXFCE2E=; b=DjMVHNUs9W46dLZuwo1VBQ/H11DYw6G/p7DtCa5S/KBOs4cIXe3iIDbATPwtbwDzwwyg+7 sXtmXkQiXzGlDhta7iskRXZGNsSn3ZSWRyxfJj8DxPegqSDOge+icxP2CC8KRywAUb2fzv TLegu43FkrguYt4eg/LftU3RdraLQcI= X-MC-Unique: mdjoE-nrPR2JVxGAcY2oOQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 19/28] mirror: Require GRAPH_RDLOCK for accessing a node's parent list Date: Wed, 10 May 2023 14:21:02 +0200 Message-Id: <20230510122111.46566-20-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, DKIM_INVALID=0.1, DKIM_SIGNED=0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721520918100004 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that functions accessing the parent list of a node need to hold a reader lock for the graph. As it happens, they already do. Signed-off-by: Kevin Wolf Message-Id: <20230504115750.54437-13-kwolf@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- block/mirror.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 80fa345071..b5c4ae31f3 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1416,7 +1416,7 @@ static MirrorOp *coroutine_fn active_write_prepare(Mi= rrorBlockJob *s, return op; } =20 -static void coroutine_fn active_write_settle(MirrorOp *op) +static void coroutine_fn GRAPH_RDLOCK active_write_settle(MirrorOp *op) { uint64_t start_chunk =3D op->offset / op->s->granularity; uint64_t end_chunk =3D DIV_ROUND_UP(op->offset + op->bytes, --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721463; cv=none; d=zohomail.com; s=zohoarc; b=bE0EIL/vw6G+RSNx+Kbh8cOWem1NSu7gExk4SxAxE6u/IV8mtS7LKKVsqfw8FhjDSroLpS6PyvJvUgxi8B7xhVo4N2eFTqISoNBMaS9QBzUJ5ZkA4pwU6HTny3iZzf4yrcue6yTXRZiGCEkCh7O7vWTMYDGXZtk0pSusyk8qLOs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721463; 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=Fryqh3t9XEWbLcWsKeUd9uiWkgOaSR845bK2vbFDaLo=; b=YrCc5x0dJRMWirOMFaCYRxvkRovQ9V3fb1+6txzeMcF3BTURNV7qtQVXXE4murhtbxH12gpuQx/wQQjtXjpwKr4ZJ7ZVrOraPl/wOeM0f++lmwTSRHOjeTL1xyV6ffIN8uWkBMSqVndo25FBQZV4/3v10v+eo1EmmeeErh+YZl0= 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 1683721463199936.9080292836964; Wed, 10 May 2023 05:24:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq1-0003Bu-PI; Wed, 10 May 2023 08:22:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipX-0002ST-BZ for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipS-0007lC-Tp for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:03 -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-116-XizpPnO4NXKUcfX1b_12Mw-1; Wed, 10 May 2023 08:21:56 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A7521C087A8; Wed, 10 May 2023 12:21:56 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BF37E63F8A; Wed, 10 May 2023 12:21:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721318; 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=Fryqh3t9XEWbLcWsKeUd9uiWkgOaSR845bK2vbFDaLo=; b=LgEv0Miteb9XO3NuFUf6W2h8clgmlDwX+c38avTK+lyiDAxemTquMn/TR3eEDYVahTkHhq h95iAE9nU0vsUsRvVjVsTKDqy1Sd5dX4HNls+cpVm3S/tWn2OD/KTgSSwO8FPdWswcPV2j gG6mtS/PSza9VtcTjhMUjic3CVjWwYo= X-MC-Unique: XizpPnO4NXKUcfX1b_12Mw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 20/28] block: Mark bdrv_co_get_allocated_file_size() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:03 +0200 Message-Id: <20230510122111.46566-21-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721464408100002 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_get_allocated_file_size() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Message-Id: <20230504115750.54437-14-kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf --- include/block/block-io.h | 7 +++++-- include/block/block_int-common.h | 2 +- block.c | 4 +++- block/vmdk.c | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/block/block-io.h b/include/block/block-io.h index 5dab88521d..fb2adb31c7 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -84,8 +84,11 @@ int64_t coroutine_mixed_fn bdrv_nb_sectors(BlockDriverSt= ate *bs); int64_t coroutine_fn GRAPH_RDLOCK bdrv_co_getlength(BlockDriverState *bs); int64_t co_wrapper_mixed_bdrv_rdlock bdrv_getlength(BlockDriverState *bs); =20 -int64_t coroutine_fn bdrv_co_get_allocated_file_size(BlockDriverState *bs); -int64_t co_wrapper bdrv_get_allocated_file_size(BlockDriverState *bs); +int64_t coroutine_fn GRAPH_RDLOCK +bdrv_co_get_allocated_file_size(BlockDriverState *bs); + +int64_t co_wrapper_bdrv_rdlock +bdrv_get_allocated_file_size(BlockDriverState *bs); =20 BlockMeasureInfo *bdrv_measure(BlockDriver *drv, QemuOpts *opts, BlockDriverState *in_bs, Error **errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 6fb28cd8fa..6e0365d8f2 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -685,7 +685,7 @@ struct BlockDriver { int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_getlength)( BlockDriverState *bs); =20 - int64_t coroutine_fn (*bdrv_co_get_allocated_file_size)( + int64_t coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_allocated_file_siz= e)( BlockDriverState *bs); =20 BlockMeasureInfo *(*bdrv_measure)(QemuOpts *opts, BlockDriverState *in= _bs, diff --git a/block.c b/block.c index abec940867..3ccb935950 100644 --- a/block.c +++ b/block.c @@ -5750,7 +5750,8 @@ exit: * sums the size of all data-bearing children. (This excludes backing * children.) */ -static int64_t coroutine_fn bdrv_sum_allocated_file_size(BlockDriverState = *bs) +static int64_t coroutine_fn GRAPH_RDLOCK +bdrv_sum_allocated_file_size(BlockDriverState *bs) { BdrvChild *child; int64_t child_size, sum =3D 0; @@ -5778,6 +5779,7 @@ int64_t coroutine_fn bdrv_co_get_allocated_file_size(= BlockDriverState *bs) { BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return -ENOMEDIUM; diff --git a/block/vmdk.c b/block/vmdk.c index 11b553ef25..fddbd1c86c 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -2845,7 +2845,7 @@ static void vmdk_close(BlockDriverState *bs) error_free(s->migration_blocker); } =20 -static int64_t coroutine_fn +static int64_t coroutine_fn GRAPH_RDLOCK vmdk_co_get_allocated_file_size(BlockDriverState *bs) { int i; --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721496; cv=none; d=zohomail.com; s=zohoarc; b=imZP1DIPwHlHbtLoRcZjRpWH56ArM3vv/gYOJBZWP4q/4FFRGpjcYK/6vFtytFwF2jKy9aYzhoteqYJXX0AHKun1kcYt8bVvgc1U3hGFcM/23fa5ul49oNACh3P7vbBtZQxKu6lrwzG7lfxWRZS814vW9HqFyYCmyBSFtATb3FE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721496; 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=GSHiPvLprmH/2qeqiJxANVyGdixcF8vjBneMzGkpQhE=; b=EIzCU69KAKzxbSwpMUatnolhWnw5xteF0as20YpnnEAHbl9YCsgK64vRKhBiuRcQlOqtLvyAVWqBXWonHdXebWzn/fwRRktge6KFqDbzGE6dld1/dDHS6UaI7Thm5FJLVK/xtz0fScUpj2utTHs7000Oc7NgOMD/y4zmJmB/a+A= 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 1683721496575707.6735877379116; Wed, 10 May 2023 05:24:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq5-0003VX-Ef; Wed, 10 May 2023 08:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipd-0002X2-81 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipX-0007nQ-R2 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:06 -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-169-ioYdiwjiNWGZ7jn4LM0OhQ-1; Wed, 10 May 2023 08:21:57 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D7D180253B; Wed, 10 May 2023 12:21:57 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B127747CD0; Wed, 10 May 2023 12:21:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721323; 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=GSHiPvLprmH/2qeqiJxANVyGdixcF8vjBneMzGkpQhE=; b=hKG1k+pLBEgBSVXmJ5tckPZmpnjVcOufPlIzP6+eNN6Rn2BnPSNnNj3BVh5iR1DYV3iRCm XpwtKuhD58oEN+iiXH9e+0TgqoRlJ2R16kk6XP7unC58OVPBUG1k0iyHQ4QwZuCzK6q8RX WV7o5BvUgWmEsp39xyHep2M/2ltdDyA= X-MC-Unique: ioYdiwjiNWGZ7jn4LM0OhQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 21/28] block: Mark bdrv_co_get_info() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:04 +0200 Message-Id: <20230510122111.46566-22-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721497919100005 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_get_info() need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-15-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-io.h | 7 +++++-- include/block/block_int-common.h | 4 ++-- block.c | 2 ++ block/crypto.c | 2 +- block/io.c | 11 +++++------ block/mirror.c | 8 ++++++-- block/raw-format.c | 2 +- 7 files changed, 22 insertions(+), 14 deletions(-) diff --git a/include/block/block-io.h b/include/block/block-io.h index fb2adb31c7..bba7f957e1 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -167,8 +167,11 @@ const char *bdrv_get_node_name(const BlockDriverState = *bs); const char *bdrv_get_device_name(const BlockDriverState *bs); const char *bdrv_get_device_or_node_name(const BlockDriverState *bs); =20 -int coroutine_fn bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *b= di); -int co_wrapper_mixed bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *= bdi); +int coroutine_fn GRAPH_RDLOCK +bdrv_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); + +int co_wrapper_mixed_bdrv_rdlock +bdrv_get_info(BlockDriverState *bs, BlockDriverInfo *bdi); =20 ImageInfoSpecific *bdrv_get_specific_info(BlockDriverState *bs, Error **errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 6e0365d8f2..ee77903f72 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -699,8 +699,8 @@ struct BlockDriver { BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_offset); =20 - int coroutine_fn (*bdrv_co_get_info)(BlockDriverState *bs, - BlockDriverInfo *bdi); + int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_get_info)( + BlockDriverState *bs, BlockDriverInfo *bdi); =20 ImageInfoSpecific *(*bdrv_get_specific_info)(BlockDriverState *bs, Error **errp); diff --git a/block.c b/block.c index 3ccb935950..a6deaf8ad1 100644 --- a/block.c +++ b/block.c @@ -6349,6 +6349,8 @@ int coroutine_fn bdrv_co_get_info(BlockDriverState *b= s, BlockDriverInfo *bdi) int ret; BlockDriver *drv =3D bs->drv; IO_CODE(); + assert_bdrv_graph_readable(); + /* if bs->drv =3D=3D NULL, bs is closed, so there's nothing to do here= */ if (!drv) { return -ENOMEDIUM; diff --git a/block/crypto.c b/block/crypto.c index 8fd3ad0054..30093cff9b 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -736,7 +736,7 @@ fail: return ret; } =20 -static int coroutine_fn +static int coroutine_fn GRAPH_RDLOCK block_crypto_co_get_info_luks(BlockDriverState *bs, BlockDriverInfo *bdi) { BlockDriverInfo subbdi; diff --git a/block/io.c b/block/io.c index 6fa1993374..3bf9ef9d87 100644 --- a/block/io.c +++ b/block/io.c @@ -727,10 +727,9 @@ BdrvTrackedRequest *coroutine_fn bdrv_co_get_self_requ= est(BlockDriverState *bs) /** * Round a region to cluster boundaries */ -void coroutine_fn bdrv_round_to_clusters(BlockDriverState *bs, - int64_t offset, int64_t bytes, - int64_t *cluster_offset, - int64_t *cluster_bytes) +void coroutine_fn GRAPH_RDLOCK +bdrv_round_to_clusters(BlockDriverState *bs, int64_t offset, int64_t bytes, + int64_t *cluster_offset, int64_t *cluster_bytes) { BlockDriverInfo bdi; IO_CODE(); @@ -744,7 +743,7 @@ void coroutine_fn bdrv_round_to_clusters(BlockDriverSta= te *bs, } } =20 -static coroutine_fn int bdrv_get_cluster_size(BlockDriverState *bs) +static int coroutine_fn GRAPH_RDLOCK bdrv_get_cluster_size(BlockDriverStat= e *bs) { BlockDriverInfo bdi; int ret; @@ -1800,7 +1799,7 @@ fail: return ret; } =20 -static inline int coroutine_fn +static inline int coroutine_fn GRAPH_RDLOCK bdrv_co_write_req_prepare(BdrvChild *child, int64_t offset, int64_t bytes, BdrvTrackedRequest *req, int flags) { diff --git a/block/mirror.c b/block/mirror.c index b5c4ae31f3..e48ed0af31 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -576,8 +576,10 @@ static uint64_t coroutine_fn mirror_iteration(MirrorBl= ockJob *s) } else if (ret >=3D 0 && !(ret & BDRV_BLOCK_DATA)) { int64_t target_offset; int64_t target_bytes; - bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, - &target_offset, &target_bytes); + WITH_GRAPH_RDLOCK_GUARD() { + bdrv_round_to_clusters(blk_bs(s->target), offset, io_bytes, + &target_offset, &target_bytes); + } if (target_offset =3D=3D offset && target_bytes =3D=3D io_bytes) { mirror_method =3D ret & BDRV_BLOCK_ZERO ? @@ -966,11 +968,13 @@ static int coroutine_fn mirror_run(Job *job, Error **= errp) */ bdrv_get_backing_filename(target_bs, backing_filename, sizeof(backing_filename)); + bdrv_graph_co_rdlock(); if (!bdrv_co_get_info(target_bs, &bdi) && bdi.cluster_size) { s->target_cluster_size =3D bdi.cluster_size; } else { s->target_cluster_size =3D BDRV_SECTOR_SIZE; } + bdrv_graph_co_rdunlock(); if (backing_filename[0] && !bdrv_backing_chain_next(target_bs) && s->granularity < s->target_cluster_size) { s->buf_size =3D MAX(s->buf_size, s->target_cluster_size); diff --git a/block/raw-format.c b/block/raw-format.c index 06b8030d9d..fd9e61f58e 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -369,7 +369,7 @@ static BlockMeasureInfo *raw_measure(QemuOpts *opts, Bl= ockDriverState *in_bs, return info; } =20 -static int coroutine_fn +static int coroutine_fn GRAPH_RDLOCK raw_co_get_info(BlockDriverState *bs, BlockDriverInfo *bdi) { return bdrv_co_get_info(bs->file->bs, bdi); --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721558; cv=none; d=zohomail.com; s=zohoarc; b=jVO3qvGmpeY++tzXs9T0JimkRbyS3ogW86M/0VyCWJTkuJ3+guVG/2ZfEW+CEaPA2FnVeR3FXTtwiqkl2qkCa/Yi1eZFdO9I9lmjmcelDj/Qu/AARL29C5YURE3o5xjKXKIxXp1+ny2QkH31iLxoo5XOqUA5DmgZ77SlnkMsyAc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721558; 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=kxUmHNnAPAEOm9WY//M+R4VEtqEbp07LztQKBcgCE/U=; b=Cq4+/kL4R9qwnvJ1fhX98Gr/nI7BZYh6+UvEjchEePpFq3E1fvCENioKo8RfUYl2X3SPw/Sg/9NHN5oVVvqEyqXc3U36/qEEkQZt20vZGtMHA8Hiw1ddNR2xJeVm3nEQXOx5mKvyytEdlGYmViViHaJSc9zFymjqQzV43TRqa/c= 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 1683721558871707.4964646185654; Wed, 10 May 2023 05:25:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipv-0002rq-3N; Wed, 10 May 2023 08:22:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipY-0002Sg-Lx for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipU-0007mD-UU for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:04 -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-647-zqghXI2ePWukqKzZd55Ksg-1; Wed, 10 May 2023 08:21:58 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7641F3C0D844; Wed, 10 May 2023 12:21:58 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id BC06518EC1; Wed, 10 May 2023 12:21:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721320; 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=kxUmHNnAPAEOm9WY//M+R4VEtqEbp07LztQKBcgCE/U=; b=X4541v6UxLLHEYUKMx0nbLgxDjWV4pXtGINb87jROXy5joc0OvWrTNAsbCgzSykRE4pB0c gA2w8m8fEzqh4XGLT5nAlMthW03T15UgcLvj9ONzmjlpScrMesfjis3fG6jqLc0OwH7jRw l+wVq0oTrOsozW29OJ3EAy/rehBKds4= X-MC-Unique: zqghXI2ePWukqKzZd55Ksg-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 22/28] block: Mark bdrv_co_debug_event() GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:05 +0200 Message-Id: <20230510122111.46566-23-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721559086100001 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_co_debug_event() need to hold a reader lock for the graph. Unfortunately we cannot use a co_wrapper_bdrv_rdlock (i.e. make the coroutine wrapper a no_coroutine_fn), because the function is called (using the BLKDBG_EVENT macro) by mixed functions that run both in coroutine and non-coroutine context (for example many of the functions in qcow2-cluster.c and qcow2-refcount.c). Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-16-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-io.h | 9 +++++---- include/block/block_int-common.h | 4 ++-- block.c | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/block/block-io.h b/include/block/block-io.h index bba7f957e1..1f612ec5bd 100644 --- a/include/block/block-io.h +++ b/include/block/block-io.h @@ -205,10 +205,11 @@ void *qemu_try_blockalign0(BlockDriverState *bs, size= _t size); void bdrv_enable_copy_on_read(BlockDriverState *bs); void bdrv_disable_copy_on_read(BlockDriverState *bs); =20 -void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, - BlkdebugEvent event); -void co_wrapper_mixed bdrv_debug_event(BlockDriverState *bs, - BlkdebugEvent event); +void coroutine_fn GRAPH_RDLOCK +bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent event); + +void co_wrapper_mixed_bdrv_rdlock +bdrv_debug_event(BlockDriverState *bs, BlkdebugEvent event); =20 #define BLKDBG_EVENT(child, evt) \ do { \ diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index ee77903f72..88ce7f9d9e 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -735,8 +735,8 @@ struct BlockDriver { int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_check)( BlockDriverState *bs, BdrvCheckResult *result, BdrvCheckMode fix); =20 - void coroutine_fn (*bdrv_co_debug_event)(BlockDriverState *bs, - BlkdebugEvent event); + void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_debug_event)( + BlockDriverState *bs, BlkdebugEvent event); =20 /* io queue for linux-aio */ void coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_io_plug)(BlockDriverState= *bs); diff --git a/block.c b/block.c index a6deaf8ad1..1bc766c778 100644 --- a/block.c +++ b/block.c @@ -6399,6 +6399,8 @@ BlockStatsSpecific *bdrv_get_specific_stats(BlockDriv= erState *bs) void coroutine_fn bdrv_co_debug_event(BlockDriverState *bs, BlkdebugEvent = event) { IO_CODE(); + assert_bdrv_graph_readable(); + if (!bs || !bs->drv || !bs->drv->bdrv_co_debug_event) { return; } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721429; cv=none; d=zohomail.com; s=zohoarc; b=dyecetZy/iJaiRflLEkhnwLxwpJb2eTGpj3tJtBTlkUhnfxTdSQCzpaSiJhjrLLPqDmESnfz2UwMvE4LhGgS5t0Kv3N/5/Lci9DNxRLWniV9xHzOv/B3h2ZrPrlbVbM0ThYdTI7VeyDEcItFCXJpcmNqIHvRlMswGyuqs7taccA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721429; 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=WRzL0DuvSjk1HCOV34CFAeCiOZ0kSGxxwLKlRcp+mv8=; b=eCszxMw+1UuFI9BuPtNZ5hJO40qbEHhm0pQ2KbPyH3VZz+fgkZHhiQdPi9xJFhN+Fy1C4nyyTbgucsb8mU1j6O3VJnF6F/oc17uNnf7+BUZX5/KUIbjZ8dRJUXqtLLf3kzyStVeufnHxCbHJHFbHptvBqdkThZ8IZ4uIW37rphs= 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 1683721429566810.7178818111597; Wed, 10 May 2023 05:23:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipw-0002z3-7l; Wed, 10 May 2023 08:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipd-0002X7-A9 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipX-0007nV-T9 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22: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-611-5qPzyfnVME22PtebgvEZ2g-1; Wed, 10 May 2023 08:21:59 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 695DC281295A; Wed, 10 May 2023 12:21:59 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id ACE5863F87; Wed, 10 May 2023 12:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721323; 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=WRzL0DuvSjk1HCOV34CFAeCiOZ0kSGxxwLKlRcp+mv8=; b=WUSFwUEYJvRQGZngAIbnsyxn6tmSBIZSHRAeSC7Xx3XLBI13W3GvQL5BTOYL1BC5KZ7JYQ xvvam5Cu7RVp+Be8UzEszL0hIDa3UYe1KPjkcssWFx7Y4evBsqhkxPu8ELm7pBigYG3UT7 g/4mZ9Vieo/xxjCvFeBOXrvtNKNZsHA= X-MC-Unique: 5qPzyfnVME22PtebgvEZ2g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 23/28] block: Mark BlockDriver callbacks for amend job GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:06 +0200 Message-Id: <20230510122111.46566-24-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721429983100003 Content-Type: text/plain; charset="utf-8" From: Emanuele Giuseppe Esposito This adds GRAPH_RDLOCK annotations to declare that callers of amend callbacks in BlockDriver need to hold a reader lock for the graph. Signed-off-by: Emanuele Giuseppe Esposito Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-17-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block_int-common.h | 12 ++++++------ block/amend.c | 8 +++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 88ce7f9d9e..37d094796e 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -204,12 +204,13 @@ struct BlockDriver { * to allow driver-specific initialization code that requires * the BQL, like setting up specific permission flags. */ - int (*bdrv_amend_pre_run)(BlockDriverState *bs, Error **errp); + int GRAPH_RDLOCK_PTR (*bdrv_amend_pre_run)( + BlockDriverState *bs, Error **errp); /* * This function is invoked under BQL after .bdrv_co_amend() * to allow cleaning up what was done in .bdrv_amend_pre_run(). */ - void (*bdrv_amend_clean)(BlockDriverState *bs); + void GRAPH_RDLOCK_PTR (*bdrv_amend_clean)(BlockDriverState *bs); =20 /* * Return true if @to_replace can be replaced by a BDS with the @@ -463,10 +464,9 @@ struct BlockDriver { =20 int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filena= me); =20 - int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, - BlockdevAmendOptions *opts, - bool force, - Error **errp); + int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_amend)( + BlockDriverState *bs, BlockdevAmendOptions *opts, bool force, + Error **errp); =20 /* aio */ BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_preadv)(BlockDriverState *bs, diff --git a/block/amend.c b/block/amend.c index bc4bb7b416..53a410247c 100644 --- a/block/amend.c +++ b/block/amend.c @@ -46,6 +46,7 @@ static int coroutine_fn blockdev_amend_run(Job *job, Erro= r **errp) { BlockdevAmendJob *s =3D container_of(job, BlockdevAmendJob, common); int ret; + GRAPH_RDLOCK_GUARD(); =20 job_progress_set_remaining(&s->common, 1); ret =3D s->bs->drv->bdrv_co_amend(s->bs, s->opts, s->force, errp); @@ -54,7 +55,8 @@ static int coroutine_fn blockdev_amend_run(Job *job, Erro= r **errp) return ret; } =20 -static int blockdev_amend_pre_run(BlockdevAmendJob *s, Error **errp) +static int GRAPH_RDLOCK +blockdev_amend_pre_run(BlockdevAmendJob *s, Error **errp) { if (s->bs->drv->bdrv_amend_pre_run) { return s->bs->drv->bdrv_amend_pre_run(s->bs, errp); @@ -67,9 +69,11 @@ static void blockdev_amend_free(Job *job) { BlockdevAmendJob *s =3D container_of(job, BlockdevAmendJob, common); =20 + bdrv_graph_rdlock_main_loop(); if (s->bs->drv->bdrv_amend_clean) { s->bs->drv->bdrv_amend_clean(s->bs); } + bdrv_graph_rdunlock_main_loop(); =20 bdrv_unref(s->bs); } @@ -93,6 +97,8 @@ void qmp_x_blockdev_amend(const char *job_id, BlockDriver *drv =3D bdrv_find_format(fmt); BlockDriverState *bs; =20 + GRAPH_RDLOCK_GUARD_MAINLOOP(); + bs =3D bdrv_lookup_bs(NULL, node_name, errp); if (!bs) { return; --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721463; cv=none; d=zohomail.com; s=zohoarc; b=V5VQqTukrv0U72kCYIn1yKWVnTDivEpC04J3VGkEkgSEJ5Ks03P0GdQVnISgr0tG/6tB1BapsIXrkHyR1G/c2aVb8UPZf3N1gtejYUApBhxrCSfNEBnvyKFsyws/rpEJGYSGilCEV+BSZKbHwCsKNzQtRlU8xgu2XnGo5TpO1L0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721463; 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=HZdOdwE1VAPdJONWA2dRBfHpB3tCLnC9B108Ki0YzNU=; b=AgIrAWyDdFQXd8n0rotptSWcipoiiyBAMhZ9xQ5gfkSobIPLoRUbWvSMZpBfRHeaWRM100K5cK7ujBpoSqT0SJ7/UqAiXUrm5w2rI943TsMzYmBoo6KCSQjGupitbXGtykw0msA8ABEWrZXPbDjYBPC6P89vok/QYZ4/NriwaBI= 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 1683721463977756.2370872413376; Wed, 10 May 2023 05:24:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwipw-00031f-SU; Wed, 10 May 2023 08:22:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipd-0002X6-A3 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:10 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipW-0007n2-R7 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:06 -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-465-arvNkL_KMTC8ZJjR_0Bb7g-1; Wed, 10 May 2023 08:22:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 79C5685A588; Wed, 10 May 2023 12:22:00 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0E5863F86; Wed, 10 May 2023 12:21:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721322; 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=HZdOdwE1VAPdJONWA2dRBfHpB3tCLnC9B108Ki0YzNU=; b=WKQUvrEhk6O4z6D9iXOJT5vPkif0ytPcwbcGoMveaxbYRcVwPec/U4YNK9mj3jMQmPa8nK 7X8UZIf4KkEk+x+kG7MCzHo/ufuB3u14QXjcfOSNoQBSXv/NI/oWr2CXVYCcgNgMHAQ1y0 P723ulPRhoKNl2q9V19WeBqMwMg9ujY= X-MC-Unique: arvNkL_KMTC8ZJjR_0Bb7g-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 24/28] block: Mark bdrv_query_bds_stats() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:07 +0200 Message-Id: <20230510122111.46566-25-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721464403100001 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_bds_stats() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-18-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- block/qapi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/qapi.c b/block/qapi.c index c84147849d..71f2751257 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -604,8 +604,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, = BlockBackend *blk) =3D bdrv_latency_histogram_stats(&hgram[BLOCK_ACCT_FLUSH]); } =20 -static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, - bool blk_level) +static BlockStats * GRAPH_RDLOCK +bdrv_query_bds_stats(BlockDriverState *bs, bool blk_level) { BdrvChild *parent_child; BlockDriverState *filter_or_cow_bs; @@ -713,6 +713,8 @@ BlockStatsList *qmp_query_blockstats(bool has_query_nod= es, BlockBackend *blk; BlockDriverState *bs; =20 + GRAPH_RDLOCK_GUARD_MAINLOOP(); + /* Just to be safe if query_nodes is not always initialized */ if (has_query_nodes && query_nodes) { for (bs =3D bdrv_next_node(NULL); bs; bs =3D bdrv_next_node(bs)) { --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721523; cv=none; d=zohomail.com; s=zohoarc; b=Kh9wNH16XKrU1/rjkTbrgscg0eucc2PgSxzhmujOFbQD1juwD5N7FcQFfepQCwV0ho2whGThmS5bUi1WIiudce5g3YbLlmuCrkymLjBGOLCWVHKikCB43Z1qs7Niq5zEXWuhJgbGISgIH3cVG3B4ovvKFPbS9hHlVKMceyqqmU4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721523; 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=W3XvTv0U/P/RmwzRf32w3+6vGDxoqsRsKf2+ruWO4Uk=; b=Dqv8vLL7Uxigw6dnOw1ffWUvNEj5NEpKSt3ZwZxBIb8tblnogNxgQjmtNc/QZgrBN9yo39eM+UVXGkADeUrtYuALKQjRGjgvKCikroYU2vhoHwd7WeSg1FiJzHk5JH0A5UNBi2ep48Hl9rv3DnEmo/hvAsUY4RYTNSTIHlTMw8Y= 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 1683721523083423.97397990195054; Wed, 10 May 2023 05:25:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiqA-0003o9-04; Wed, 10 May 2023 08:22:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipr-0002nI-KN for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipe-0007oN-09 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:23 -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-205-PNtvT4hAP_K3hoNGfvilMQ-1; Wed, 10 May 2023 08:22:01 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6A19581DB87; Wed, 10 May 2023 12:22:01 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id B048F63F86; Wed, 10 May 2023 12:22:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721324; 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=W3XvTv0U/P/RmwzRf32w3+6vGDxoqsRsKf2+ruWO4Uk=; b=hyNsHZ0Zv9de7neTGKQT6LKZzWRek5sBml9USBYovhFw1Risxz+7EbzuKh5cnlKZVR9NgH At6PSHDkYThB5OIvzDDjEubIeoQZ/te8Pz5VTMXGUWQbsjPBTqY0boswmxiZllMJjU7KwQ t13eGui22uQPi/86RplRllPtBPQrNLI= X-MC-Unique: PNtvT4hAP_K3hoNGfvilMQ-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 25/28] block: Mark bdrv_query_block_graph_info() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:08 +0200 Message-Id: <20230510122111.46566-26-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721523313100001 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_query_block_graph_info() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-19-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/qapi.h | 7 ++++--- qemu-img.c | 2 ++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/block/qapi.h b/include/block/qapi.h index 8773b9b191..18d48ddb70 100644 --- a/include/block/qapi.h +++ b/include/block/qapi.h @@ -25,6 +25,7 @@ #ifndef BLOCK_QAPI_H #define BLOCK_QAPI_H =20 +#include "block/graph-lock.h" #include "block/snapshot.h" #include "qapi/qapi-types-block-core.h" =20 @@ -43,9 +44,9 @@ void bdrv_query_image_info(BlockDriverState *bs, bool flat, bool skip_implicit_filters, Error **errp); -void bdrv_query_block_graph_info(BlockDriverState *bs, - BlockGraphInfo **p_info, - Error **errp); +void GRAPH_RDLOCK +bdrv_query_block_graph_info(BlockDriverState *bs, BlockGraphInfo **p_info, + Error **errp); =20 void bdrv_snapshot_dump(QEMUSnapshotInfo *sn); void bdrv_image_info_specific_dump(ImageInfoSpecific *info_spec, diff --git a/qemu-img.c b/qemu-img.c index 9aeac69fa6..9f9f0a7629 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2938,6 +2938,8 @@ static BlockGraphInfoList *collect_image_info_list(bo= ol image_opts, } bs =3D blk_bs(blk); =20 + GRAPH_RDLOCK_GUARD_MAINLOOP(); + /* * Note that the returned BlockGraphInfo object will not have * information about this image's backing node, because we have op= ened --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721481; cv=none; d=zohomail.com; s=zohoarc; b=DYsa8PLqz4gJsao8a9+/JlTaIJkY1St+KtjWDens4CAlQGgW2u+5pP+91vMT3U95JF5TpGkp1y+XfWhzDu/G1gPFnexm41CIGUMmeOGibRspGhhgRiao18JckCtwbZcBEJ14Cg8IOK5nEZVBCSKAZ8W04uikwlLEgrfEAXoEOBM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721481; 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=hnJryFoHOKfjZrLPQZOQDz1TDB2KI3ta4gyPzjuGPkQ=; b=D7Qt8TUZfOPPJqPq1jLiIVQmCac27+tvDdlaJTNfuldEa+98TnP5ghCt6bKB4N3asxBrD8orBf+017ZB8YqGTxqx96WLW4iTS9UZbO+A2+F6yQ2Sq6A+IgJzoeGWSRLryaa2llSa1mM9LeukDlPjpLItsjbMWVbAFNxqoSf6xco= 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 16837214817011009.3553106212826; Wed, 10 May 2023 05:24:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq3-0003IX-Ci; Wed, 10 May 2023 08:22:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipj-0002f8-ON for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipf-0007oa-0E for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:15 -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-LUIdnMy4OXSj0Ps7mul8iA-1; Wed, 10 May 2023 08:22:02 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 674E51C0879B; Wed, 10 May 2023 12:22:02 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id A0E7C18EC1; Wed, 10 May 2023 12:22:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721325; 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=hnJryFoHOKfjZrLPQZOQDz1TDB2KI3ta4gyPzjuGPkQ=; b=Fl16J+KWZEvNj/ZCf1FU404fTbLGJU0kHRGqMQrHAYukuDCEunoOS39nHxDnp3mkiU7ijo chyeKHchSdwI8TjbNwcfLrAwZGlWL54ogn4aW/vd+sCOdn2ZYaPTavjANLi4wNSeSW4y4+ ptD8MzB3Zwlt5NJ5OfIS/laffZ34rWU= X-MC-Unique: LUIdnMy4OXSj0Ps7mul8iA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 26/28] block: Mark bdrv_recurse_can_replace() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:09 +0200 Message-Id: <20230510122111.46566-27-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721482506100001 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_recurse_can_replace() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-20-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 5 +++-- include/block/block_int-common.h | 4 ++-- include/block/block_int-global-state.h | 4 ++-- block/blkverify.c | 5 +++-- block/mirror.c | 4 ++++ block/quorum.c | 4 ++-- blockdev.c | 3 +++ 7 files changed, 19 insertions(+), 10 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index ec3ddb17a8..f234bca0b6 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -163,8 +163,9 @@ int bdrv_amend_options(BlockDriverState *bs_new, QemuOp= ts *opts, Error **errp); =20 /* check if a named node can be replaced when doing drive-mirror */ -BlockDriverState *check_to_replace_node(BlockDriverState *parent_bs, - const char *node_name, Error **err= p); +BlockDriverState * GRAPH_RDLOCK +check_to_replace_node(BlockDriverState *parent_bs, const char *node_name, + Error **errp); =20 int no_coroutine_fn bdrv_activate(BlockDriverState *bs, Error **errp); =20 diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 37d094796e..024ded4fc2 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -217,8 +217,8 @@ struct BlockDriver { * same data as @bs without it affecting @bs's behavior (that is, * without it being visible to @bs's parents). */ - bool (*bdrv_recurse_can_replace)(BlockDriverState *bs, - BlockDriverState *to_replace); + bool GRAPH_RDLOCK_PTR (*bdrv_recurse_can_replace)( + BlockDriverState *bs, BlockDriverState *to_replace); =20 int (*bdrv_probe_device)(const char *filename); =20 diff --git a/include/block/block_int-global-state.h b/include/block/block_i= nt-global-state.h index 902406eb99..da5fb31089 100644 --- a/include/block/block_int-global-state.h +++ b/include/block/block_int-global-state.h @@ -225,8 +225,8 @@ int bdrv_child_try_set_perm(BdrvChild *c, uint64_t perm= , uint64_t shared, */ int bdrv_child_refresh_perms(BlockDriverState *bs, BdrvChild *c, Error **e= rrp); =20 -bool bdrv_recurse_can_replace(BlockDriverState *bs, - BlockDriverState *to_replace); +bool GRAPH_RDLOCK bdrv_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace); =20 /* * Default implementation for BlockDriver.bdrv_child_perm() that can diff --git a/block/blkverify.c b/block/blkverify.c index 1c16f86b2e..7326461f30 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -265,8 +265,9 @@ static int coroutine_fn GRAPH_RDLOCK blkverify_co_flush= (BlockDriverState *bs) return bdrv_co_flush(s->test_file->bs); } =20 -static bool blkverify_recurse_can_replace(BlockDriverState *bs, - BlockDriverState *to_replace) +static bool GRAPH_RDLOCK +blkverify_recurse_can_replace(BlockDriverState *bs, + BlockDriverState *to_replace) { BDRVBlkverifyState *s =3D bs->opaque; =20 diff --git a/block/mirror.c b/block/mirror.c index e48ed0af31..717442ca4d 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -747,7 +747,10 @@ static int mirror_exit_common(Job *job) * Cannot use check_to_replace_node() here, because that would * check for an op blocker on @to_replace, and we have our own * there. + * + * TODO Pull out the writer lock from bdrv_replace_node() to here */ + bdrv_graph_rdlock_main_loop(); if (bdrv_recurse_can_replace(src, to_replace)) { bdrv_replace_node(to_replace, target_bs, &local_err); } else { @@ -756,6 +759,7 @@ static int mirror_exit_common(Job *job) "would not lead to an abrupt change of visible data= ", to_replace->node_name, target_bs->node_name); } + bdrv_graph_rdunlock_main_loop(); bdrv_drained_end(target_bs); if (local_err) { error_report_err(local_err); diff --git a/block/quorum.c b/block/quorum.c index ff5a0a2da3..f28758cf2b 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -825,8 +825,8 @@ static coroutine_fn GRAPH_RDLOCK int quorum_co_flush(Bl= ockDriverState *bs) return result; } =20 -static bool quorum_recurse_can_replace(BlockDriverState *bs, - BlockDriverState *to_replace) +static bool GRAPH_RDLOCK +quorum_recurse_can_replace(BlockDriverState *bs, BlockDriverState *to_repl= ace) { BDRVQuorumState *s =3D bs->opaque; int i; diff --git a/blockdev.c b/blockdev.c index e464daea58..d141ca7a2d 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2961,6 +2961,9 @@ static void blockdev_mirror_common(const char *job_id= , BlockDriverState *bs, BlockDriverState *unfiltered_bs; int job_flags =3D JOB_DEFAULT; =20 + GLOBAL_STATE_CODE(); + GRAPH_RDLOCK_GUARD_MAINLOOP(); + if (!has_speed) { speed =3D 0; } --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721475; cv=none; d=zohomail.com; s=zohoarc; b=IDmaQrzqiI4NGfoirzyIawK+IKH9vhpDT6vccYY2D/AOwBKH5f+biPHvYNhHRJJxadnWt/4p9jQqIaVsA5gUQX49EIYyS2LDQLBHG4KYXytwFA/Znx21obo95ccD6Gc8jGNe34nKGV/C10VT3Ih5Q1ytrgkBZ4kRLdhmlYcyACA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721475; 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=VYzP2+MoxRIsAXhhnClbZ0nRAdJq6JskrQsc0DsYbcI=; b=hydp8bgcDnjDr1O/c7SqY/Pgg3xUYYAmT7B7hkmAYk7f6jRm7NLe+5hwF5x7XsSifrQND1a+WXS3ECiMADi7Ak3a02ljml91+3SXeGz/+Pa6WrqDGiCPn8Qeq9TWU50VvK26dTZ2gXDle0H2f2q7M51xNuFfZ0AUdbnx1e5T2IU= 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 1683721475474172.13669188893437; Wed, 10 May 2023 05:24:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq8-0003k9-UH; Wed, 10 May 2023 08:22:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipl-0002gx-3a for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipf-0007pc-U2 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:16 -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-33-wzPXXlsVMPmZUYzzNJ4MoA-1; Wed, 10 May 2023 08:22:03 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 723E91C0513D; Wed, 10 May 2023 12:22:03 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9EEA063F86; Wed, 10 May 2023 12:22:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721329; 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=VYzP2+MoxRIsAXhhnClbZ0nRAdJq6JskrQsc0DsYbcI=; b=DltKoQ4eu3qbTIAwiM5P6c58kgLCNWWKl+phFXSmUvMe/PAK8YOWZzbu8yElJA88hc5yh/ SMh81qTMKUv6p5Ezsr/D3XJSqzWBpSRCD+noK+ar+zIqryPykInLTdbu4IqfXbbPLPEZQo kJ7QgXZtAoLRGFEG9atfU+d7GBTpB9Q= X-MC-Unique: wzPXXlsVMPmZUYzzNJ4MoA-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 27/28] block: Mark bdrv_refresh_limits() and callers GRAPH_RDLOCK Date: Wed, 10 May 2023 14:21:10 +0200 Message-Id: <20230510122111.46566-28-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721477127100007 Content-Type: text/plain; charset="utf-8" This adds GRAPH_RDLOCK annotations to declare that callers of bdrv_refresh_limits() need to hold a reader lock for the graph because it accesses the children list of a node. Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Message-Id: <20230504115750.54437-21-kwolf@redhat.com> Signed-off-by: Kevin Wolf --- include/block/block-global-state.h | 5 ++++- include/block/block_int-common.h | 3 ++- block.c | 9 +++++++++ block/io.c | 1 - 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/include/block/block-global-state.h b/include/block/block-globa= l-state.h index f234bca0b6..2d93423d35 100644 --- a/include/block/block-global-state.h +++ b/include/block/block-global-state.h @@ -133,7 +133,10 @@ int bdrv_reopen_set_read_only(BlockDriverState *bs, bo= ol read_only, BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); void bdrv_refresh_filename(BlockDriverState *bs); -void bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **= errp); + +void GRAPH_RDLOCK +bdrv_refresh_limits(BlockDriverState *bs, Transaction *tran, Error **errp); + int bdrv_commit(BlockDriverState *bs); int bdrv_make_empty(BdrvChild *c, Error **errp); int bdrv_change_backing_file(BlockDriverState *bs, const char *backing_fil= e, diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 024ded4fc2..4909876756 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -334,7 +334,8 @@ struct BlockDriver { int (*bdrv_debug_resume)(BlockDriverState *bs, const char *tag); bool (*bdrv_debug_is_suspended)(BlockDriverState *bs, const char *tag); =20 - void (*bdrv_refresh_limits)(BlockDriverState *bs, Error **errp); + void GRAPH_RDLOCK_PTR (*bdrv_refresh_limits)( + BlockDriverState *bs, Error **errp); =20 /* * Returns 1 if newly created images are guaranteed to contain only diff --git a/block.c b/block.c index 1bc766c778..dad9a4fa43 100644 --- a/block.c +++ b/block.c @@ -1667,7 +1667,10 @@ bdrv_open_driver(BlockDriverState *bs, BlockDriver *= drv, const char *node_name, return ret; } =20 + bdrv_graph_rdlock_main_loop(); bdrv_refresh_limits(bs, NULL, &local_err); + bdrv_graph_rdunlock_main_loop(); + if (local_err) { error_propagate(errp, local_err); return -EINVAL; @@ -3419,7 +3422,9 @@ static int bdrv_set_file_or_backing_noperm(BlockDrive= rState *parent_bs, } =20 out: + bdrv_graph_rdlock_main_loop(); bdrv_refresh_limits(parent_bs, tran, NULL); + bdrv_graph_rdunlock_main_loop(); =20 return 0; } @@ -4917,7 +4922,9 @@ static void bdrv_reopen_commit(BDRVReopenState *reope= n_state) qdict_del(bs->explicit_options, "backing"); qdict_del(bs->options, "backing"); =20 + bdrv_graph_rdlock_main_loop(); bdrv_refresh_limits(bs, NULL, NULL); + bdrv_graph_rdunlock_main_loop(); bdrv_refresh_total_sectors(bs, bs->total_sectors); } =20 @@ -5316,7 +5323,9 @@ int bdrv_append(BlockDriverState *bs_new, BlockDriver= State *bs_top, out: tran_finalize(tran, ret); =20 + bdrv_graph_rdlock_main_loop(); bdrv_refresh_limits(bs_top, NULL, NULL); + bdrv_graph_rdunlock_main_loop(); =20 if (new_context && old_context !=3D new_context) { aio_context_release(new_context); diff --git a/block/io.c b/block/io.c index 3bf9ef9d87..58557f2f96 100644 --- a/block/io.c +++ b/block/io.c @@ -160,7 +160,6 @@ void bdrv_refresh_limits(BlockDriverState *bs, Transact= ion *tran, Error **errp) bool have_limits; =20 GLOBAL_STATE_CODE(); - assume_graph_lock(); /* FIXME */ =20 if (tran) { BdrvRefreshLimitsState *s =3D g_new(BdrvRefreshLimitsState, 1); --=20 2.40.1 From nobody Mon May 20 20:10:12 2024 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=1683721496; cv=none; d=zohomail.com; s=zohoarc; b=C0s8OwEUt/rstR14SaU5Vcfr+mj9HewG/qhrBzHB11UxrdvI+7eM0O1zAtp1effmUA/MEybHGtjhlBpcdwKzp07UZBdlVXqyqXR8uY+cwDpUdAqCmv13aDHRYKOsxIyKKLI12rabhLSyuA36VrNRav2nq3JxoM4CcSVYFuZYUaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683721496; 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=bhV8PxGfIM2CiMvz/jmOrzBWe7WQGQrw+jf2GRjCHGA=; b=Cpd+KLRHwmSzjB/hGO/vilVLVZ+hvgsTSNg8fAC9H8FLwFRkIrij4WT82OVMZotQVqU9YpnAZWirFQVpM4X0yAqdLy1RlJatXn6hPsJfiMw9I++DK20lws8bQb+WVJBGjuf4d7WQu0LWLo9mvJpFELA7IeyofYGRb9v82Lno0ok= 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 1683721496980263.9356263775235; Wed, 10 May 2023 05:24:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pwiq5-0003WJ-GZ; Wed, 10 May 2023 08:22:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipk-0002fB-56 for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwipe-0007oh-WF for qemu-devel@nongnu.org; Wed, 10 May 2023 08:22: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-14-UjWJF8LQNE2icX92kcQZtw-1; Wed, 10 May 2023 08:22:05 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B45B886463; Wed, 10 May 2023 12:22:04 +0000 (UTC) Received: from merkur.fritz.box (unknown [10.39.194.148]) by smtp.corp.redhat.com (Postfix) with ESMTP id C85DF18EC1; Wed, 10 May 2023 12:22:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683721326; 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=bhV8PxGfIM2CiMvz/jmOrzBWe7WQGQrw+jf2GRjCHGA=; b=iteIX0qSecRkocoleRYrK3gk27kuGeMNB8vI/Xg5sVPb8B5Yc+nmYlv6WE8HeYMIqdduf8 tkCwO+7QJgxDuc/sXgkGjLEaUXYD9UL2G99geoPhVmoM3l1pSUqXtFgr2magtsXYKDlKU3 cHPMCnN2GK1z6b/afXY4JGHjBuuMwwM= X-MC-Unique: UjWJF8LQNE2icX92kcQZtw-1 From: Kevin Wolf To: qemu-block@nongnu.org Cc: kwolf@redhat.com, richard.henderson@linaro.org, qemu-devel@nongnu.org Subject: [PULL 28/28] block: compile out assert_bdrv_graph_readable() by default Date: Wed, 10 May 2023 14:21:11 +0200 Message-Id: <20230510122111.46566-29-kwolf@redhat.com> In-Reply-To: <20230510122111.46566-1-kwolf@redhat.com> References: <20230510122111.46566-1-kwolf@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1683721499235100011 Content-Type: text/plain; charset="utf-8" From: Stefan Hajnoczi reader_count() is a performance bottleneck because the global aio_context_list_lock mutex causes thread contention. Put this debugging assertion behind a new ./configure --enable-debug-graph-lock option and disable it by default. The --enable-debug-graph-lock option is also enabled by the more general --enable-debug option. Signed-off-by: Stefan Hajnoczi Message-Id: <20230501173443.153062-1-stefanha@redhat.com> Reviewed-by: Kevin Wolf Signed-off-by: Kevin Wolf --- meson_options.txt | 2 ++ configure | 1 + block/graph-lock.c | 3 +++ meson.build | 2 ++ scripts/meson-buildoptions.sh | 4 ++++ 5 files changed, 12 insertions(+) diff --git a/meson_options.txt b/meson_options.txt index 66ca350029..d8330a1f71 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -319,6 +319,8 @@ option('rng_none', type: 'boolean', value: false, description: 'dummy RNG, avoid using /dev/(u)random and getrandom()= ') option('coroutine_pool', type: 'boolean', value: true, description: 'coroutine freelist (better performance)') +option('debug_graph_lock', type: 'boolean', value: false, + description: 'graph lock debugging support') option('debug_mutex', type: 'boolean', value: false, description: 'mutex debugging support') option('debug_stack_usage', type: 'boolean', value: false, diff --git a/configure b/configure index 77c03315f8..243e2e0a0d 100755 --- a/configure +++ b/configure @@ -816,6 +816,7 @@ for opt do --enable-debug) # Enable debugging options that aren't excessively noisy debug_tcg=3D"yes" + meson_option_parse --enable-debug-graph-lock "" meson_option_parse --enable-debug-mutex "" meson_option_add -Doptimization=3D0 fortify_source=3D"no" diff --git a/block/graph-lock.c b/block/graph-lock.c index 639526608f..377884c3a9 100644 --- a/block/graph-lock.c +++ b/block/graph-lock.c @@ -265,7 +265,10 @@ void bdrv_graph_rdunlock_main_loop(void) =20 void assert_bdrv_graph_readable(void) { + /* reader_count() is slow due to aio_context_list_lock lock contention= */ +#ifdef CONFIG_DEBUG_GRAPH_LOCK assert(qemu_in_main_thread() || reader_count()); +#endif } =20 void assert_bdrv_graph_writable(void) diff --git a/meson.build b/meson.build index c56e0fec9e..646555420f 100644 --- a/meson.build +++ b/meson.build @@ -1963,6 +1963,7 @@ if get_option('debug_stack_usage') and have_coroutine= _pool have_coroutine_pool =3D false endif config_host_data.set10('CONFIG_COROUTINE_POOL', have_coroutine_pool) +config_host_data.set('CONFIG_DEBUG_GRAPH_LOCK', get_option('debug_graph_lo= ck')) config_host_data.set('CONFIG_DEBUG_MUTEX', get_option('debug_mutex')) config_host_data.set('CONFIG_DEBUG_STACK_USAGE', get_option('debug_stack_u= sage')) config_host_data.set('CONFIG_GPROF', get_option('gprof')) @@ -3841,6 +3842,7 @@ summary_info +=3D {'PIE': get_option('b= _pie')} summary_info +=3D {'static build': config_host.has_key('CONFIG_STATIC= ')} summary_info +=3D {'malloc trim support': has_malloc_trim} summary_info +=3D {'membarrier': have_membarrier} +summary_info +=3D {'debug graph lock': get_option('debug_graph_lock')} summary_info +=3D {'debug stack usage': get_option('debug_stack_usage')} summary_info +=3D {'mutex debugging': get_option('debug_mutex')} summary_info +=3D {'memory allocator': get_option('malloc')} diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 34d82dec53..2805d1c145 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -23,6 +23,8 @@ meson_options_help() { printf "%s\n" ' QEMU' printf "%s\n" ' --enable-cfi Control-Flow Integrity (CFI)' printf "%s\n" ' --enable-cfi-debug Verbose errors in case of CFI = violation' + printf "%s\n" ' --enable-debug-graph-lock' + printf "%s\n" ' graph lock debugging support' printf "%s\n" ' --enable-debug-mutex mutex debugging support' printf "%s\n" ' --enable-debug-stack-usage' printf "%s\n" ' measure coroutine stack usage' @@ -254,6 +256,8 @@ _meson_option_parse() { --datadir=3D*) quote_sh "-Ddatadir=3D$2" ;; --enable-dbus-display) printf "%s" -Ddbus_display=3Denabled ;; --disable-dbus-display) printf "%s" -Ddbus_display=3Ddisabled ;; + --enable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=3Dtrue ;; + --disable-debug-graph-lock) printf "%s" -Ddebug_graph_lock=3Dfalse ;; --enable-debug-mutex) printf "%s" -Ddebug_mutex=3Dtrue ;; --disable-debug-mutex) printf "%s" -Ddebug_mutex=3Dfalse ;; --enable-debug-stack-usage) printf "%s" -Ddebug_stack_usage=3Dtrue ;; --=20 2.40.1