From patchwork Mon Oct 19 11:37:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eryu Guan X-Patchwork-Id: 7435191 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1C6FBEEA4 for ; Mon, 19 Oct 2015 11:43:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 28AE620693 for ; Mon, 19 Oct 2015 11:43:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AA3120691 for ; Mon, 19 Oct 2015 11:43:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751095AbbJSLnh (ORCPT ); Mon, 19 Oct 2015 07:43:37 -0400 Received: from mail-pa0-f43.google.com ([209.85.220.43]:34431 "EHLO mail-pa0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750819AbbJSLng (ORCPT ); Mon, 19 Oct 2015 07:43:36 -0400 Received: by padhk11 with SMTP id hk11so28173252pad.1 for ; Mon, 19 Oct 2015 04:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=14k3HG6X/pOzhAmDcqhegR292EdTEDWbxnTFgLJPgN4=; b=zceFDTJoR2QJKUFeYztqOSuAOEPHl2AxfmWg73h9wJ/ochQxSxactuu2tJIPEnuS8W /M1FV6a7QG8FrBuFyJNKthp0XG5C58w4Ur+3jOZMJeq4scpbpszzJaUplIlw08n3aw8W VwYSD2UpKjo+VpOoFmMCLHUMp2ynPYrW6dgLD2713QirYNDgPh8AgYLhyBvpx1drIl6o v2CQqyPp19ryi2FVwVt860iaNLFf1iFsaZF2TLMQ1cSsBU3792XnozZVbrDPoHI5t071 +dc1M+rrUFrNidgsPgVrac4iVXFPAacfrIeg/dqsQYWhhDweBtrfmeVt8hubYr8eXs3M joMw== X-Received: by 10.66.155.167 with SMTP id vx7mr11398736pab.127.1445255016107; Mon, 19 Oct 2015 04:43:36 -0700 (PDT) Received: from localhost ([128.199.137.77]) by smtp.gmail.com with ESMTPSA id dd4sm35930489pbb.52.2015.10.19.04.43.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Oct 2015 04:43:35 -0700 (PDT) From: Eryu Guan To: linux-btrfs@vger.kernel.org Cc: Eryu Guan Subject: [PATCH 04/10] btrfs-progs: return -EIO properly in restore_metadump() Date: Mon, 19 Oct 2015 19:37:54 +0800 Message-Id: <1445254680-11102-5-git-send-email-guaneryu@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1445254680-11102-1-git-send-email-guaneryu@gmail.com> References: <1445254680-11102-1-git-send-email-guaneryu@gmail.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Error number -EIO is assigned to ret but later ret is overwritten by wait_for_worker(). Signed-off-by: Eryu Guan --- btrfs-image.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/btrfs-image.c b/btrfs-image.c index 82eed05..7d3a2f8 100644 --- a/btrfs-image.c +++ b/btrfs-image.c @@ -2465,6 +2465,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore, u64 bytenr = 0; FILE *in = NULL; int ret = 0; + int err = 0; if (!strcmp(input, "-")) { in = stdin; @@ -2526,7 +2527,7 @@ static int restore_metadump(const char *input, FILE *out, int old_restore, if (le64_to_cpu(header->magic) != HEADER_MAGIC || le64_to_cpu(header->bytenr) != bytenr) { fprintf(stderr, "bad header in metadump image\n"); - ret = -EIO; + err = -EIO; break; } ret = add_cluster(cluster, &mdrestore, &bytenr); @@ -2536,6 +2537,8 @@ static int restore_metadump(const char *input, FILE *out, int old_restore, } } ret = wait_for_worker(&mdrestore); + if (!ret) + ret = err; if (!ret && !multi_devices && !old_restore) { struct btrfs_root *root;