Lines Matching full:ref
10 #include "delayed-ref.h"
72 * btrfs_delayed_refs_rsv_release - release a ref head's reservation.
76 * This drops the delayed ref head's count from the delayed refs rsv and frees
277 /* insert a new ref to head ref rbtree */
357 * Find a head entry based on bytenr. This returns the delayed ref head if it
418 struct btrfs_delayed_ref_node *ref) in drop_delayed_ref() argument
421 rb_erase_cached(&ref->ref_node, &head->ref_tree); in drop_delayed_ref()
422 RB_CLEAR_NODE(&ref->ref_node); in drop_delayed_ref()
423 if (!list_empty(&ref->add_list)) in drop_delayed_ref()
424 list_del(&ref->add_list); in drop_delayed_ref()
425 ref->in_tree = 0; in drop_delayed_ref()
426 btrfs_put_delayed_ref(ref); in drop_delayed_ref()
433 struct btrfs_delayed_ref_node *ref, in merge_ref() argument
437 struct rb_node *node = rb_next(&ref->ref_node); in merge_ref()
447 if (comp_refs(ref, next, false)) in merge_ref()
450 if (ref->action == next->action) { in merge_ref()
453 if (ref->ref_mod < next->ref_mod) { in merge_ref()
454 swap(ref, next); in merge_ref()
461 ref->ref_mod += mod; in merge_ref()
462 if (ref->ref_mod == 0) { in merge_ref()
463 drop_delayed_ref(trans, delayed_refs, head, ref); in merge_ref()
467 * Can't have multiples of the same ref on a tree block. in merge_ref()
469 WARN_ON(ref->type == BTRFS_TREE_BLOCK_REF_KEY || in merge_ref()
470 ref->type == BTRFS_SHARED_BLOCK_REF_KEY); in merge_ref()
482 struct btrfs_delayed_ref_node *ref; in btrfs_merge_delayed_refs() local
508 ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node); in btrfs_merge_delayed_refs()
509 if (seq && ref->seq >= seq) in btrfs_merge_delayed_refs()
511 if (merge_ref(trans, delayed_refs, head, ref, seq)) in btrfs_merge_delayed_refs()
598 struct btrfs_delayed_ref_node *ref) in insert_delayed_ref() argument
605 exist = tree_insert(&href->ref_tree, ref); in insert_delayed_ref()
611 if (exist->action == ref->action) { in insert_delayed_ref()
612 mod = ref->ref_mod; in insert_delayed_ref()
615 if (exist->ref_mod < ref->ref_mod) { in insert_delayed_ref()
616 exist->action = ref->action; in insert_delayed_ref()
618 exist->ref_mod = ref->ref_mod; in insert_delayed_ref()
619 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
622 else if (ref->action == BTRFS_DROP_DELAYED_REF) { in insert_delayed_ref()
629 mod = -ref->ref_mod; in insert_delayed_ref()
639 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
640 list_add_tail(&ref->add_list, &href->ref_add_list); in insert_delayed_ref()
647 * helper function to update the accounting in the head ref
665 * reallocated before the delayed ref in update_existing_head_ref()
667 * with an existing head ref without in update_existing_head_ref()
711 * If we are going to from a positive ref mod to a negative or vice in update_existing_head_ref()
744 * The head node stores the sum of all the mods, so dropping a ref in init_delayed_ref_head()
755 * modification deletes the delayed ref without ever inserting the in init_delayed_ref_head()
756 * extent into the extent allocation tree. ref->must_insert_reserved in init_delayed_ref_head()
828 * we've updated the existing ref, free the newly in add_delayed_ref_head()
829 * allocated ref in add_delayed_ref_head()
861 * @ref: The structure which is going to be initialized.
881 struct btrfs_delayed_ref_node *ref, in init_delayed_ref_common() argument
893 refcount_set(&ref->refs, 1); in init_delayed_ref_common()
894 ref->bytenr = bytenr; in init_delayed_ref_common()
895 ref->num_bytes = num_bytes; in init_delayed_ref_common()
896 ref->ref_mod = 1; in init_delayed_ref_common()
897 ref->action = action; in init_delayed_ref_common()
898 ref->is_head = 0; in init_delayed_ref_common()
899 ref->in_tree = 1; in init_delayed_ref_common()
900 ref->seq = seq; in init_delayed_ref_common()
901 ref->type = ref_type; in init_delayed_ref_common()
902 RB_CLEAR_NODE(&ref->ref_node); in init_delayed_ref_common()
903 INIT_LIST_HEAD(&ref->add_list); in init_delayed_ref_common()
907 * add a delayed tree ref. This does all of the accounting required
908 * to make sure the delayed ref is eventually processed before this
917 struct btrfs_delayed_tree_ref *ref; in btrfs_add_delayed_tree_ref() local
935 ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS); in btrfs_add_delayed_tree_ref()
936 if (!ref) in btrfs_add_delayed_tree_ref()
941 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
951 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
962 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_tree_ref()
964 ref->root = generic_ref->tree_ref.root; in btrfs_add_delayed_tree_ref()
965 ref->parent = parent; in btrfs_add_delayed_tree_ref()
966 ref->level = level; in btrfs_add_delayed_tree_ref()
977 * insert both the head node and the new ref without dropping in btrfs_add_delayed_tree_ref()
984 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_tree_ref()
993 trace_add_delayed_tree_ref(fs_info, &ref->node, ref, in btrfs_add_delayed_tree_ref()
997 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
1006 * add a delayed data ref. it's similar to btrfs_add_delayed_tree_ref.
1014 struct btrfs_delayed_data_ref *ref; in btrfs_add_delayed_data_ref() local
1030 ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS); in btrfs_add_delayed_data_ref()
1031 if (!ref) in btrfs_add_delayed_data_ref()
1038 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_data_ref()
1040 ref->root = ref_root; in btrfs_add_delayed_data_ref()
1041 ref->parent = parent; in btrfs_add_delayed_data_ref()
1042 ref->objectid = owner; in btrfs_add_delayed_data_ref()
1043 ref->offset = offset; in btrfs_add_delayed_data_ref()
1048 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1058 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1073 * insert both the head node and the new ref without dropping in btrfs_add_delayed_data_ref()
1080 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_data_ref()
1089 trace_add_delayed_data_ref(trans->fs_info, &ref->node, ref, in btrfs_add_delayed_data_ref()
1093 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()