From nobody Sun Oct 5 19:22:57 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1489009441815923.3603417543837; Wed, 8 Mar 2017 13:44:01 -0800 (PST) Received: from localhost ([::1]:58603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cljNI-0003tE-HO for importer@patchew.org; Wed, 08 Mar 2017 16:44:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55141) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cljEF-0004ak-Hz for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:34:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cljED-0000CW-RS for qemu-devel@nongnu.org; Wed, 08 Mar 2017 16:34:39 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46734) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cljEA-0000BK-BA; Wed, 08 Mar 2017 16:34:34 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B8EFC037F70; Wed, 8 Mar 2017 21:34:34 +0000 (UTC) Received: from red.redhat.com (ovpn-124-84.rdu2.redhat.com [10.10.124.84] (may be forged)) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v28LYVl6026773; Wed, 8 Mar 2017 16:34:33 -0500 From: Eric Blake To: qemu-devel@nongnu.org Date: Wed, 8 Mar 2017 15:34:27 -0600 Message-Id: <20170308213429.29244-2-eblake@redhat.com> In-Reply-To: <20170308213429.29244-1-eblake@redhat.com> References: <20170308213429.29244-1-eblake@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Wed, 08 Mar 2017 21:34:34 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 1/3] backup: React to bdrv_is_allocated() errors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, Jeff Cody , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If bdrv_is_allocated() fails, we should immediately do the backup error action, rather than attempting backup_do_cow() (although that will likely fail too). Signed-off-by: Eric Blake --- block/backup.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/block/backup.c b/block/backup.c index d3d20db..a4fb288 100644 --- a/block/backup.c +++ b/block/backup.c @@ -468,13 +468,14 @@ static void coroutine_fn backup_run(void *opaque) /* Both FULL and TOP SYNC_MODE's require copying.. */ for (; start < end; start++) { bool error_is_read; + int alloced =3D 0; + if (yield_and_check(job)) { break; } if (job->sync_mode =3D=3D MIRROR_SYNC_MODE_TOP) { int i, n; - int alloced =3D 0; /* Check to see if these blocks are already in the * backing file. */ @@ -492,7 +493,7 @@ static void coroutine_fn backup_run(void *opaque) sectors_per_cluster - i, &n); i +=3D n; - if (alloced =3D=3D 1 || n =3D=3D 0) { + if (alloced || n =3D=3D 0) { break; } } @@ -504,8 +505,13 @@ static void coroutine_fn backup_run(void *opaque) } } /* FULL sync mode we copy the whole drive. */ - ret =3D backup_do_cow(job, start * sectors_per_cluster, - sectors_per_cluster, &error_is_read, false= ); + if (alloced < 0) { + ret =3D alloced; + } else { + ret =3D backup_do_cow(job, start * sectors_per_cluster, + sectors_per_cluster, &error_is_read, + false); + } if (ret < 0) { /* Depending on error action, fail now or retry cluster */ BlockErrorAction action =3D --=20 2.9.3