Lines Matching defs:head
107 * the head node for delayed ref is used to store the sum of all the
108 * reference count modifications queued up in the rbtree. the head
117 struct btrfs_delayed_ref_head *head;
201 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
202 if (head) {
203 if (!mutex_trylock(&head->mutex)) {
204 refcount_inc(&head->refs);
213 mutex_lock(&head->mutex);
214 mutex_unlock(&head->mutex);
215 btrfs_put_delayed_ref_head(head);
218 spin_lock(&head->lock);
219 if (head->extent_op && head->extent_op->update_flags)
220 extent_flags |= head->extent_op->flags_to_set;
224 num_refs += head->ref_mod;
225 spin_unlock(&head->lock);
226 mutex_unlock(&head->mutex);
1543 struct btrfs_delayed_ref_head *head,
1566 key.objectid = head->bytenr;
1573 key.offset = head->num_bytes;
1589 if (key.objectid == head->bytenr &&
1591 key.offset == head->num_bytes)
1598 key.objectid = head->bytenr;
1599 key.offset = head->num_bytes;
1702 select_delayed_ref(struct btrfs_delayed_ref_head *head)
1706 if (RB_EMPTY_ROOT(&head->ref_tree.rb_root))
1715 if (!list_empty(&head->ref_add_list))
1716 return list_first_entry(&head->ref_add_list,
1719 ref = rb_entry(rb_first_cached(&head->ref_tree),
1726 struct btrfs_delayed_ref_head *head)
1729 head->processing = 0;
1732 btrfs_delayed_ref_unlock(head);
1736 struct btrfs_delayed_ref_head *head)
1738 struct btrfs_delayed_extent_op *extent_op = head->extent_op;
1743 if (head->must_insert_reserved) {
1744 head->extent_op = NULL;
1752 struct btrfs_delayed_ref_head *head)
1757 extent_op = cleanup_extent_op(head);
1760 head->extent_op = NULL;
1761 spin_unlock(&head->lock);
1762 ret = run_delayed_extent_op(trans, head, extent_op);
1769 struct btrfs_delayed_ref_head *head)
1771 int nr_items = 1; /* Dropping this ref head update. */
1777 if (head->total_ref_mod < 0 && head->is_data) {
1779 delayed_refs->pending_csums -= head->num_bytes;
1781 nr_items += btrfs_csum_bytes_to_leaves(fs_info, head->num_bytes);
1790 if (head->total_ref_mod < 0 ||
1791 (head->total_ref_mod == 0 && head->must_insert_reserved)) {
1792 u64 flags = btrfs_ref_head_to_space_flags(head);
1794 btrfs_mod_total_bytes_pinned(fs_info, flags, -head->num_bytes);
1801 struct btrfs_delayed_ref_head *head)
1810 ret = run_and_cleanup_extent_op(trans, head);
1812 unselect_delayed_ref_head(delayed_refs, head);
1820 * Need to drop our head ref lock and re-acquire the delayed ref lock
1823 spin_unlock(&head->lock);
1825 spin_lock(&head->lock);
1826 if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root) || head->extent_op) {
1827 spin_unlock(&head->lock);
1831 btrfs_delete_ref_head(delayed_refs, head);
1832 spin_unlock(&head->lock);
1835 if (head->must_insert_reserved) {
1836 btrfs_pin_extent(trans, head->bytenr, head->num_bytes, 1);
1837 if (head->is_data) {
1839 head->bytenr, head->num_bytes);
1843 btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head);
1845 trace_run_delayed_ref_head(fs_info, head, 0);
1846 btrfs_delayed_ref_unlock(head);
1847 btrfs_put_delayed_ref_head(head);
1856 struct btrfs_delayed_ref_head *head = NULL;
1860 head = btrfs_select_ref_head(delayed_refs);
1861 if (!head) {
1863 return head;
1868 * this head
1870 ret = btrfs_delayed_ref_lock(delayed_refs, head);
1874 * We may have dropped the spin lock to get the head mutex lock, and
1875 * that might have given someone else time to free the head. If that's
1879 head = ERR_PTR(-EAGAIN);
1881 return head;
1916 * head
2016 * head
2030 * returned -EAGAIN, meaning we need to select another head
2136 struct btrfs_delayed_ref_head *head;
2170 head = rb_entry(node, struct btrfs_delayed_ref_head,
2172 refcount_inc(&head->refs);
2176 mutex_lock(&head->mutex);
2177 mutex_unlock(&head->mutex);
2179 btrfs_put_delayed_ref_head(head);
2214 struct btrfs_delayed_ref_head *head;
2232 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
2233 if (!head) {
2239 if (!mutex_trylock(&head->mutex)) {
2240 refcount_inc(&head->refs);
2249 mutex_lock(&head->mutex);
2250 mutex_unlock(&head->mutex);
2251 btrfs_put_delayed_ref_head(head);
2257 spin_lock(&head->lock);
2262 for (node = rb_first_cached(&head->ref_tree); node;
2284 spin_unlock(&head->lock);
2285 mutex_unlock(&head->mutex);
3273 struct btrfs_delayed_ref_head *head;
3279 head = btrfs_find_delayed_ref_head(delayed_refs, bytenr);
3280 if (!head)
3283 spin_lock(&head->lock);
3284 if (!RB_EMPTY_ROOT(&head->ref_tree.rb_root))
3287 if (cleanup_extent_op(head) != NULL)
3294 if (!mutex_trylock(&head->mutex))
3297 btrfs_delete_ref_head(delayed_refs, head);
3298 head->processing = 0;
3300 spin_unlock(&head->lock);
3303 BUG_ON(head->extent_op);
3304 if (head->must_insert_reserved)
3307 btrfs_cleanup_ref_head_accounting(trans->fs_info, delayed_refs, head);
3308 mutex_unlock(&head->mutex);
3309 btrfs_put_delayed_ref_head(head);
3312 spin_unlock(&head->lock);
5724 * list head uses. For that, we need to take a reference to the