Lines Matching full:ref
10 #include "delayed-ref.h"
73 * Release a ref head's reservation
78 * This drops the delayed ref head's count from the delayed refs rsv and frees
301 /* insert a new ref to head ref rbtree */
381 * Find a head entry based on bytenr. This returns the delayed ref head if it
442 struct btrfs_delayed_ref_node *ref) in drop_delayed_ref() argument
445 rb_erase_cached(&ref->ref_node, &head->ref_tree); in drop_delayed_ref()
446 RB_CLEAR_NODE(&ref->ref_node); in drop_delayed_ref()
447 if (!list_empty(&ref->add_list)) in drop_delayed_ref()
448 list_del(&ref->add_list); in drop_delayed_ref()
449 ref->in_tree = 0; in drop_delayed_ref()
450 btrfs_put_delayed_ref(ref); in drop_delayed_ref()
457 struct btrfs_delayed_ref_node *ref, in merge_ref() argument
461 struct rb_node *node = rb_next(&ref->ref_node); in merge_ref()
471 if (comp_refs(ref, next, false)) in merge_ref()
474 if (ref->action == next->action) { in merge_ref()
477 if (ref->ref_mod < next->ref_mod) { in merge_ref()
478 swap(ref, next); in merge_ref()
485 ref->ref_mod += mod; in merge_ref()
486 if (ref->ref_mod == 0) { in merge_ref()
487 drop_delayed_ref(trans, delayed_refs, head, ref); in merge_ref()
491 * Can't have multiples of the same ref on a tree block. in merge_ref()
493 WARN_ON(ref->type == BTRFS_TREE_BLOCK_REF_KEY || in merge_ref()
494 ref->type == BTRFS_SHARED_BLOCK_REF_KEY); in merge_ref()
506 struct btrfs_delayed_ref_node *ref; in btrfs_merge_delayed_refs() local
523 ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node); in btrfs_merge_delayed_refs()
524 if (seq && ref->seq >= seq) in btrfs_merge_delayed_refs()
526 if (merge_ref(trans, delayed_refs, head, ref, seq)) in btrfs_merge_delayed_refs()
606 struct btrfs_delayed_ref_node *ref) in insert_delayed_ref() argument
613 exist = tree_insert(&href->ref_tree, ref); in insert_delayed_ref()
619 if (exist->action == ref->action) { in insert_delayed_ref()
620 mod = ref->ref_mod; in insert_delayed_ref()
623 if (exist->ref_mod < ref->ref_mod) { in insert_delayed_ref()
624 exist->action = ref->action; in insert_delayed_ref()
626 exist->ref_mod = ref->ref_mod; in insert_delayed_ref()
627 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
630 else if (ref->action == BTRFS_DROP_DELAYED_REF) { in insert_delayed_ref()
637 mod = -ref->ref_mod; in insert_delayed_ref()
647 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
648 list_add_tail(&ref->add_list, &href->ref_add_list); in insert_delayed_ref()
655 * helper function to update the accounting in the head ref
672 * reallocated before the delayed ref in update_existing_head_ref()
674 * with an existing head ref without in update_existing_head_ref()
716 * If we are going to from a positive ref mod to a negative or vice in update_existing_head_ref()
750 * The head node stores the sum of all the mods, so dropping a ref in init_delayed_ref_head()
761 * modification deletes the delayed ref without ever inserting the in init_delayed_ref_head()
762 * extent into the extent allocation tree. ref->must_insert_reserved in init_delayed_ref_head()
832 * we've updated the existing ref, free the newly in add_delayed_ref_head()
833 * 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
916 struct btrfs_delayed_tree_ref *ref; in btrfs_add_delayed_tree_ref() local
933 ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS); in btrfs_add_delayed_tree_ref()
934 if (!ref) in btrfs_add_delayed_tree_ref()
939 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
947 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
958 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_tree_ref()
961 ref->root = generic_ref->tree_ref.owning_root; in btrfs_add_delayed_tree_ref()
962 ref->parent = parent; in btrfs_add_delayed_tree_ref()
963 ref->level = level; in btrfs_add_delayed_tree_ref()
974 * insert both the head node and the new ref without dropping in btrfs_add_delayed_tree_ref()
980 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_tree_ref()
989 trace_add_delayed_tree_ref(fs_info, &ref->node, ref, in btrfs_add_delayed_tree_ref()
993 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
1002 * add a delayed data ref. it's similar to btrfs_add_delayed_tree_ref.
1009 struct btrfs_delayed_data_ref *ref; in btrfs_add_delayed_data_ref() local
1025 ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS); in btrfs_add_delayed_data_ref()
1026 if (!ref) in btrfs_add_delayed_data_ref()
1033 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_data_ref()
1035 ref->root = ref_root; in btrfs_add_delayed_data_ref()
1036 ref->parent = parent; in btrfs_add_delayed_data_ref()
1037 ref->objectid = owner; in btrfs_add_delayed_data_ref()
1038 ref->offset = offset; in btrfs_add_delayed_data_ref()
1043 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1051 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1066 * insert both the head node and the new ref without dropping in btrfs_add_delayed_data_ref()
1072 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_data_ref()
1081 trace_add_delayed_data_ref(trans->fs_info, &ref->node, ref, in btrfs_add_delayed_data_ref()
1085 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()