Lines Matching refs:ref
166 static void free_pref(struct prelim_ref *ref) in free_pref() argument
168 kmem_cache_free(btrfs_prelim_ref_cache, ref); in free_pref()
232 struct prelim_ref *ref; in prelim_ref_insert() local
240 ref = rb_entry(parent, struct prelim_ref, rbnode); in prelim_ref_insert()
241 result = prelim_ref_compare(ref, newref); in prelim_ref_insert()
248 struct extent_inode_elem *eie = ref->inode_list; in prelim_ref_insert()
254 ref->inode_list = newref->inode_list; in prelim_ref_insert()
257 trace_btrfs_prelim_ref_merge(fs_info, ref, newref, in prelim_ref_insert()
264 update_share_count(sc, ref->count, in prelim_ref_insert()
265 ref->count + newref->count); in prelim_ref_insert()
266 ref->count += newref->count; in prelim_ref_insert()
285 struct prelim_ref *ref, *next_ref; in prelim_release() local
287 rbtree_postorder_for_each_entry_safe(ref, next_ref, &preftree->root, in prelim_release()
289 free_pref(ref); in prelim_release()
339 struct prelim_ref *ref; in add_prelim_ref() local
344 ref = kmem_cache_alloc(btrfs_prelim_ref_cache, gfp_mask); in add_prelim_ref()
345 if (!ref) in add_prelim_ref()
348 ref->root_id = root_id; in add_prelim_ref()
350 ref->key_for_search = *key; in add_prelim_ref()
370 if (ref->key_for_search.type == BTRFS_EXTENT_DATA_KEY && in add_prelim_ref()
371 ref->key_for_search.offset >= LLONG_MAX) in add_prelim_ref()
372 ref->key_for_search.offset = 0; in add_prelim_ref()
374 memset(&ref->key_for_search, 0, sizeof(ref->key_for_search)); in add_prelim_ref()
377 ref->inode_list = NULL; in add_prelim_ref()
378 ref->level = level; in add_prelim_ref()
379 ref->count = count; in add_prelim_ref()
380 ref->parent = parent; in add_prelim_ref()
381 ref->wanted_disk_byte = wanted_disk_byte; in add_prelim_ref()
382 prelim_ref_insert(fs_info, preftree, ref, sc); in add_prelim_ref()
412 struct ulist *parents, struct prelim_ref *ref, in add_all_parents() argument
420 struct btrfs_key *key_for_search = &ref->key_for_search; in add_all_parents()
424 u64 wanted_disk_byte = ref->wanted_disk_byte; in add_all_parents()
504 struct prelim_ref *ref, struct ulist *parents, in resolve_indirect_ref() argument
513 int level = ref->level; in resolve_indirect_ref()
516 root_key.objectid = ref->root_id; in resolve_indirect_ref()
549 ret = btrfs_search_slot(NULL, root, &ref->key_for_search, path, in resolve_indirect_ref()
552 ret = btrfs_search_old_slot(root, &ref->key_for_search, path, in resolve_indirect_ref()
560 ref->root_id, level, ref->count, ret, in resolve_indirect_ref()
561 ref->key_for_search.objectid, ref->key_for_search.type, in resolve_indirect_ref()
562 ref->key_for_search.offset); in resolve_indirect_ref()
576 ret = add_all_parents(root, path, parents, ref, level, time_seq, in resolve_indirect_ref()
644 struct prelim_ref *ref; in resolve_indirect_refs() local
646 ref = rb_entry(rnode, struct prelim_ref, rbnode); in resolve_indirect_refs()
647 if (WARN(ref->parent, in resolve_indirect_refs()
653 rb_erase(&ref->rbnode, &preftrees->indirect.root); in resolve_indirect_refs()
656 if (ref->count == 0) { in resolve_indirect_refs()
657 free_pref(ref); in resolve_indirect_refs()
662 ref->root_id != sc->root_objectid) { in resolve_indirect_refs()
663 free_pref(ref); in resolve_indirect_refs()
667 err = resolve_indirect_ref(fs_info, path, time_seq, ref, in resolve_indirect_refs()
675 prelim_ref_insert(fs_info, &preftrees->direct, ref, in resolve_indirect_refs()
679 free_pref(ref); in resolve_indirect_refs()
687 ref->parent = node ? node->val : 0; in resolve_indirect_refs()
688 ref->inode_list = unode_aux_to_inode_list(node); in resolve_indirect_refs()
697 free_pref(ref); in resolve_indirect_refs()
701 memcpy(new_ref, ref, sizeof(*ref)); in resolve_indirect_refs()
712 prelim_ref_insert(fs_info, &preftrees->direct, ref, NULL); in resolve_indirect_refs()
732 struct prelim_ref *ref; in add_missing_keys() local
738 ref = rb_entry(node, struct prelim_ref, rbnode); in add_missing_keys()
741 BUG_ON(ref->parent); /* should not be a direct ref */ in add_missing_keys()
742 BUG_ON(ref->key_for_search.type); in add_missing_keys()
743 BUG_ON(!ref->wanted_disk_byte); in add_missing_keys()
745 eb = read_tree_block(fs_info, ref->wanted_disk_byte, 0, in add_missing_keys()
746 ref->level - 1, NULL); in add_missing_keys()
748 free_pref(ref); in add_missing_keys()
751 free_pref(ref); in add_missing_keys()
758 btrfs_item_key_to_cpu(eb, &ref->key_for_search, 0); in add_missing_keys()
760 btrfs_node_key_to_cpu(eb, &ref->key_for_search, 0); in add_missing_keys()
764 prelim_ref_insert(fs_info, &preftrees->indirect, ref, NULL); in add_missing_keys()
810 struct btrfs_delayed_tree_ref *ref; in add_delayed_refs() local
818 ref = btrfs_delayed_node_to_tree_ref(node); in add_delayed_refs()
819 ret = add_indirect_ref(fs_info, preftrees, ref->root, in add_delayed_refs()
820 key_ptr, ref->level + 1, in add_delayed_refs()
827 struct btrfs_delayed_tree_ref *ref; in add_delayed_refs() local
829 ref = btrfs_delayed_node_to_tree_ref(node); in add_delayed_refs()
831 ret = add_direct_ref(fs_info, preftrees, ref->level + 1, in add_delayed_refs()
832 ref->parent, node->bytenr, count, in add_delayed_refs()
838 struct btrfs_delayed_data_ref *ref; in add_delayed_refs() local
839 ref = btrfs_delayed_node_to_data_ref(node); in add_delayed_refs()
841 key.objectid = ref->objectid; in add_delayed_refs()
843 key.offset = ref->offset; in add_delayed_refs()
863 ret = add_indirect_ref(fs_info, preftrees, ref->root, in add_delayed_refs()
870 struct btrfs_delayed_data_ref *ref; in add_delayed_refs() local
872 ref = btrfs_delayed_node_to_data_ref(node); in add_delayed_refs()
874 ret = add_direct_ref(fs_info, preftrees, 0, ref->parent, in add_delayed_refs()
1153 struct prelim_ref *ref; local
1287 ref = rb_entry(node, struct prelim_ref, rbnode);
1288 node = rb_next(&ref->rbnode);
1299 if (roots && ref->count && ref->root_id && ref->parent == 0) {
1301 ref->root_id != sc->root_objectid) {
1307 ret = ulist_add(roots, ref->root_id, 0, GFP_NOFS);
1311 if (ref->count && ref->parent) {
1312 if (extent_item_pos && !ref->inode_list &&
1313 ref->level == 0) {
1316 eb = read_tree_block(fs_info, ref->parent, 0,
1317 ref->level, NULL);
1337 ref->inode_list = eie;
1339 ret = ulist_add_merge_ptr(refs, ref->parent,
1340 ref->inode_list,
1360 eie->next = ref->inode_list;