diff options
Diffstat (limited to 'fs/btrfs/backref.c')
-rw-r--r-- | fs/btrfs/backref.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 208d8aa5b07e..04edf69be875 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c | |||
@@ -461,6 +461,7 @@ static int __merge_refs(struct list_head *head, int mode) | |||
461 | pos2 = n2, n2 = pos2->next) { | 461 | pos2 = n2, n2 = pos2->next) { |
462 | struct __prelim_ref *ref2; | 462 | struct __prelim_ref *ref2; |
463 | struct __prelim_ref *xchg; | 463 | struct __prelim_ref *xchg; |
464 | struct extent_inode_elem *eie; | ||
464 | 465 | ||
465 | ref2 = list_entry(pos2, struct __prelim_ref, list); | 466 | ref2 = list_entry(pos2, struct __prelim_ref, list); |
466 | 467 | ||
@@ -472,12 +473,20 @@ static int __merge_refs(struct list_head *head, int mode) | |||
472 | ref1 = ref2; | 473 | ref1 = ref2; |
473 | ref2 = xchg; | 474 | ref2 = xchg; |
474 | } | 475 | } |
475 | ref1->count += ref2->count; | ||
476 | } else { | 476 | } else { |
477 | if (ref1->parent != ref2->parent) | 477 | if (ref1->parent != ref2->parent) |
478 | continue; | 478 | continue; |
479 | ref1->count += ref2->count; | ||
480 | } | 479 | } |
480 | |||
481 | eie = ref1->inode_list; | ||
482 | while (eie && eie->next) | ||
483 | eie = eie->next; | ||
484 | if (eie) | ||
485 | eie->next = ref2->inode_list; | ||
486 | else | ||
487 | ref1->inode_list = ref2->inode_list; | ||
488 | ref1->count += ref2->count; | ||
489 | |||
481 | list_del(&ref2->list); | 490 | list_del(&ref2->list); |
482 | kfree(ref2); | 491 | kfree(ref2); |
483 | } | 492 | } |
@@ -890,8 +899,7 @@ again: | |||
890 | while (!list_empty(&prefs)) { | 899 | while (!list_empty(&prefs)) { |
891 | ref = list_first_entry(&prefs, struct __prelim_ref, list); | 900 | ref = list_first_entry(&prefs, struct __prelim_ref, list); |
892 | list_del(&ref->list); | 901 | list_del(&ref->list); |
893 | if (ref->count < 0) | 902 | WARN_ON(ref->count < 0); |
894 | WARN_ON(1); | ||
895 | if (ref->count && ref->root_id && ref->parent == 0) { | 903 | if (ref->count && ref->root_id && ref->parent == 0) { |
896 | /* no parent == root of tree */ | 904 | /* no parent == root of tree */ |
897 | ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS); | 905 | ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS); |