From nobody Thu Dec 18 13:24:56 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1643733841; cv=none; d=zohomail.com; s=zohoarc; b=da3Z/eM5cnpVLS6N6huhJyE9E6hUkxEhuGiTRYoPy8ozywEtxaLmrPlGsKdiUs4/ME7fFB1b0cm2RrVtCQCghAuP3iffc/UUT5364Pb8UutlvTyDvVWAUdJ1gvOTeTMDOJZU3+pOZqCmT6hkWCL3QN4CaHQtq+Tz+cvudZcmFCw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1643733841; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=i/6COBUyvIszZcrXQPuZOU122eGtBCFH2syifxo5GsY=; b=lUUJwbbkJhQVmABs3ppmnM/cLjHMsgEPVg5qF+37idwPRuBRQ2W98LTEkXYI9PzcKcWtFch4QcCfTpFh59y15MCjpecNWmPyP8Zh5ltV3u/V2dtXWDVI1gbYss0W7lAOBXlNYJUK/PEokvL76R/tedVWKrZLiT0cBdeDp+6UTW0= 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 1643733841018865.555415980893; Tue, 1 Feb 2022 08:44:01 -0800 (PST) Received: from localhost ([::1]:55998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nEwG8-000215-2P for importer@patchew.org; Tue, 01 Feb 2022 11:44:00 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46464) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEuyD-0002X1-BA for qemu-devel@nongnu.org; Tue, 01 Feb 2022 10:21:25 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:29113) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nEuy9-0003tS-6a for qemu-devel@nongnu.org; Tue, 01 Feb 2022 10:21:24 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-177-xTg8L20YPAmwnToTztmtow-1; Tue, 01 Feb 2022 10:21:19 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D88618C89DA; Tue, 1 Feb 2022 15:21:18 +0000 (UTC) Received: from merkur.redhat.com (unknown [10.39.194.45]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C47974E98; Tue, 1 Feb 2022 15:21:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1643728880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=i/6COBUyvIszZcrXQPuZOU122eGtBCFH2syifxo5GsY=; b=ibwSbmOHjaF0N7QjvPx1mYd2XN2w97tU/cO8WWjV8GBPPc7BhqF+VWH2m/MBncjGoeMpvt DbFD+6iccdZisKqimm8bILk0D8yr1fmIpTBDLBJ96/0jhML8jNqmU+oc+pF54lkw4+8PyS BGSxrsc+h6l3Z7/Ot5Of1tCJl5yb14U= X-MC-Unique: xTg8L20YPAmwnToTztmtow-1 From: Kevin Wolf To: qemu-block@nongnu.org Subject: [PULL 02/10] block: bdrv_set_backing_hd(): use drained section Date: Tue, 1 Feb 2022 16:21:00 +0100 Message-Id: <20220201152108.171898-3-kwolf@redhat.com> In-Reply-To: <20220201152108.171898-1-kwolf@redhat.com> References: <20220201152108.171898-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kwolf@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=kwolf@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.081, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, 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: , Cc: kwolf@redhat.com, peter.maydell@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1643733844073100001 Content-Type: text/plain; charset="utf-8" From: Vladimir Sementsov-Ogievskiy Graph modifications should be done in drained section. stream_prepare() handler of block stream job call bdrv_set_backing_hd() without using drained section and it's theoretically possible that some IO request will interleave with graph modification and will use outdated pointers to removed block nodes. Some other callers use bdrv_set_backing_hd() not caring about drained sections too. So it seems good to make a drained section exactly in bdrv_set_backing_hd(). Signed-off-by: Vladimir Sementsov-Ogievskiy Message-Id: <20220124173741.2984056-1-vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf --- block.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/block.c b/block.c index 7b3ce415d8..b54d59d1fa 100644 --- a/block.c +++ b/block.c @@ -3341,6 +3341,8 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDr= iverState *backing_hd, int ret; Transaction *tran =3D tran_new(); =20 + bdrv_drained_begin(bs); + ret =3D bdrv_set_backing_noperm(bs, backing_hd, tran, errp); if (ret < 0) { goto out; @@ -3350,6 +3352,8 @@ int bdrv_set_backing_hd(BlockDriverState *bs, BlockDr= iverState *backing_hd, out: tran_finalize(tran, ret); =20 + bdrv_drained_end(bs); + return ret; } =20 --=20 2.31.1