if (backref->found_dir_item && backref->found_dir_index) {
if (backref->filetype != filetype)
backref->errors |= REF_ERR_FILETYPE_UNMATCH;
- if (!backref->errors && backref->found_inode_ref) {
+ if (!backref->errors && backref->found_inode_ref &&
+ rec->nlink == rec->found_link) {
list_del(&backref->list);
free(backref);
}
list_for_each_entry(backref, &rec->backrefs, list) {
ret = btrfs_add_link(trans, root, rec->ino, backref->dir,
backref->name, backref->namelen,
- backref->ref_type, &backref->index, 1);
+ backref->filetype, &backref->index, 1);
if (ret < 0)
goto out;
}