From patchwork Wed Oct 15 21:58:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 5087261 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.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 64308C11AC for ; Wed, 15 Oct 2014 20:58:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8559120114 for ; Wed, 15 Oct 2014 20:58:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 68C04200FF for ; Wed, 15 Oct 2014 20:58:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751238AbaJOU6w (ORCPT ); Wed, 15 Oct 2014 16:58:52 -0400 Received: from mail-wi0-f179.google.com ([209.85.212.179]:41304 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750775AbaJOU6w (ORCPT ); Wed, 15 Oct 2014 16:58:52 -0400 Received: by mail-wi0-f179.google.com with SMTP id d1so3040808wiv.6 for ; Wed, 15 Oct 2014 13:58:50 -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; bh=Dk5WRyHroMtmbbqTfsLj5uDoAlzG4pmf3D13y2OM7Jc=; b=SZbBrnhpX8exeCV+gOP74lfJg/9vx/YsBxzmzKazXGsi/rLh3iMj3/299FdLk7v/1X A1atDksF4WW7RO8bKTXYDtSAe7GF2nxmZkVpHVGJE1F48OzJIKaosbUR3bZeCY4Kaop0 xoQmTBPiGxF7WPrfuDDA8Lpz4Qx/W+8ODDInTOMsxGVrXYjM0CmorZL9WWlbwmc9XRt0 LBVL5ios+AijBlHQ1oG0CNjKhZjIY85Fvorc9egaw8SZy8lNSM71FBvp4G4Mj/dP3S53 PjKP6o1AoiZzx51BB4SJYD+RuJNcvbIm1e4RQgrkmAywpbg8d3e37sAzZ43WyPQ4fn40 9uRQ== X-Received: by 10.180.73.18 with SMTP id h18mr307349wiv.34.1413406730565; Wed, 15 Oct 2014 13:58:50 -0700 (PDT) Received: from debian-vm3.lan (bl9-95-210.dsl.telepac.pt. [85.242.95.210]) by mx.google.com with ESMTPSA id ky3sm25092683wjb.39.2014.10.15.13.58.48 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 15 Oct 2014 13:58:48 -0700 (PDT) From: Filipe Manana X-Google-Original-From: Filipe Manana To: linux-btrfs@vger.kernel.org Cc: dsterba@suse.cz, Filipe Manana Subject: [PATCH] Btrfs-progs: check, fix return value check of is_child_root() Date: Wed, 15 Oct 2014 22:58:40 +0100 Message-Id: <1413410320-22954-1-git-send-email-fdmanana@suse.com> X-Mailer: git-send-email 1.9.1 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, T_DKIM_INVALID, T_RP_MATCHES_RCVD, 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 The following commit: "btrfs-progs: fsck: remove unfriendly BUG_ON() for searching tree failure" f495a2ac66116f0a1b15e73380c8cbca6e0a4ca0 introduced a regression, detected through xfstests/btrfs/054, where previously a negative return value (-1) was used to mean a particular root didn't had any parent root, and now, after that change, a negative value is also used to mean that an error happened. That change also made the only caller of is_child_root() interpret any negative return value as an error and therefore incorrectly made the caller leave with an error, instead of jumping to its "skip" label. Since the return value that means "the root with id child_root_id doesn't have any parent root" isn't used by the only caller of is_child_root(), just get rid of it and make is_child_root() return 0 if parent_root_id isn't a parent of child_root_id, return 1 if it is, and a negative value on error. This affects only the 3.17 release candidates (3.16 and older releases don't have this issue). Signed-off-by: Filipe Manana --- cmds-check.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cmds-check.c b/cmds-check.c index 99d1a94..002d3e9 100644 --- a/cmds-check.c +++ b/cmds-check.c @@ -901,7 +901,6 @@ static int is_child_root(struct btrfs_root *root, u64 parent_root_id, struct btrfs_path path; struct btrfs_key key; struct extent_buffer *leaf; - int has_parent = 0; int ret; btrfs_init_path(&path); @@ -939,8 +938,6 @@ static int is_child_root(struct btrfs_root *root, u64 parent_root_id, key.type != BTRFS_ROOT_BACKREF_KEY) break; - has_parent = 1; - if (key.offset == parent_root_id) { btrfs_release_path(&path); return 1; @@ -952,7 +949,7 @@ out: btrfs_release_path(&path); if (ret < 0) return ret; - return has_parent? 0 : -1; + return 0; } static int process_dir_item(struct btrfs_root *root,