Lines Matching refs:head
95 * the head node for delayed ref is used to store the sum of all the
96 * reference count modifications queued up in the rbtree. the head
106 struct btrfs_delayed_ref_head *head;
193 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
194 if (head) {
195 if (!mutex_trylock(&head->mutex)) {
196 refcount_inc(&head->refs);
205 mutex_lock(&head->mutex);
206 mutex_unlock(&head->mutex);
207 btrfs_put_delayed_ref_head(head);
210 spin_lock(&head->lock);
211 if (head->extent_op && head->extent_op->update_flags)
212 extent_flags |= head->extent_op->flags_to_set;
216 num_refs += head->ref_mod;
217 spin_unlock(&head->lock);
218 mutex_unlock(&head->mutex);
1601 struct btrfs_delayed_ref_head *head,
1625 key.objectid = head->bytenr;
1632 key.offset = head->num_bytes;
1648 if (key.objectid == head->bytenr &&
1650 key.offset == head->num_bytes)
1657 key.objectid = head->bytenr;
1658 key.offset = head->num_bytes;
1666 head->bytenr, head->num_bytes, extent_op->level);
1766 select_delayed_ref(struct btrfs_delayed_ref_head *head)
1770 if (RB_EMPTY_ROOT(&head->ref_tree.rb_root))
1779 if (!list_empty(&head->ref_add_list))
1780 return list_first_entry(&head->ref_add_list,
1783 ref = rb_entry(rb_first_cached(&head->ref_tree),
1790 struct btrfs_delayed_ref_head *head)
1793 head->processing = false;
1796 btrfs_delayed_ref_unlock(head);
1800 struct btrfs_delayed_ref_head *head)
1802 struct btrfs_delayed_extent_op *extent_op = head->extent_op;
1807 if (head->must_insert_reserved) {
1808 head->extent_op = NULL;
1816 struct btrfs_delayed_ref_head *head)
1821 extent_op = cleanup_extent_op(head);
1824 head->extent_op = NULL;
1825 spin_unlock(&head->lock);
1826 ret = run_delayed_extent_op(trans, head, extent_op);
1833 struct btrfs_delayed_ref_head *head)
1835 int nr_items = 1; /* Dropping this ref head update. */
1841 if (head->total_ref_mod < 0 && head->is_data) {
1843 delayed_refs->pending_csums -= head->num_bytes;
1845 nr_items += btrfs_csum_bytes_to_leaves(fs_info, head->num_bytes);
1852 struct btrfs_delayed_ref_head *head)
1861 ret = run_and_cleanup_extent_op(trans, head);
1863 unselect_delayed_ref_head(delayed_refs, head);
1871 * Need to drop our head ref lock and re-acquire the delayed ref lock
1874 spin_unlock(&head->lock);
1876 spin_lock(&head->lock);
1877 if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root) || head->extent_op) {
1878 spin_unlock(&head->lock);
1882 btrfs_delete_ref_head(delayed_refs, head);
1883 spin_unlock(&head->lock);
1886 if (head->must_insert_reserved) {
1887 btrfs_pin_extent(trans, head->bytenr, head->num_bytes, 1);
1888 if (head->is_data) {
1891 csum_root = btrfs_csum_root(fs_info, head->bytenr);
1892 ret = btrfs_del_csums(trans, csum_root, head->bytenr,
1893 head->num_bytes);
1897 btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head);
1899 trace_run_delayed_ref_head(fs_info, head, 0);
1900 btrfs_delayed_ref_unlock(head);
1901 btrfs_put_delayed_ref_head(head);
1910 struct btrfs_delayed_ref_head *head = NULL;
1914 head = btrfs_select_ref_head(delayed_refs);
1915 if (!head) {
1917 return head;
1922 * this head
1924 ret = btrfs_delayed_ref_lock(delayed_refs, head);
1928 * We may have dropped the spin lock to get the head mutex lock, and
1929 * that might have given someone else time to free the head. If that's
1933 head = ERR_PTR(-EAGAIN);
1935 return head;
1967 * head
2064 * head
2078 * returned -EAGAIN, meaning we need to select another head
2147 struct btrfs_delayed_ref_head *head;
2181 head = rb_entry(node, struct btrfs_delayed_ref_head,
2183 refcount_inc(&head->refs);
2187 mutex_lock(&head->mutex);
2188 mutex_unlock(&head->mutex);
2190 btrfs_put_delayed_ref_head(head);
2224 struct btrfs_delayed_ref_head *head;
2242 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
2243 if (!head) {
2249 if (!mutex_trylock(&head->mutex)) {
2256 refcount_inc(&head->refs);
2265 mutex_lock(&head->mutex);
2266 mutex_unlock(&head->mutex);
2267 btrfs_put_delayed_ref_head(head);
2273 spin_lock(&head->lock);
2278 for (node = rb_first_cached(&head->ref_tree); node;
2300 spin_unlock(&head->lock);
2301 mutex_unlock(&head->mutex);
3235 struct btrfs_delayed_ref_head *head;
3241 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
3242 if (!head)
3245 spin_lock(&head->lock);
3246 if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root))
3249 if (cleanup_extent_op(head) != NULL)
3256 if (!mutex_trylock(&head->mutex))
3259 btrfs_delete_ref_head(delayed_refs, head);
3260 head->processing = false;
3262 spin_unlock(&head->lock);
3265 BUG_ON(head->extent_op);
3266 if (head->must_insert_reserved)
3269 btrfs_cleanup_ref_head_accounting(trans->fs_info, delayed_refs, head);
3270 mutex_unlock(&head->mutex);
3271 btrfs_put_delayed_ref_head(head);
3274 spin_unlock(&head->lock);
5984 * list head uses. For that, we need to take a reference to the