Lines Matching refs:entry
554 struct btrfs_free_space_entry *entry; in io_ctl_add_entry() local
559 entry = io_ctl->cur; in io_ctl_add_entry()
560 put_unaligned_le64(offset, &entry->offset); in io_ctl_add_entry()
561 put_unaligned_le64(bytes, &entry->bytes); in io_ctl_add_entry()
562 entry->type = (bitmap) ? BTRFS_FREE_SPACE_BITMAP : in io_ctl_add_entry()
622 struct btrfs_free_space *entry, u8 *type) in io_ctl_read_entry() argument
634 entry->offset = get_unaligned_le64(&e->offset); in io_ctl_read_entry()
635 entry->bytes = get_unaligned_le64(&e->bytes); in io_ctl_read_entry()
649 struct btrfs_free_space *entry) in io_ctl_read_bitmap() argument
657 copy_page(entry->bitmap, io_ctl->cur); in io_ctl_read_bitmap()
1200 struct btrfs_free_space *entry, *next; in write_bitmap_entries() local
1204 list_for_each_entry_safe(entry, next, bitmap_list, list) { in write_bitmap_entries()
1205 ret = io_ctl_add_bitmap(io_ctl, entry->bitmap); in write_bitmap_entries()
1208 list_del_init(&entry->list); in write_bitmap_entries()
1229 struct btrfs_free_space *entry, *next; in cleanup_bitmap_list() local
1231 list_for_each_entry_safe(entry, next, bitmap_list, list) in cleanup_bitmap_list()
1232 list_del_init(&entry->list); in cleanup_bitmap_list()
1598 struct btrfs_free_space *entry, *prev = NULL; in tree_search_offset() local
1603 entry = NULL; in tree_search_offset()
1607 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1608 prev = entry; in tree_search_offset()
1610 if (offset < entry->offset) in tree_search_offset()
1612 else if (offset > entry->offset) in tree_search_offset()
1619 if (!entry) in tree_search_offset()
1621 if (entry->bitmap) in tree_search_offset()
1622 return entry; in tree_search_offset()
1631 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1632 if (entry->offset != offset) in tree_search_offset()
1635 WARN_ON(!entry->bitmap); in tree_search_offset()
1636 return entry; in tree_search_offset()
1637 } else if (entry) { in tree_search_offset()
1638 if (entry->bitmap) { in tree_search_offset()
1643 n = rb_prev(&entry->offset_index); in tree_search_offset()
1649 entry = prev; in tree_search_offset()
1652 return entry; in tree_search_offset()
1659 entry = prev; in tree_search_offset()
1660 if (entry->offset > offset) { in tree_search_offset()
1661 n = rb_prev(&entry->offset_index); in tree_search_offset()
1663 entry = rb_entry(n, struct btrfs_free_space, in tree_search_offset()
1665 ASSERT(entry->offset <= offset); in tree_search_offset()
1668 return entry; in tree_search_offset()
1674 if (entry->bitmap) { in tree_search_offset()
1675 n = rb_prev(&entry->offset_index); in tree_search_offset()
1683 if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) in tree_search_offset()
1684 return entry; in tree_search_offset()
1685 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1686 return entry; in tree_search_offset()
1692 if (entry->bitmap) { in tree_search_offset()
1693 if (entry->offset + BITS_PER_BITMAP * in tree_search_offset()
1697 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1701 n = rb_next(&entry->offset_index); in tree_search_offset()
1704 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1706 return entry; in tree_search_offset()
1876 static inline u64 get_max_extent_size(struct btrfs_free_space *entry) in get_max_extent_size() argument
1878 if (entry->bitmap) in get_max_extent_size()
1879 return entry->max_extent_size; in get_max_extent_size()
1880 return entry->bytes; in get_max_extent_size()
1888 struct btrfs_free_space *entry; in find_free_space() local
1897 entry = tree_search_offset(ctl, offset_to_bitmap(ctl, *offset), 0, 1); in find_free_space()
1898 if (!entry) in find_free_space()
1901 for (node = &entry->offset_index; node; node = rb_next(node)) { in find_free_space()
1902 entry = rb_entry(node, struct btrfs_free_space, offset_index); in find_free_space()
1903 if (entry->bytes < *bytes) { in find_free_space()
1904 *max_extent_size = max(get_max_extent_size(entry), in find_free_space()
1913 tmp = entry->offset - ctl->start + align - 1; in find_free_space()
1916 align_off = tmp - entry->offset; in find_free_space()
1919 tmp = entry->offset; in find_free_space()
1922 if (entry->bytes < *bytes + align_off) { in find_free_space()
1923 *max_extent_size = max(get_max_extent_size(entry), in find_free_space()
1928 if (entry->bitmap) { in find_free_space()
1931 ret = search_bitmap(ctl, entry, &tmp, &size, true); in find_free_space()
1935 return entry; in find_free_space()
1938 max(get_max_extent_size(entry), in find_free_space()
1945 *bytes = entry->bytes - align_off; in find_free_space()
1946 return entry; in find_free_space()
2181 struct btrfs_free_space *entry; in insert_into_bitmap() local
2193 entry = rb_entry(node, struct btrfs_free_space, offset_index); in insert_into_bitmap()
2194 if (!entry->bitmap) { in insert_into_bitmap()
2199 if (entry->offset == offset_to_bitmap(ctl, offset)) { in insert_into_bitmap()
2200 bytes_added = add_bytes_to_bitmap(ctl, entry, offset, in insert_into_bitmap()
2817 struct btrfs_free_space *entry; in __btrfs_return_cluster_to_free_space() local
2834 entry = rb_entry(node, struct btrfs_free_space, offset_index); in __btrfs_return_cluster_to_free_space()
2835 node = rb_next(&entry->offset_index); in __btrfs_return_cluster_to_free_space()
2836 rb_erase(&entry->offset_index, &cluster->root); in __btrfs_return_cluster_to_free_space()
2837 RB_CLEAR_NODE(&entry->offset_index); in __btrfs_return_cluster_to_free_space()
2839 bitmap = (entry->bitmap != NULL); in __btrfs_return_cluster_to_free_space()
2842 if (!btrfs_free_space_trimmed(entry)) { in __btrfs_return_cluster_to_free_space()
2845 entry->bytes; in __btrfs_return_cluster_to_free_space()
2848 try_merge_free_space(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2849 steal_from_bitmap(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2852 if (!btrfs_free_space_trimmed(entry)) { in __btrfs_return_cluster_to_free_space()
2855 entry->bytes; in __btrfs_return_cluster_to_free_space()
2859 entry->offset, &entry->offset_index, bitmap); in __btrfs_return_cluster_to_free_space()
2955 struct btrfs_free_space *entry = NULL; in btrfs_find_space_for_alloc() local
2965 entry = find_free_space(ctl, &offset, &bytes_search, in btrfs_find_space_for_alloc()
2967 if (!entry) in btrfs_find_space_for_alloc()
2971 if (entry->bitmap) { in btrfs_find_space_for_alloc()
2972 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2974 if (!btrfs_free_space_trimmed(entry)) in btrfs_find_space_for_alloc()
2977 if (!entry->bytes) in btrfs_find_space_for_alloc()
2978 free_bitmap(ctl, entry); in btrfs_find_space_for_alloc()
2980 unlink_free_space(ctl, entry); in btrfs_find_space_for_alloc()
2981 align_gap_len = offset - entry->offset; in btrfs_find_space_for_alloc()
2982 align_gap = entry->offset; in btrfs_find_space_for_alloc()
2983 align_gap_trim_state = entry->trim_state; in btrfs_find_space_for_alloc()
2985 if (!btrfs_free_space_trimmed(entry)) in btrfs_find_space_for_alloc()
2988 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2989 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2991 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2992 if (!entry->bytes) in btrfs_find_space_for_alloc()
2993 kmem_cache_free(btrfs_free_space_cachep, entry); in btrfs_find_space_for_alloc()
2995 link_free_space(ctl, entry); in btrfs_find_space_for_alloc()
3053 struct btrfs_free_space *entry, in btrfs_alloc_from_bitmap() argument
3066 err = search_bitmap(ctl, entry, &search_start, &search_bytes, true); in btrfs_alloc_from_bitmap()
3068 *max_extent_size = max(get_max_extent_size(entry), in btrfs_alloc_from_bitmap()
3074 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
3091 struct btrfs_free_space *entry = NULL; in btrfs_alloc_from_cluster() local
3108 entry = rb_entry(node, struct btrfs_free_space, offset_index); in btrfs_alloc_from_cluster()
3110 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
3111 *max_extent_size = max(get_max_extent_size(entry), in btrfs_alloc_from_cluster()
3114 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
3115 (!entry->bitmap && entry->offset < min_start)) { in btrfs_alloc_from_cluster()
3116 node = rb_next(&entry->offset_index); in btrfs_alloc_from_cluster()
3119 entry = rb_entry(node, struct btrfs_free_space, in btrfs_alloc_from_cluster()
3124 if (entry->bitmap) { in btrfs_alloc_from_cluster()
3126 cluster, entry, bytes, in btrfs_alloc_from_cluster()
3130 node = rb_next(&entry->offset_index); in btrfs_alloc_from_cluster()
3133 entry = rb_entry(node, struct btrfs_free_space, in btrfs_alloc_from_cluster()
3139 ret = entry->offset; in btrfs_alloc_from_cluster()
3141 entry->offset += bytes; in btrfs_alloc_from_cluster()
3142 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
3155 if (!btrfs_free_space_trimmed(entry)) in btrfs_alloc_from_cluster()
3159 if (!entry->bitmap && !btrfs_free_space_trimmed(entry)) in btrfs_alloc_from_cluster()
3163 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
3164 rb_erase(&entry->offset_index, &cluster->root); in btrfs_alloc_from_cluster()
3166 if (entry->bitmap) { in btrfs_alloc_from_cluster()
3168 entry->bitmap); in btrfs_alloc_from_cluster()
3171 } else if (!btrfs_free_space_trimmed(entry)) { in btrfs_alloc_from_cluster()
3174 kmem_cache_free(btrfs_free_space_cachep, entry); in btrfs_alloc_from_cluster()
3184 struct btrfs_free_space *entry, in btrfs_bitmap_cluster() argument
3200 i = offset_to_bit(entry->offset, ctl->unit, in btrfs_bitmap_cluster()
3201 max_t(u64, offset, entry->offset)); in btrfs_bitmap_cluster()
3209 if (entry->max_extent_size && in btrfs_bitmap_cluster()
3210 entry->max_extent_size < cont1_bytes) in btrfs_bitmap_cluster()
3214 for_each_set_bit_from(i, entry->bitmap, BITS_PER_BITMAP) { in btrfs_bitmap_cluster()
3215 next_zero = find_next_zero_bit(entry->bitmap, in btrfs_bitmap_cluster()
3229 entry->max_extent_size = (u64)max_bits * ctl->unit; in btrfs_bitmap_cluster()
3248 cluster->window_start = start * ctl->unit + entry->offset; in btrfs_bitmap_cluster()
3249 rb_erase(&entry->offset_index, &ctl->free_space_offset); in btrfs_bitmap_cluster()
3250 ret = tree_insert_offset(&cluster->root, entry->offset, in btrfs_bitmap_cluster()
3251 &entry->offset_index, 1); in btrfs_bitmap_cluster()
3272 struct btrfs_free_space *entry = NULL; in setup_cluster_no_bitmap() local
3279 entry = tree_search_offset(ctl, offset, 0, 1); in setup_cluster_no_bitmap()
3280 if (!entry) in setup_cluster_no_bitmap()
3287 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
3288 if (entry->bitmap && list_empty(&entry->list)) in setup_cluster_no_bitmap()
3289 list_add_tail(&entry->list, bitmaps); in setup_cluster_no_bitmap()
3290 node = rb_next(&entry->offset_index); in setup_cluster_no_bitmap()
3293 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
3296 window_free = entry->bytes; in setup_cluster_no_bitmap()
3297 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3298 first = entry; in setup_cluster_no_bitmap()
3299 last = entry; in setup_cluster_no_bitmap()
3301 for (node = rb_next(&entry->offset_index); node; in setup_cluster_no_bitmap()
3302 node = rb_next(&entry->offset_index)) { in setup_cluster_no_bitmap()
3303 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
3305 if (entry->bitmap) { in setup_cluster_no_bitmap()
3306 if (list_empty(&entry->list)) in setup_cluster_no_bitmap()
3307 list_add_tail(&entry->list, bitmaps); in setup_cluster_no_bitmap()
3311 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3314 last = entry; in setup_cluster_no_bitmap()
3315 window_free += entry->bytes; in setup_cluster_no_bitmap()
3316 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
3317 max_extent = entry->bytes; in setup_cluster_no_bitmap()
3334 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
3335 node = rb_next(&entry->offset_index); in setup_cluster_no_bitmap()
3336 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
3339 rb_erase(&entry->offset_index, &ctl->free_space_offset); in setup_cluster_no_bitmap()
3340 ret = tree_insert_offset(&cluster->root, entry->offset, in setup_cluster_no_bitmap()
3341 &entry->offset_index, 0); in setup_cluster_no_bitmap()
3342 total_size += entry->bytes; in setup_cluster_no_bitmap()
3344 } while (node && entry != last); in setup_cluster_no_bitmap()
3362 struct btrfs_free_space *entry = NULL; in setup_cluster_bitmap() local
3374 entry = list_first_entry(bitmaps, struct btrfs_free_space, list); in setup_cluster_bitmap()
3376 if (!entry || entry->offset != bitmap_offset) { in setup_cluster_bitmap()
3377 entry = tree_search_offset(ctl, bitmap_offset, 1, 0); in setup_cluster_bitmap()
3378 if (entry && list_empty(&entry->list)) in setup_cluster_bitmap()
3379 list_add(&entry->list, bitmaps); in setup_cluster_bitmap()
3382 list_for_each_entry(entry, bitmaps, list) { in setup_cluster_bitmap()
3383 if (entry->bytes < bytes) in setup_cluster_bitmap()
3385 ret = btrfs_bitmap_cluster(block_group, entry, cluster, offset, in setup_cluster_bitmap()
3412 struct btrfs_free_space *entry, *tmp; in btrfs_find_space_cluster() local
3465 list_for_each_entry_safe(entry, tmp, &bitmaps, list) in btrfs_find_space_cluster()
3466 list_del_init(&entry->list); in btrfs_find_space_cluster()
3565 struct btrfs_free_space *entry; in trim_no_bitmap() local
3583 entry = tree_search_offset(ctl, start, 0, 1); in trim_no_bitmap()
3584 if (!entry) in trim_no_bitmap()
3588 while (entry->bitmap || in trim_no_bitmap()
3589 (async && btrfs_free_space_trimmed(entry))) { in trim_no_bitmap()
3590 node = rb_next(&entry->offset_index); in trim_no_bitmap()
3593 entry = rb_entry(node, struct btrfs_free_space, in trim_no_bitmap()
3597 if (entry->offset >= end) in trim_no_bitmap()
3600 extent_start = entry->offset; in trim_no_bitmap()
3601 extent_bytes = entry->bytes; in trim_no_bitmap()
3602 extent_trim_state = entry->trim_state; in trim_no_bitmap()
3604 start = entry->offset; in trim_no_bitmap()
3605 bytes = entry->bytes; in trim_no_bitmap()
3611 unlink_free_space(ctl, entry); in trim_no_bitmap()
3622 entry->offset += max_discard_size; in trim_no_bitmap()
3623 entry->bytes -= max_discard_size; in trim_no_bitmap()
3624 link_free_space(ctl, entry); in trim_no_bitmap()
3626 kmem_cache_free(btrfs_free_space_cachep, entry); in trim_no_bitmap()
3637 unlink_free_space(ctl, entry); in trim_no_bitmap()
3638 kmem_cache_free(btrfs_free_space_cachep, entry); in trim_no_bitmap()
3694 struct btrfs_free_space *entry; in reset_trimming_bitmap() local
3697 entry = tree_search_offset(ctl, offset, 1, 0); in reset_trimming_bitmap()
3698 if (entry) { in reset_trimming_bitmap()
3699 if (btrfs_free_space_trimmed(entry)) { in reset_trimming_bitmap()
3701 entry->bitmap_extents; in reset_trimming_bitmap()
3702 ctl->discardable_bytes[BTRFS_STAT_CURR] += entry->bytes; in reset_trimming_bitmap()
3704 entry->trim_state = BTRFS_TRIM_STATE_UNTRIMMED; in reset_trimming_bitmap()
3711 struct btrfs_free_space *entry) in end_trimming_bitmap() argument
3713 if (btrfs_free_space_trimming_bitmap(entry)) { in end_trimming_bitmap()
3714 entry->trim_state = BTRFS_TRIM_STATE_TRIMMED; in end_trimming_bitmap()
3716 entry->bitmap_extents; in end_trimming_bitmap()
3717 ctl->discardable_bytes[BTRFS_STAT_CURR] -= entry->bytes; in end_trimming_bitmap()
3731 struct btrfs_free_space *entry; in trim_bitmaps() local
3753 entry = tree_search_offset(ctl, offset, 1, 0); in trim_bitmaps()
3762 if (!entry || (async && minlen && start == offset && in trim_bitmaps()
3763 btrfs_free_space_trimmed(entry))) { in trim_bitmaps()
3777 entry->trim_state = BTRFS_TRIM_STATE_TRIMMING; in trim_bitmaps()
3780 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3787 end_trimming_bitmap(ctl, entry); in trim_bitmaps()
3789 entry->trim_state = BTRFS_TRIM_STATE_UNTRIMMED; in trim_bitmaps()
3824 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3825 if (entry->bytes == 0) in trim_bitmaps()
3826 free_bitmap(ctl, entry); in trim_bitmaps()