Skip to content

Commit

Permalink
btrfs: backref: Don't merge refs which are not for same block.
Browse files Browse the repository at this point in the history
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: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Chris Mason <clm@fb.com>
  • Loading branch information
Qu Wenruo authored and Chris Mason committed Jun 10, 2015
1 parent 20b2e30 commit 00db646
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/btrfs/backref.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
* FIXME: if we add more keys in __add_prelim_ref, we can merge more here.
Expand Down Expand Up @@ -537,9 +537,9 @@ static void __merge_refs(struct list_head *head, int mode)

ref2 = list_entry(pos2, struct __prelim_ref, list);

if (!ref_for_same_block(ref1, ref2))
continue;
if (mode == 1) {
if (!ref_for_same_block(ref1, ref2))
continue;
if (!ref1->parent && ref2->parent) {
xchg = ref1;
ref1 = ref2;
Expand Down

0 comments on commit 00db646

Please sign in to comment.