Commit 00db646d authored by Qu Wenruo's avatar Qu Wenruo Committed by Chris Mason

btrfs: backref: Don't merge refs which are not for same block.

Old __merge_refs() in backref.c will even merge refs whose root_id are
different, which makes qgroup gives wrong result.

Fix it by checking ref_for_same_block() before any mode specific works.
Signed-off-by: default avatarQu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 20b2e302
...@@ -509,7 +509,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info, ...@@ -509,7 +509,7 @@ static int __add_missing_keys(struct btrfs_fs_info *fs_info,
} }
/* /*
* merge two lists of backrefs and adjust counts accordingly * merge backrefs and adjust counts accordingly
* *
* mode = 1: merge identical keys, if key is set * mode = 1: merge identical keys, if key is set
* FIXME: if we add more keys in __add_prelim_ref, we can merge more here. * FIXME: if we add more keys in __add_prelim_ref, we can merge more here.
...@@ -537,9 +537,9 @@ static void __merge_refs(struct list_head *head, int mode) ...@@ -537,9 +537,9 @@ static void __merge_refs(struct list_head *head, int mode)
ref2 = list_entry(pos2, struct __prelim_ref, list); ref2 = list_entry(pos2, struct __prelim_ref, list);
if (mode == 1) {
if (!ref_for_same_block(ref1, ref2)) if (!ref_for_same_block(ref1, ref2))
continue; continue;
if (mode == 1) {
if (!ref1->parent && ref2->parent) { if (!ref1->parent && ref2->parent) {
xchg = ref1; xchg = ref1;
ref1 = ref2; ref1 = ref2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment