From patchwork Wed Mar 8 21:34:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Blake X-Patchwork-Id: 9612041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2E03860414 for ; Wed, 8 Mar 2017 21:43:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1DFA926E8A for ; Wed, 8 Mar 2017 21:43:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 120DB285FC; Wed, 8 Mar 2017 21:43:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BB55226E8A for ; Wed, 8 Mar 2017 21:43:33 +0000 (UTC) Received: from localhost ([::1]:58603 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cljMq-0003tE-Ps for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Mar 2017 16:43:32 -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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 = 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 =