summaryrefslogtreecommitdiff
path: root/cmds-check.c
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@gmail.com>2014-10-16 01:33:23 +0100
committerDavid Sterba <dsterba@suse.cz>2014-10-16 12:01:55 +0200
commitd6d44779f5df4ed04a6bdac6330a8e91740a2f7f (patch)
tree0fc9a90cea85c62a5fe5ea304f5ec4ccefdac59d /cmds-check.c
parent7fd6d933528f30ab03d3880c8cb5e89968e41858 (diff)
Btrfs-progs: check, fix return value check of is_child_root()
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 continuing. 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> Reviewed-by: Wang Shilong <wangshilong1991@gmail.com> Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'cmds-check.c')
-rw-r--r--cmds-check.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/cmds-check.c b/cmds-check.c
index 99d1a94c..310eb2a8 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -895,6 +895,14 @@ static int leave_shared_node(struct btrfs_root *root,
return 0;
}
+/*
+ * Returns:
+ * < 0 - on error
+ * 1 - if the root with id child_root_id is a child of root parent_root_id
+ * 0 - if the root child_root_id isn't a child of the root parent_root_id but
+ * has other root(s) as parent(s)
+ * 2 - if the root child_root_id doesn't have any parent roots
+ */
static int is_child_root(struct btrfs_root *root, u64 parent_root_id,
u64 child_root_id)
{
@@ -952,7 +960,7 @@ out:
btrfs_release_path(&path);
if (ret < 0)
return ret;
- return has_parent? 0 : -1;
+ return has_parent ? 0 : 2;
}
static int process_dir_item(struct btrfs_root *root,