From nobody Tue May 14 07:07:57 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=1668607483; cv=none; d=zohomail.com; s=zohoarc; b=W9UEoVA5iPmEQPaph21loc0c1V+GZqeDnusCtQb/7ITsL93H7LIyPijytW6fVk2VfIbnWclNKERLWLFz0F0yApWAVEa7AXt/5UqepGHq+KM4bHbwGQ+9nJEtDpNI49ULZM4GpIByQefb9WAw2mZE/L3+ahw0zFdvLcjqxqqMhwE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607483; 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=YSBmp9TWRoxCrsN4SW7/9XhtxuOKnwbj3jjC4erRstI=; b=WPXdc1dfm2/GTg6n33FB1+FUO8v6J8pUbCx+32JQuwKtzAvMPaiy0CeNgfIu9Jh/OS/A8vMDY9dzLTwwnSyP7FnVpTZMoDhQeN3cXxfTRn6dsCnHA3g3KQpQ9PqBXhO72m86bRqqqBrBMqU/unMq36sxkpDNGGvM5z/BVwi/FD0= 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 1668607483719464.38236563845; Wed, 16 Nov 2022 06:04:43 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrI-0007cA-UA; Wed, 16 Nov 2022 08:53:44 -0500 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 1ovIrG-0007UO-Ct for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 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 1ovIrE-0002ii-KI for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 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-255-D35UY6UPPB-pxErARoNmgg-1; Wed, 16 Nov 2022 08:53:35 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 498371C09B71; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id F19DE40E80E4; Wed, 16 Nov 2022 13:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606819; 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=YSBmp9TWRoxCrsN4SW7/9XhtxuOKnwbj3jjC4erRstI=; b=Y1CeMPqvyKDdbwNvI3kHnVQuMRuWvSZLlL4fuUGrXE5ihD4PFvuqPXpxaJe0UMDZ17PTHT B8UV/TuSNulODUa780omXf9sO8VmbDYRdQOlfRQNjGn8qemCz0Ou9zzB6i7oc/8fIzgK1T TaARy5nCGIfs+/8kM3mFe79pe/sSGmI= X-MC-Unique: D35UY6UPPB-pxErARoNmgg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 1/6] block: assert that bdrv_co_create is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:26 -0500 Message-Id: <20221116135331.3052923-2-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668607486303100003 Content-Type: text/plain; charset="utf-8" This function is either called by bdrv_create(), which always takes care of creating a new coroutine, or by bdrv_create_file(), which is only called by BlockDriver->bdrv_co_create_opts callbacks, invoked by bdrv_co_create(). Protecting bdrv_co_create() implies that BlockDriver->bdrv_co_create_opts is always called with graph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 1 + include/block/block_int-common.h | 1 + 2 files changed, 2 insertions(+) diff --git a/block.c b/block.c index c7611bed9e..e54ed300d7 100644 --- a/block.c +++ b/block.c @@ -537,6 +537,7 @@ int coroutine_fn bdrv_co_create(BlockDriver *drv, const= char *filename, assert(qemu_in_coroutine()); assert(*errp =3D=3D NULL); assert(drv); + assert_bdrv_graph_readable(); =20 if (!drv->bdrv_co_create_opts) { error_setg(errp, "Driver '%s' does not support image creation", diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index db97d61836..d45961a1d1 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -253,6 +253,7 @@ struct BlockDriver { =20 int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, Error **errp); + /* Called with graph rdlock taken */ int coroutine_fn (*bdrv_co_create_opts)(BlockDriver *drv, const char *filename, QemuOpts *opts, --=20 2.31.1 From nobody Tue May 14 07:07:57 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=1668606907; cv=none; d=zohomail.com; s=zohoarc; b=FVQSGBNKCT5IPFqIWos82KSekXIfc09XtjGYg7skpKwy8GGxxPGHozsnJle/o012uy4bcPosKV+KrQT1rwVAghcI5p8YShXTgWOafZsollcCFBPBhk85VsCRiS2np83jn+eAIgExo4PWUuiwD5bk6cKg8wigkudRaerYO5z2z80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668606907; 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=QH/+/7UJYS5MtViHT79nNUCSFC9rW6fu+qCQmkWOUeI=; b=CabB84VPsSq3X8QM/cI/EuJMRXwiyU11QBZAYg+kwXbSed6jx1JllYP852+3v782zmS1DDS5NlLDSefjdOBH44ytCi4bni2Za0ta4G5LgpBuEpHm/K/2z8ssVve+ONPPeXTEhjB7UySbWwC46L0AG9mC2wL1obwuLLXhaUuntcU= 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 1668606907055502.35597643510096; Wed, 16 Nov 2022 05:55:07 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrL-0007if-E8; Wed, 16 Nov 2022 08:53:47 -0500 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 1ovIrH-0007Y4-Oz for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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 1ovIrF-0002jY-N6 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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-172-afC2oFH9MFiU6PQnct7Kog-1; Wed, 16 Nov 2022 08:53:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9D5E43C10688; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5277340E80E3; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606821; 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=QH/+/7UJYS5MtViHT79nNUCSFC9rW6fu+qCQmkWOUeI=; b=YfPbvYO8EMnfVsKYVwmSolzmX9h6H2K83iexc0bR2JYBBmXt87i3Fc57zp4zegEBAaNXfx HwfgzXoUINqbwH0kf+US0iWpKOlCl3cI5+hbIqRYmocrElgVM58nOu+SEJMWfNf7h2G0jj 9Gi2t1ufI6irlEiM7LMN+HbdN0osG0g= X-MC-Unique: afC2oFH9MFiU6PQnct7Kog-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 2/6] block: assert that BlockDriver->bdrv_co_{amend/create} are called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:27 -0500 Message-Id: <20221116135331.3052923-3-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668606908004100001 Content-Type: text/plain; charset="utf-8" Both functions are only called by Job->run() callbacks, therefore they must take the lock in the *_run() implementation. Signed-off-by: Emanuele Giuseppe Esposito --- block/amend.c | 1 + block/create.c | 1 + include/block/block_int-common.h | 2 ++ 3 files changed, 4 insertions(+) diff --git a/block/amend.c b/block/amend.c index f696a006e3..a155b6889b 100644 --- a/block/amend.c +++ b/block/amend.c @@ -45,6 +45,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); diff --git a/block/create.c b/block/create.c index 4df43f11f4..4048d71265 100644 --- a/block/create.c +++ b/block/create.c @@ -43,6 +43,7 @@ static int coroutine_fn blockdev_create_run(Job *job, Err= or **errp) int ret; =20 GLOBAL_STATE_CODE(); + GRAPH_RDLOCK_GUARD(); =20 job_progress_set_remaining(&s->common, 1); ret =3D s->drv->bdrv_co_create(s->opts, errp); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index d45961a1d1..1e9bb91c98 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -251,6 +251,7 @@ struct BlockDriver { Error **errp); void (*bdrv_close)(BlockDriverState *bs); =20 + /* Called with graph rdlock taken */ int coroutine_fn (*bdrv_co_create)(BlockdevCreateOptions *opts, Error **errp); /* Called with graph rdlock taken */ @@ -471,6 +472,7 @@ struct BlockDriver { =20 int (*bdrv_probe)(const uint8_t *buf, int buf_size, const char *filena= me); =20 + /* Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_amend)(BlockDriverState *bs, BlockdevAmendOptions *opts, bool force, --=20 2.31.1 From nobody Tue May 14 07:07:57 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=1668607159; cv=none; d=zohomail.com; s=zohoarc; b=iDEnACwu6h4oFe8qML9dRvMtQyPGRJhW/kcYrqygI4IU9KqZRyF+3SfxaLvZcM3vzdthdORxBfgIrv3SbYTrx/vAbF5JWZOBF+PL12HwyA9wnw5FoFoebwEyZDhlfaYlOzQzuqip97oNT3qXroOrzUKi+E/IViJP/+wucE0kDmI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607159; 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=Ro20h428+MmQ1aHxt24h1z4UYKTh74mpEKt522DW974=; b=QAPz2XTQ7wQiQ2SZqVhTb6zazNU1j5RsSwxFMzYged9/G0aTfsGV3spPfHhhCh/l5Hxjul5wyCNVxW9yK6YyiLg4D1YW8+vhyyNOds1SUY3OJewG6eZIA7XhfXoXbulSy0oApYv09unT4MnggV8jJjLPBCbg/ColxI4lBLNaUJ4= 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 1668607159334180.0876689720394; Wed, 16 Nov 2022 05:59:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrJ-0007dc-JZ; Wed, 16 Nov 2022 08:53:45 -0500 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 1ovIrH-0007YG-QJ for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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 1ovIrF-0002j5-CV for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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-335-nseocApXNtKdLI62IGyCBg-1; Wed, 16 Nov 2022 08:53:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F142B3801F5A; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id A69B140E80E3; Wed, 16 Nov 2022 13:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; 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=Ro20h428+MmQ1aHxt24h1z4UYKTh74mpEKt522DW974=; b=VK0jKvRoNZHhzKL6wrEJJtVtf3o0kza3BLZVtUuA5moN52sip63+TFlBEjlAzSO0USNPU5 pg6jcdGsDAASo7ULfoW355QbBrjTwL6pgPKcyrk3UvQ2YB9fd0NlZu/gA8vkR4SPNCOxKa V6k4GTSIbVK1WD7IwPRtM6XNiCw94bY= X-MC-Unique: nseocApXNtKdLI62IGyCBg-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 3/6] block: assert that BlockDriver->bdrv_co_copy_range_{from/to} is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:28 -0500 Message-Id: <20221116135331.3052923-4-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668607159549100001 Content-Type: text/plain; charset="utf-8" The only non-protected caller is convert_co_copy_range(), all other callers are BlockDriver callbacks that already take the rdlock. Signed-off-by: Emanuele Giuseppe Esposito --- block/block-backend.c | 2 ++ block/io.c | 5 +++++ include/block/block_int-common.h | 4 ++++ qemu-img.c | 4 +++- 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/block/block-backend.c b/block/block-backend.c index 9e1c689e84..6f0dd15808 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -2631,6 +2631,8 @@ int coroutine_fn blk_co_copy_range(BlockBackend *blk_= in, int64_t off_in, if (r) { return r; } + + GRAPH_RDLOCK_GUARD(); return bdrv_co_copy_range(blk_in->root, off_in, blk_out->root, off_out, bytes, read_flags, write_flags); diff --git a/block/io.c b/block/io.c index 831f277e85..62c0b3a390 100644 --- a/block/io.c +++ b/block/io.c @@ -3165,6 +3165,7 @@ static int coroutine_fn bdrv_co_copy_range_internal( { BdrvTrackedRequest req; int ret; + assert_bdrv_graph_readable(); =20 /* TODO We can support BDRV_REQ_NO_FALLBACK here */ assert(!(read_flags & BDRV_REQ_NO_FALLBACK)); @@ -3246,6 +3247,7 @@ int coroutine_fn bdrv_co_copy_range_from(BdrvChild *s= rc, int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); trace_bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, @@ -3263,6 +3265,7 @@ int coroutine_fn bdrv_co_copy_range_to(BdrvChild *src= , int64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); trace_bdrv_co_copy_range_to(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); return bdrv_co_copy_range_internal(src, src_offset, dst, dst_offset, @@ -3275,6 +3278,8 @@ int coroutine_fn bdrv_co_copy_range(BdrvChild *src, i= nt64_t src_offset, BdrvRequestFlags write_flags) { IO_CODE(); + assert_bdrv_graph_readable(); + return bdrv_co_copy_range_from(src, src_offset, dst, dst_offset, bytes, read_flags, write_flags); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 1e9bb91c98..9e441cb93b 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -574,6 +574,8 @@ struct BlockDriver { * * See the comment of bdrv_co_copy_range for the parameter and return = value * semantics. + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_copy_range_from)(BlockDriverState *bs, BdrvChild *src, @@ -592,6 +594,8 @@ struct BlockDriver { * * See the comment of bdrv_co_copy_range for the parameter and return = value * semantics. + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_copy_range_to)(BlockDriverState *bs, BdrvChild *src, diff --git a/qemu-img.c b/qemu-img.c index 33703a6d92..2086cf6eed 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2027,7 +2027,9 @@ retry: =20 if (s->ret =3D=3D -EINPROGRESS) { if (copy_range) { - ret =3D convert_co_copy_range(s, sector_num, n); + WITH_GRAPH_RDLOCK_GUARD() { + ret =3D convert_co_copy_range(s, sector_num, n); + } if (ret) { s->copy_range =3D false; goto retry; --=20 2.31.1 From nobody Tue May 14 07:07:57 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=1668607574; cv=none; d=zohomail.com; s=zohoarc; b=ZrcBoNAGuyiPoxs9FugiNrjtd8R7KmwL3qTHRTyEtF2mo3Kx5W1H/PQZjRhZKjA3Gtw6vP0uUKyFbl7USeJHa8qbuo6FbX+wW8XaZ2NjEsiPuiDahRWaRKfVncO0XeZWpt6uCqzI8QkQ/NmlaQooTtxmoopjwErwVDMjSXm1gqk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607574; 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=NNpqTpAQbuZtCAGRbUHSH2DtrE1j72lEjkUIqHAQEgE=; b=E+B/IAj3/s8XOowuxoXg/m4upPe9MbvWcGAdtn0TABJML0vPyY/5l/uA8uij86lKjhSBjptBrCVJNMuiUiNGvJHu7TapW3pAUG/Trtp8S+2NTZVTEgKuE/zrxaE06Cmx1UKPv93H4dSK6wKkhRoT9o6xq/hgwIx8+q5s2cj9X+g= 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 1668607574015912.4286884753959; Wed, 16 Nov 2022 06:06:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrI-0007cC-U2; Wed, 16 Nov 2022 08:53:44 -0500 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 1ovIrG-0007Uc-Fl for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 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 1ovIrE-0002ih-HY for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:42 -0500 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-544-rSIcNVqQOi2vVx4yrjz13g-1; Wed, 16 Nov 2022 08:53:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51B55811E7A; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067BD40C6EC3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; 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=NNpqTpAQbuZtCAGRbUHSH2DtrE1j72lEjkUIqHAQEgE=; b=Dr1jaqMaLXowBE2a+UngA0nuz4fKOrKOe/Itis1c6EAca5l79I692JdZTq0zedRZjz2mgh Dt+Q6e21HqD1A+w3f8ETJPW4bo0fqaHugawUSk48JlRRlbYIg9tpCbXhBoDXyH6472SY6t QSq6MzhAsclDh46SBIB+AjcDoA3hmoA= X-MC-Unique: rSIcNVqQOi2vVx4yrjz13g-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 4/6] block/dirty-bitmap: assert that BlockDriver->bdrv_co_*_dirty_bitmap are always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:29 -0500 Message-Id: <20221116135331.3052923-5-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668607575377100003 Content-Type: text/plain; charset="utf-8" The only callers are the respective bdrv_*_dirty_bitmap() functions that take care of creating a new coroutine (that already takes the graph rdlock). Signed-off-by: Emanuele Giuseppe Esposito --- block/dirty-bitmap.c | 2 ++ include/block/block_int-common.h | 2 ++ 2 files changed, 4 insertions(+) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 21cf592889..92c70a7282 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -392,6 +392,7 @@ int coroutine_fn bdrv_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *n= ame, Error **errp) { + assert_bdrv_graph_readable(); if (bs->drv && bs->drv->bdrv_co_remove_persistent_dirty_bitmap) { return bs->drv->bdrv_co_remove_persistent_dirty_bitmap(bs, name, e= rrp); } @@ -413,6 +414,7 @@ bdrv_co_can_store_new_dirty_bitmap(BlockDriverState *bs= , const char *name, uint32_t granularity, Error **errp) { BlockDriver *drv =3D bs->drv; + assert_bdrv_graph_readable(); =20 if (!drv) { error_setg_errno(errp, ENOMEDIUM, diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 9e441cb93b..3064822508 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -789,9 +789,11 @@ struct BlockDriver { void (*bdrv_drain_end)(BlockDriverState *bs); =20 bool (*bdrv_supports_persistent_dirty_bitmap)(BlockDriverState *bs); + /* Called with graph rdlock held. */ bool coroutine_fn (*bdrv_co_can_store_new_dirty_bitmap)( BlockDriverState *bs, const char *name, uint32_t granularity, Error **errp); + /* Called with graph rdlock held. */ int coroutine_fn (*bdrv_co_remove_persistent_dirty_bitmap)( BlockDriverState *bs, const char *name, Error **errp); }; --=20 2.31.1 From nobody Tue May 14 07:07:57 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=1668606865; cv=none; d=zohomail.com; s=zohoarc; b=Z7wBsyJAQ4h4pKw+WV9zxTMFfixSZYZT3uCpTgKaKv2AtrenbaHKNZMevO93mPkULPsax/SgiMSwrc81L38Nk++YBloTxv7sHD9r3fXEIZh2A52+Lp1+nn9hmZ1ksjSbEgkP/1V36KcIy16wTD+jxzBXY5Yqmc/9Fm70IpHzJGw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668606865; 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=dmIaFsLSCEXhvHzxeUI8wryLJNEgtrYu1PgD6PMFDew=; b=nlLruca/iXEMJ4AQ5+fogwC63z+MXbanE4ok0SdVLAZjpXP3rJJNWWmHVQemT4i0pWcmIhCMP3x1CyWG5Pe2+6gNOwx00T00RzaDiZZ7jTyT28ovwuMxgzo/zEuyFMvq+lnT9TThcq6VBYYvSPBgalWoT+mT/NKSjSCzHxLgQhQ= 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 1668606865575598.3608102210757; Wed, 16 Nov 2022 05:54:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrG-0007Ud-JM; Wed, 16 Nov 2022 08:53:42 -0500 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 1ovIrF-0007Pq-6s for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:41 -0500 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 1ovIrD-0002hy-63 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:40 -0500 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-399-4q-QmLdYOhOZcDcL7g6rqQ-1; Wed, 16 Nov 2022 08:53:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A5A9F857F92; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5A63E40E80E3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606818; 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=dmIaFsLSCEXhvHzxeUI8wryLJNEgtrYu1PgD6PMFDew=; b=KeRVNPh/A3sxqKMJD+9/nHAjISO/GXUyH7XZu9bR+ATIBu/cba1a2+heqdSQBnYYALt6s2 gsV7mhqsiUOwDQ4ofOqUU4IYk4m5bSSPgp7DO5Hix2RQT1gG/FXvK+6DM65Rnv/bJf+Wfp B//fZxJgG4N8zhp0vfFIk2Dz4DkOghk= X-MC-Unique: 4q-QmLdYOhOZcDcL7g6rqQ-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 5/6] block/io: assert that BlockDriver->bdrv_co_*_snapshot_* are always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:30 -0500 Message-Id: <20221116135331.3052923-6-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668606865894100001 Content-Type: text/plain; charset="utf-8" The only callers are other callback functions that already run with the graph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block/io.c | 2 ++ include/block/block_int-common.h | 3 +++ 2 files changed, 5 insertions(+) diff --git a/block/io.c b/block/io.c index 62c0b3a390..7d1d0c48b0 100644 --- a/block/io.c +++ b/block/io.c @@ -3449,6 +3449,7 @@ bdrv_co_preadv_snapshot(BdrvChild *child, int64_t off= set, int64_t bytes, BlockDriver *drv =3D bs->drv; int ret; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return -ENOMEDIUM; @@ -3474,6 +3475,7 @@ bdrv_co_snapshot_block_status(BlockDriverState *bs, BlockDriver *drv =3D bs->drv; int ret; IO_CODE(); + assert_bdrv_graph_readable(); =20 if (!drv) { return -ENOMEDIUM; diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 3064822508..03bd28e3c9 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -652,9 +652,12 @@ struct BlockDriver { * - be able to select a specific snapshot * - receive the snapshot's actual length (which may differ from bs's * length) + * + * Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_preadv_snapshot)(BlockDriverState *bs, int64_t offset, int64_t bytes, QEMUIOVector *qiov, size_t qiov_off= set); + /* Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_snapshot_block_status)(BlockDriverState *bs, bool want_zero, int64_t offset, int64_t bytes, int64_t *pnum, int64_t *map, BlockDriverState **file); --=20 2.31.1 From nobody Tue May 14 07:07:57 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=1668607197; cv=none; d=zohomail.com; s=zohoarc; b=JCrdYm1qDel2u7r6OijSkjqqq1tjkJu+6+0h2KKEv7AOp12Vmce39Id3H1YLyOvYmAoBZqhYp28lqiD/tzWhbNjRYdgbXe9AftzemVK5DN7LvHxw4Y2k1L2Y+cBTCVqcvt5lvV6hXdVmrqMe3B4Oj9u9I+/sqzUhtdPlcoqgNiU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1668607197; 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=aRNlHc5dNco8sL82R2DreaesGOuYlSclpQ+GSk1CEkU=; b=Y4QLljwlMCfDZjWf/IcH3iJ0ZjOax6EbAEf75aIMX7QjTzxZFzwMoi2ZdO3V9rZAO5f3WZlyl8CIPu+ipNzuSLqY6eCLEZbaNb//CAp6DcTSbIszu74/w/vhDf5pLUtOTfyP6zZC63t9zx1c8iwiX7DQ2zahOWY87YrynHYCnH8= 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 1668607197911674.4910277439119; Wed, 16 Nov 2022 05:59:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ovIrK-0007gO-Kb; Wed, 16 Nov 2022 08:53:46 -0500 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 1ovIrH-0007YB-Q9 for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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 1ovIrF-0002j1-7d for qemu-devel@nongnu.org; Wed, 16 Nov 2022 08:53:43 -0500 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-550-owxhRB9nNuy7SGfRHTV4GA-1; Wed, 16 Nov 2022 08:53:37 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 06955185A7A9; Wed, 16 Nov 2022 13:53:37 +0000 (UTC) Received: from virtlab701.virt.lab.eng.bos.redhat.com (virtlab701.virt.lab.eng.bos.redhat.com [10.19.152.228]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF5C940E80E3; Wed, 16 Nov 2022 13:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1668606820; 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=aRNlHc5dNco8sL82R2DreaesGOuYlSclpQ+GSk1CEkU=; b=Xm+0RCJwNJ2LIyA1/R8YeIGyLMiKdpvCKmV6deay7vVB2tRTUg1Xoj0GDFY5B75rDKM7p4 aUNLxfVH2PG1L2L89Xn91+fYpA+vD2qvZut/qmrsq91acL1lSMnjf60qhBbfXqT5APfSTR eKRJ4eTHip7utS0smCVLjkBDEjnNLas= X-MC-Unique: owxhRB9nNuy7SGfRHTV4GA-1 From: Emanuele Giuseppe Esposito To: qemu-block@nongnu.org Cc: Kevin Wolf , Hanna Reitz , John Snow , Paolo Bonzini , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , Fam Zheng , Eric Blake , qemu-devel@nongnu.org, Emanuele Giuseppe Esposito Subject: [PATCH 6/6] block: assert that BlockDriver->bdrv_co_delete_file is always called with graph rdlock taken Date: Wed, 16 Nov 2022 08:53:31 -0500 Message-Id: <20221116135331.3052923-7-eesposit@redhat.com> In-Reply-To: <20221116135331.3052923-1-eesposit@redhat.com> References: <20221116135331.3052923-1-eesposit@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 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=eesposit@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 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: 1668607199787100007 Content-Type: text/plain; charset="utf-8" The only callers are other callback functions that already run with the gra= ph rdlock taken. Signed-off-by: Emanuele Giuseppe Esposito --- block.c | 1 + include/block/block_int-common.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/block.c b/block.c index e54ed300d7..1a6ae08879 100644 --- a/block.c +++ b/block.c @@ -747,6 +747,7 @@ int coroutine_fn bdrv_co_delete_file(BlockDriverState *= bs, Error **errp) =20 IO_CODE(); assert(bs !=3D NULL); + assert_bdrv_graph_readable(); =20 if (!bs->drv) { error_setg(errp, "Block node '%s' is not opened", bs->filename); diff --git a/include/block/block_int-common.h b/include/block/block_int-com= mon.h index 03bd28e3c9..20308376c6 100644 --- a/include/block/block_int-common.h +++ b/include/block/block_int-common.h @@ -681,7 +681,7 @@ struct BlockDriver { */ int coroutine_fn (*bdrv_co_flush)(BlockDriverState *bs); =20 - /* Delete a created file. */ + /* Delete a created file. Called with graph rdlock taken. */ int coroutine_fn (*bdrv_co_delete_file)(BlockDriverState *bs, Error **errp); =20 --=20 2.31.1