From patchwork Mon Mar 13 14:55:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 738204 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vhgt80FxRz9ryZ for ; Tue, 14 Mar 2017 01:56:16 +1100 (AEDT) Received: from localhost ([::1]:52493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnROP-0005kK-Dp for incoming@patchwork.ozlabs.org; Mon, 13 Mar 2017 10:56:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnRNd-0005hG-HO for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnRNc-0002tj-NO for qemu-devel@nongnu.org; Mon, 13 Mar 2017 10:55:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56056) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cnRNZ-0002r7-Re; Mon, 13 Mar 2017 10:55:21 -0400 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 DE0837E9FD; Mon, 13 Mar 2017 14:55:21 +0000 (UTC) Received: from noname.redhat.com (ovpn-117-150.ams2.redhat.com [10.36.117.150]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2DEtEUW009408; Mon, 13 Mar 2017 10:55:20 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Mon, 13 Mar 2017 15:55:00 +0100 Message-Id: <1489416908-3771-5-git-send-email-kwolf@redhat.com> In-Reply-To: <1489416908-3771-1-git-send-email-kwolf@redhat.com> References: <1489416908-3771-1-git-send-email-kwolf@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.26]); Mon, 13 Mar 2017 14:55:21 +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] [PULL 04/12] 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, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake 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 Signed-off-by: Kevin Wolf --- 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 = 0; + if (yield_and_check(job)) { break; } if (job->sync_mode == MIRROR_SYNC_MODE_TOP) { int i, n; - int alloced = 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 += n; - if (alloced == 1 || n == 0) { + if (alloced || n == 0) { break; } } @@ -504,8 +505,13 @@ static void coroutine_fn backup_run(void *opaque) } } /* FULL sync mode we copy the whole drive. */ - ret = backup_do_cow(job, start * sectors_per_cluster, - sectors_per_cluster, &error_is_read, false); + if (alloced < 0) { + ret = alloced; + } else { + ret = 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 =