All of lore.kernel.org
 help / color / mirror / Atom feed
From: Filipe Manana <fdmanana@gmail.com>
To: linux-btrfs@vger.kernel.org
Cc: dsterba@suse.cz, Filipe Manana <fdmanana@suse.com>
Subject: [PATCH] Btrfs-progs: check, fix return value check of is_child_root()
Date: Wed, 15 Oct 2014 22:58:40 +0100	[thread overview]
Message-ID: <1413410320-22954-1-git-send-email-fdmanana@suse.com> (raw)

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 <fdmanana@suse.com>
---
 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,
-- 
1.9.1


             reply	other threads:[~2014-10-15 20:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-15 21:58 Filipe Manana [this message]
2014-10-15 21:07 ` [PATCH] Btrfs-progs: check, fix return value check of is_child_root() David Sterba
2014-10-16  0:33 ` [PATCH v2] " Filipe Manana
2014-10-16  9:55   ` Wang Shilong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1413410320-22954-1-git-send-email-fdmanana@suse.com \
    --to=fdmanana@gmail.com \
    --cc=dsterba@suse.cz \
    --cc=fdmanana@suse.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.