From nobody Mon Feb 9 03:13:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564072078; cv=none; d=zoho.com; s=zohoarc; b=DcWoiuc4Y/cvAhwZxBcK3E+6vAfsXx9urrnEDfGtP9GFdhMSgAmxyttBGBNZvxjlGIjWEC75w2Z7xSnLuBBQm58yMoWv2/N4IrdPylSzHfPx9fLFmX+iE/NQYruDGsWakCpCFyoLy3dAHs+ExnGdSOOtYRJAJGrDYJIR6e1GXBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564072078; 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:ARC-Authentication-Results; bh=Fy3r0cSbccxQJLS7L/Ol9nLVxsqAIPGQ3NEX4XK2gUc=; b=Iq3tegDpznL+o+hwwf8Hu0iNUJtXYWO23Vjih1e8p3W+flNC/GBSRKlrR76YU1dQj0fqllA6sEaWb51rV17nRTOm+Ad+wPFNZDFE7VHuGR+ioRjzn/dadT6lXCmbM9FwV0WPY3pJkhYwrxU07O1sULkRwwzK/PQuPPZz6eCRBMU= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1564072078901878.6959757203302; Thu, 25 Jul 2019 09:27:58 -0700 (PDT) Received: from localhost ([::1]:33822 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqgaz-0005As-GV for importer@patchew.org; Thu, 25 Jul 2019 12:27:57 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36933) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hqgaV-0003bH-Eo for qemu-devel@nongnu.org; Thu, 25 Jul 2019 12:27:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hqgaT-0003vm-Av for qemu-devel@nongnu.org; Thu, 25 Jul 2019 12:27:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46738) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hqgaQ-0003ra-53; Thu, 25 Jul 2019 12:27:22 -0400 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 mx1.redhat.com (Postfix) with ESMTPS id 4EED830917AF; Thu, 25 Jul 2019 16:27:21 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-146.ams2.redhat.com [10.36.117.146]) by smtp.corp.redhat.com (Postfix) with ESMTP id B928E5D71A; Thu, 25 Jul 2019 16:27:19 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Thu, 25 Jul 2019 18:27:03 +0200 Message-Id: <20190725162704.12622-4-kwolf@redhat.com> In-Reply-To: <20190725162704.12622-1-kwolf@redhat.com> References: <20190725162704.12622-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 25 Jul 2019 16:27:21 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 3/4] mirror: Keep target drained until graph changes are done X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, vsementsov@virtuozzo.com, den@virtuozzo.com, qemu-devel@nongnu.org, mreitz@redhat.com, dplotnikov@virtuozzo.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Calling bdrv_drained_end() for target_bs can restarts requests too early, so that they would execute on mirror_top_bs, which however has already dropped all permissions. Keep the target node drained until all graph changes have completed. Signed-off-by: Kevin Wolf --- block/mirror.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/block/mirror.c b/block/mirror.c index 8cb75fb409..7483051f8d 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -644,6 +644,11 @@ static int mirror_exit_common(Job *job) bdrv_ref(mirror_top_bs); bdrv_ref(target_bs); =20 + /* The mirror job has no requests in flight any more, but we need to + * drain potential other users of the BDS before changing the graph. */ + assert(s->in_drain); + bdrv_drained_begin(target_bs); + /* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before * inserting target_bs at s->to_replace, where we might not be able to= get * these permissions. @@ -684,12 +689,7 @@ static int mirror_exit_common(Job *job) bdrv_reopen_set_read_only(target_bs, ro, NULL); } =20 - /* The mirror job has no requests in flight any more, but we need = to - * drain potential other users of the BDS before changing the grap= h. */ - assert(s->in_drain); - bdrv_drained_begin(target_bs); bdrv_replace_node(to_replace, target_bs, &local_err); - bdrv_drained_end(target_bs); if (local_err) { error_report_err(local_err); ret =3D -EPERM; @@ -704,7 +704,6 @@ static int mirror_exit_common(Job *job) aio_context_release(replace_aio_context); } g_free(s->replaces); - bdrv_unref(target_bs); =20 /* * Remove the mirror filter driver from the graph. Before this, get ri= d of @@ -724,9 +723,12 @@ static int mirror_exit_common(Job *job) bs_opaque->job =3D NULL; =20 bdrv_drained_end(src); + bdrv_drained_end(target_bs); + s->in_drain =3D false; bdrv_unref(mirror_top_bs); bdrv_unref(src); + bdrv_unref(target_bs); =20 return ret; } --=20 2.20.1