From patchwork Wed Nov 29 13:48:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qu Wenruo X-Patchwork-Id: 10082255 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 9C67C6020B for ; Wed, 29 Nov 2017 13:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8B99D29846 for ; Wed, 29 Nov 2017 13:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E8DA2984B; Wed, 29 Nov 2017 13:48:24 +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 vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1048F29843 for ; Wed, 29 Nov 2017 13:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753212AbdK2NsW (ORCPT ); Wed, 29 Nov 2017 08:48:22 -0500 Received: from prv3-mh.provo.novell.com ([137.65.250.26]:47164 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753102AbdK2NsV (ORCPT ); Wed, 29 Nov 2017 08:48:21 -0500 Received: from adam-pc.lan (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by prv3-mh.provo.novell.com with ESMTP (NOT encrypted); Wed, 29 Nov 2017 06:48:10 -0700 From: Qu Wenruo To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz Subject: [PATCH 1/2] btrfs-progs: convert: Fix a bug in rollback check which overwrite return value Date: Wed, 29 Nov 2017 21:48:05 +0800 Message-Id: <20171129134806.32324-1-wqu@suse.com> X-Mailer: git-send-email 2.15.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 1170ac307900 ("btrfs-progs: convert: Introduce function to check if convert image is able to be rolled back") reworked rollback check condition, by checking 1:1 mapping of each file extent. The idea itself has nothing wrong, but error handler is not implemented correctly, which over writes the return value and always try to rollback the fs even it fails to pass the check. Fix it by correctly return the error before rollback the fs. Fixes: 1170ac307900 ("btrfs-progs: convert: Introduce function to check if convert image is able to be rolled back") Reported-by: Jeff Mahoney Signed-off-by: Qu Wenruo --- convert/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/convert/main.c b/convert/main.c index af2855316fee..89f9261172ca 100644 --- a/convert/main.c +++ b/convert/main.c @@ -1443,6 +1443,8 @@ next: } } btrfs_release_path(&path); + if (ret) + return ret; /* * For HOLES mode (without NO_HOLES), we must ensure file extents * cover the whole range of the image