summaryrefslogtreecommitdiff
path: root/btrfsck.c
diff options
context:
space:
mode:
authorMiao Xie <miaox@cn.fujitsu.com>2012-08-10 16:14:02 +0800
committerroot <root@localhost.localdomain>2012-10-04 16:26:31 -0400
commitf3f72863d5571cbb04ddde0416994eada776fb2a (patch)
treee69a72f5773a5c61592007fdc773aac17b601b08 /btrfsck.c
parent78bffa238788705967050b15c9e6a7e05c90bde5 (diff)
Btrfs-progs: fix unresolved ref root message
btrfsck misinformed "unresolved ref root" message when there were several snapshots in the file system. The patch(commit cfdd42686c70) tried to fix this bug, but didn't fix it completely. If the metadata was stored in a shared leaf of the tree, the problem would happen again. This patch fixes it by another way, we don't check the relationship of the trees when we traverse the fs/file tree, we just do the check when we merge the snapshot records to the root cache. Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Diffstat (limited to 'btrfsck.c')
-rw-r--r--btrfsck.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/btrfsck.c b/btrfsck.c
index f09a4a41..918d1540 100644
--- a/btrfsck.c
+++ b/btrfsck.c
@@ -857,13 +857,10 @@ static int process_dir_item(struct btrfs_root *root,
key->objectid, key->offset, namebuf,
len, filetype, key->type, error);
} else if (location.type == BTRFS_ROOT_ITEM_KEY) {
- u64 parent = root->objectid;
-
- if (is_child_root(root, parent, location.objectid))
- add_inode_backref(root_cache, location.objectid,
- key->objectid, key->offset,
- namebuf, len, filetype,
- key->type, error);
+ add_inode_backref(root_cache, location.objectid,
+ key->objectid, key->offset,
+ namebuf, len, filetype,
+ key->type, error);
} else {
fprintf(stderr, "warning line %d\n", __LINE__);
}
@@ -1489,6 +1486,9 @@ static int merge_root_recs(struct btrfs_root *root,
remove_cache_extent(src_cache, &node->cache);
free(node);
+ if (!is_child_root(root, root->objectid, rec->ino))
+ goto skip;
+
list_for_each_entry(backref, &rec->backrefs, list) {
BUG_ON(backref->found_inode_ref);
if (backref->found_dir_item)
@@ -1504,6 +1504,7 @@ static int merge_root_recs(struct btrfs_root *root,
backref->namelen, BTRFS_DIR_INDEX_KEY,
backref->errors);
}
+skip:
free_inode_rec(rec);
}
return 0;