• Home
  • Raw
  • Download

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
276 /* insert a new ref to head ref rbtree */
356 * Find a head entry based on bytenr. This returns the delayed ref head if it
417 struct btrfs_delayed_ref_node *ref) in drop_delayed_ref() argument
420 rb_erase_cached(&ref->ref_node, &head->ref_tree); in drop_delayed_ref()
421 RB_CLEAR_NODE(&ref->ref_node); in drop_delayed_ref()
422 if (!list_empty(&ref->add_list)) in drop_delayed_ref()
423 list_del(&ref->add_list); in drop_delayed_ref()
424 ref->in_tree = 0; in drop_delayed_ref()
425 btrfs_put_delayed_ref(ref); in drop_delayed_ref()
432 struct btrfs_delayed_ref_node *ref, in merge_ref() argument
436 struct rb_node *node = rb_next(&ref->ref_node); in merge_ref()
446 if (comp_refs(ref, next, false)) in merge_ref()
449 if (ref->action == next->action) { in merge_ref()
452 if (ref->ref_mod < next->ref_mod) { in merge_ref()
453 swap(ref, next); in merge_ref()
460 ref->ref_mod += mod; in merge_ref()
461 if (ref->ref_mod == 0) { in merge_ref()
462 drop_delayed_ref(trans, delayed_refs, head, ref); in merge_ref()
466 * Can't have multiples of the same ref on a tree block. in merge_ref()
468 WARN_ON(ref->type == BTRFS_TREE_BLOCK_REF_KEY || in merge_ref()
469 ref->type == BTRFS_SHARED_BLOCK_REF_KEY); in merge_ref()
481 struct btrfs_delayed_ref_node *ref; in btrfs_merge_delayed_refs() local
507 ref = rb_entry(node, struct btrfs_delayed_ref_node, ref_node); in btrfs_merge_delayed_refs()
508 if (seq && ref->seq >= seq) in btrfs_merge_delayed_refs()
510 if (merge_ref(trans, delayed_refs, head, ref, seq)) in btrfs_merge_delayed_refs()
597 struct btrfs_delayed_ref_node *ref) in insert_delayed_ref() argument
604 exist = tree_insert(&href->ref_tree, ref); in insert_delayed_ref()
610 if (exist->action == ref->action) { in insert_delayed_ref()
611 mod = ref->ref_mod; in insert_delayed_ref()
614 if (exist->ref_mod < ref->ref_mod) { in insert_delayed_ref()
615 exist->action = ref->action; in insert_delayed_ref()
617 exist->ref_mod = ref->ref_mod; in insert_delayed_ref()
618 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
621 else if (ref->action == BTRFS_DROP_DELAYED_REF) { in insert_delayed_ref()
628 mod = -ref->ref_mod; in insert_delayed_ref()
638 if (ref->action == BTRFS_ADD_DELAYED_REF) in insert_delayed_ref()
639 list_add_tail(&ref->add_list, &href->ref_add_list); in insert_delayed_ref()
646 * helper function to update the accounting in the head ref
664 * reallocated before the delayed ref in update_existing_head_ref()
666 * with an existing head ref without in update_existing_head_ref()
708 * If we are going to from a positive ref mod to a negative or vice in update_existing_head_ref()
729 * 1. We had a ref mod of 0 or more and went negative, indicating that in update_existing_head_ref()
762 * The head node stores the sum of all the mods, so dropping a ref in init_delayed_ref_head()
773 * modification deletes the delayed ref without ever inserting the in init_delayed_ref_head()
774 * extent into the extent allocation tree. ref->must_insert_reserved in init_delayed_ref_head()
844 * we've updated the existing ref, free the newly in add_delayed_ref_head()
845 * allocated ref in add_delayed_ref_head()
878 * @ref: The structure which is going to be initialized.
898 struct btrfs_delayed_ref_node *ref, in init_delayed_ref_common() argument
910 refcount_set(&ref->refs, 1); in init_delayed_ref_common()
911 ref->bytenr = bytenr; in init_delayed_ref_common()
912 ref->num_bytes = num_bytes; in init_delayed_ref_common()
913 ref->ref_mod = 1; in init_delayed_ref_common()
914 ref->action = action; in init_delayed_ref_common()
915 ref->is_head = 0; in init_delayed_ref_common()
916 ref->in_tree = 1; in init_delayed_ref_common()
917 ref->seq = seq; in init_delayed_ref_common()
918 ref->type = ref_type; in init_delayed_ref_common()
919 RB_CLEAR_NODE(&ref->ref_node); in init_delayed_ref_common()
920 INIT_LIST_HEAD(&ref->add_list); in init_delayed_ref_common()
924 * add a delayed tree ref. This does all of the accounting required
925 * to make sure the delayed ref is eventually processed before this
933 struct btrfs_delayed_tree_ref *ref; in btrfs_add_delayed_tree_ref() local
951 ref = kmem_cache_alloc(btrfs_delayed_tree_ref_cachep, GFP_NOFS); in btrfs_add_delayed_tree_ref()
952 if (!ref) in btrfs_add_delayed_tree_ref()
957 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
967 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
978 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_tree_ref()
980 ref->root = generic_ref->tree_ref.root; in btrfs_add_delayed_tree_ref()
981 ref->parent = parent; in btrfs_add_delayed_tree_ref()
982 ref->level = level; in btrfs_add_delayed_tree_ref()
993 * insert both the head node and the new ref without dropping in btrfs_add_delayed_tree_ref()
999 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_tree_ref()
1008 trace_add_delayed_tree_ref(fs_info, &ref->node, ref, in btrfs_add_delayed_tree_ref()
1012 kmem_cache_free(btrfs_delayed_tree_ref_cachep, ref); in btrfs_add_delayed_tree_ref()
1021 * add a delayed data ref. it's similar to btrfs_add_delayed_tree_ref.
1028 struct btrfs_delayed_data_ref *ref; in btrfs_add_delayed_data_ref() local
1044 ref = kmem_cache_alloc(btrfs_delayed_data_ref_cachep, GFP_NOFS); in btrfs_add_delayed_data_ref()
1045 if (!ref) in btrfs_add_delayed_data_ref()
1052 init_delayed_ref_common(fs_info, &ref->node, bytenr, num_bytes, in btrfs_add_delayed_data_ref()
1054 ref->root = ref_root; in btrfs_add_delayed_data_ref()
1055 ref->parent = parent; in btrfs_add_delayed_data_ref()
1056 ref->objectid = owner; in btrfs_add_delayed_data_ref()
1057 ref->offset = offset; in btrfs_add_delayed_data_ref()
1062 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1072 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()
1087 * insert both the head node and the new ref without dropping in btrfs_add_delayed_data_ref()
1093 ret = insert_delayed_ref(trans, delayed_refs, head_ref, &ref->node); in btrfs_add_delayed_data_ref()
1102 trace_add_delayed_data_ref(trans->fs_info, &ref->node, ref, in btrfs_add_delayed_data_ref()
1106 kmem_cache_free(btrfs_delayed_data_ref_cachep, ref); in btrfs_add_delayed_data_ref()