• Home
  • Raw
  • Download

Lines Matching refs:entry

519 	struct btrfs_free_space_entry *entry;  in io_ctl_add_entry()  local
524 entry = io_ctl->cur; in io_ctl_add_entry()
525 entry->offset = cpu_to_le64(offset); in io_ctl_add_entry()
526 entry->bytes = cpu_to_le64(bytes); in io_ctl_add_entry()
527 entry->type = (bitmap) ? BTRFS_FREE_SPACE_BITMAP : in io_ctl_add_entry()
587 struct btrfs_free_space *entry, u8 *type) in io_ctl_read_entry() argument
599 entry->offset = le64_to_cpu(e->offset); in io_ctl_read_entry()
600 entry->bytes = le64_to_cpu(e->bytes); in io_ctl_read_entry()
614 struct btrfs_free_space *entry) in io_ctl_read_bitmap() argument
622 copy_page(entry->bitmap, io_ctl->cur); in io_ctl_read_bitmap()
1103 struct btrfs_free_space *entry, *next; in write_bitmap_entries() local
1107 list_for_each_entry_safe(entry, next, bitmap_list, list) { in write_bitmap_entries()
1108 ret = io_ctl_add_bitmap(io_ctl, entry->bitmap); in write_bitmap_entries()
1111 list_del_init(&entry->list); in write_bitmap_entries()
1132 struct btrfs_free_space *entry, *next; in cleanup_bitmap_list() local
1134 list_for_each_entry_safe(entry, next, bitmap_list, list) in cleanup_bitmap_list()
1135 list_del_init(&entry->list); in cleanup_bitmap_list()
1512 struct btrfs_free_space *entry, *prev = NULL; in tree_search_offset() local
1517 entry = NULL; in tree_search_offset()
1521 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1522 prev = entry; in tree_search_offset()
1524 if (offset < entry->offset) in tree_search_offset()
1526 else if (offset > entry->offset) in tree_search_offset()
1533 if (!entry) in tree_search_offset()
1535 if (entry->bitmap) in tree_search_offset()
1536 return entry; in tree_search_offset()
1545 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1546 if (entry->offset != offset) in tree_search_offset()
1549 WARN_ON(!entry->bitmap); in tree_search_offset()
1550 return entry; in tree_search_offset()
1551 } else if (entry) { in tree_search_offset()
1552 if (entry->bitmap) { in tree_search_offset()
1557 n = rb_prev(&entry->offset_index); in tree_search_offset()
1563 entry = prev; in tree_search_offset()
1566 return entry; in tree_search_offset()
1573 entry = prev; in tree_search_offset()
1574 if (entry->offset > offset) { in tree_search_offset()
1575 n = rb_prev(&entry->offset_index); in tree_search_offset()
1577 entry = rb_entry(n, struct btrfs_free_space, in tree_search_offset()
1579 ASSERT(entry->offset <= offset); in tree_search_offset()
1582 return entry; in tree_search_offset()
1588 if (entry->bitmap) { in tree_search_offset()
1589 n = rb_prev(&entry->offset_index); in tree_search_offset()
1597 if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) in tree_search_offset()
1598 return entry; in tree_search_offset()
1599 } else if (entry->offset + entry->bytes > offset) in tree_search_offset()
1600 return entry; in tree_search_offset()
1606 if (entry->bitmap) { in tree_search_offset()
1607 if (entry->offset + BITS_PER_BITMAP * in tree_search_offset()
1611 if (entry->offset + entry->bytes > offset) in tree_search_offset()
1615 n = rb_next(&entry->offset_index); in tree_search_offset()
1618 entry = rb_entry(n, struct btrfs_free_space, offset_index); in tree_search_offset()
1620 return entry; in tree_search_offset()
1799 static inline u64 get_max_extent_size(struct btrfs_free_space *entry) in get_max_extent_size() argument
1801 if (entry->bitmap) in get_max_extent_size()
1802 return entry->max_extent_size; in get_max_extent_size()
1803 return entry->bytes; in get_max_extent_size()
1811 struct btrfs_free_space *entry; in find_free_space() local
1820 entry = tree_search_offset(ctl, offset_to_bitmap(ctl, *offset), 0, 1); in find_free_space()
1821 if (!entry) in find_free_space()
1824 for (node = &entry->offset_index; node; node = rb_next(node)) { in find_free_space()
1825 entry = rb_entry(node, struct btrfs_free_space, offset_index); in find_free_space()
1826 if (entry->bytes < *bytes) { in find_free_space()
1827 *max_extent_size = max(get_max_extent_size(entry), in find_free_space()
1836 tmp = entry->offset - ctl->start + align - 1; in find_free_space()
1839 align_off = tmp - entry->offset; in find_free_space()
1842 tmp = entry->offset; in find_free_space()
1845 if (entry->bytes < *bytes + align_off) { in find_free_space()
1846 *max_extent_size = max(get_max_extent_size(entry), in find_free_space()
1851 if (entry->bitmap) { in find_free_space()
1854 ret = search_bitmap(ctl, entry, &tmp, &size, true); in find_free_space()
1858 return entry; in find_free_space()
1861 max(get_max_extent_size(entry), in find_free_space()
1868 *bytes = entry->bytes - align_off; in find_free_space()
1869 return entry; in find_free_space()
2074 struct btrfs_free_space *entry; in insert_into_bitmap() local
2086 entry = rb_entry(node, struct btrfs_free_space, offset_index); in insert_into_bitmap()
2087 if (!entry->bitmap) { in insert_into_bitmap()
2092 if (entry->offset == offset_to_bitmap(ctl, offset)) { in insert_into_bitmap()
2093 bytes_added = add_bytes_to_bitmap(ctl, entry, in insert_into_bitmap()
2545 struct btrfs_free_space *entry; in __btrfs_return_cluster_to_free_space() local
2560 entry = rb_entry(node, struct btrfs_free_space, offset_index); in __btrfs_return_cluster_to_free_space()
2561 node = rb_next(&entry->offset_index); in __btrfs_return_cluster_to_free_space()
2562 rb_erase(&entry->offset_index, &cluster->root); in __btrfs_return_cluster_to_free_space()
2563 RB_CLEAR_NODE(&entry->offset_index); in __btrfs_return_cluster_to_free_space()
2565 bitmap = (entry->bitmap != NULL); in __btrfs_return_cluster_to_free_space()
2567 try_merge_free_space(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2568 steal_from_bitmap(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2571 entry->offset, &entry->offset_index, bitmap); in __btrfs_return_cluster_to_free_space()
2634 struct btrfs_free_space *entry = NULL; in btrfs_find_space_for_alloc() local
2641 entry = find_free_space(ctl, &offset, &bytes_search, in btrfs_find_space_for_alloc()
2643 if (!entry) in btrfs_find_space_for_alloc()
2647 if (entry->bitmap) { in btrfs_find_space_for_alloc()
2648 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2649 if (!entry->bytes) in btrfs_find_space_for_alloc()
2650 free_bitmap(ctl, entry); in btrfs_find_space_for_alloc()
2652 unlink_free_space(ctl, entry); in btrfs_find_space_for_alloc()
2653 align_gap_len = offset - entry->offset; in btrfs_find_space_for_alloc()
2654 align_gap = entry->offset; in btrfs_find_space_for_alloc()
2656 entry->offset = offset + bytes; in btrfs_find_space_for_alloc()
2657 WARN_ON(entry->bytes < bytes + align_gap_len); in btrfs_find_space_for_alloc()
2659 entry->bytes -= bytes + align_gap_len; in btrfs_find_space_for_alloc()
2660 if (!entry->bytes) in btrfs_find_space_for_alloc()
2661 kmem_cache_free(btrfs_free_space_cachep, entry); in btrfs_find_space_for_alloc()
2663 link_free_space(ctl, entry); in btrfs_find_space_for_alloc()
2719 struct btrfs_free_space *entry, in btrfs_alloc_from_bitmap() argument
2732 err = search_bitmap(ctl, entry, &search_start, &search_bytes, true); in btrfs_alloc_from_bitmap()
2734 *max_extent_size = max(get_max_extent_size(entry), in btrfs_alloc_from_bitmap()
2740 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2755 struct btrfs_free_space *entry = NULL; in btrfs_alloc_from_cluster() local
2770 entry = rb_entry(node, struct btrfs_free_space, offset_index); in btrfs_alloc_from_cluster()
2772 if (entry->bytes < bytes) in btrfs_alloc_from_cluster()
2773 *max_extent_size = max(get_max_extent_size(entry), in btrfs_alloc_from_cluster()
2776 if (entry->bytes < bytes || in btrfs_alloc_from_cluster()
2777 (!entry->bitmap && entry->offset < min_start)) { in btrfs_alloc_from_cluster()
2778 node = rb_next(&entry->offset_index); in btrfs_alloc_from_cluster()
2781 entry = rb_entry(node, struct btrfs_free_space, in btrfs_alloc_from_cluster()
2786 if (entry->bitmap) { in btrfs_alloc_from_cluster()
2788 cluster, entry, bytes, in btrfs_alloc_from_cluster()
2792 node = rb_next(&entry->offset_index); in btrfs_alloc_from_cluster()
2795 entry = rb_entry(node, struct btrfs_free_space, in btrfs_alloc_from_cluster()
2801 ret = entry->offset; in btrfs_alloc_from_cluster()
2803 entry->offset += bytes; in btrfs_alloc_from_cluster()
2804 entry->bytes -= bytes; in btrfs_alloc_from_cluster()
2807 if (entry->bytes == 0) in btrfs_alloc_from_cluster()
2808 rb_erase(&entry->offset_index, &cluster->root); in btrfs_alloc_from_cluster()
2820 if (entry->bytes == 0) { in btrfs_alloc_from_cluster()
2822 if (entry->bitmap) { in btrfs_alloc_from_cluster()
2824 entry->bitmap); in btrfs_alloc_from_cluster()
2828 kmem_cache_free(btrfs_free_space_cachep, entry); in btrfs_alloc_from_cluster()
2837 struct btrfs_free_space *entry, in btrfs_bitmap_cluster() argument
2853 i = offset_to_bit(entry->offset, ctl->unit, in btrfs_bitmap_cluster()
2854 max_t(u64, offset, entry->offset)); in btrfs_bitmap_cluster()
2862 if (entry->max_extent_size && in btrfs_bitmap_cluster()
2863 entry->max_extent_size < cont1_bytes) in btrfs_bitmap_cluster()
2867 for_each_set_bit_from(i, entry->bitmap, BITS_PER_BITMAP) { in btrfs_bitmap_cluster()
2868 next_zero = find_next_zero_bit(entry->bitmap, in btrfs_bitmap_cluster()
2882 entry->max_extent_size = (u64)max_bits * ctl->unit; in btrfs_bitmap_cluster()
2901 cluster->window_start = start * ctl->unit + entry->offset; in btrfs_bitmap_cluster()
2902 rb_erase(&entry->offset_index, &ctl->free_space_offset); in btrfs_bitmap_cluster()
2903 ret = tree_insert_offset(&cluster->root, entry->offset, in btrfs_bitmap_cluster()
2904 &entry->offset_index, 1); in btrfs_bitmap_cluster()
2925 struct btrfs_free_space *entry = NULL; in setup_cluster_no_bitmap() local
2932 entry = tree_search_offset(ctl, offset, 0, 1); in setup_cluster_no_bitmap()
2933 if (!entry) in setup_cluster_no_bitmap()
2940 while (entry->bitmap || entry->bytes < min_bytes) { in setup_cluster_no_bitmap()
2941 if (entry->bitmap && list_empty(&entry->list)) in setup_cluster_no_bitmap()
2942 list_add_tail(&entry->list, bitmaps); in setup_cluster_no_bitmap()
2943 node = rb_next(&entry->offset_index); in setup_cluster_no_bitmap()
2946 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
2949 window_free = entry->bytes; in setup_cluster_no_bitmap()
2950 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2951 first = entry; in setup_cluster_no_bitmap()
2952 last = entry; in setup_cluster_no_bitmap()
2954 for (node = rb_next(&entry->offset_index); node; in setup_cluster_no_bitmap()
2955 node = rb_next(&entry->offset_index)) { in setup_cluster_no_bitmap()
2956 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
2958 if (entry->bitmap) { in setup_cluster_no_bitmap()
2959 if (list_empty(&entry->list)) in setup_cluster_no_bitmap()
2960 list_add_tail(&entry->list, bitmaps); in setup_cluster_no_bitmap()
2964 if (entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2967 last = entry; in setup_cluster_no_bitmap()
2968 window_free += entry->bytes; in setup_cluster_no_bitmap()
2969 if (entry->bytes > max_extent) in setup_cluster_no_bitmap()
2970 max_extent = entry->bytes; in setup_cluster_no_bitmap()
2987 entry = rb_entry(node, struct btrfs_free_space, offset_index); in setup_cluster_no_bitmap()
2988 node = rb_next(&entry->offset_index); in setup_cluster_no_bitmap()
2989 if (entry->bitmap || entry->bytes < min_bytes) in setup_cluster_no_bitmap()
2992 rb_erase(&entry->offset_index, &ctl->free_space_offset); in setup_cluster_no_bitmap()
2993 ret = tree_insert_offset(&cluster->root, entry->offset, in setup_cluster_no_bitmap()
2994 &entry->offset_index, 0); in setup_cluster_no_bitmap()
2995 total_size += entry->bytes; in setup_cluster_no_bitmap()
2997 } while (node && entry != last); in setup_cluster_no_bitmap()
3015 struct btrfs_free_space *entry = NULL; in setup_cluster_bitmap() local
3027 entry = list_first_entry(bitmaps, struct btrfs_free_space, list); in setup_cluster_bitmap()
3029 if (!entry || entry->offset != bitmap_offset) { in setup_cluster_bitmap()
3030 entry = tree_search_offset(ctl, bitmap_offset, 1, 0); in setup_cluster_bitmap()
3031 if (entry && list_empty(&entry->list)) in setup_cluster_bitmap()
3032 list_add(&entry->list, bitmaps); in setup_cluster_bitmap()
3035 list_for_each_entry(entry, bitmaps, list) { in setup_cluster_bitmap()
3036 if (entry->bytes < bytes) in setup_cluster_bitmap()
3038 ret = btrfs_bitmap_cluster(block_group, entry, cluster, offset, in setup_cluster_bitmap()
3065 struct btrfs_free_space *entry, *tmp; in btrfs_find_space_cluster() local
3118 list_for_each_entry_safe(entry, tmp, &bitmaps, list) in btrfs_find_space_cluster()
3119 list_del_init(&entry->list); in btrfs_find_space_cluster()
3199 struct btrfs_free_space *entry; in trim_no_bitmap() local
3218 entry = tree_search_offset(ctl, start, 0, 1); in trim_no_bitmap()
3219 if (!entry) { in trim_no_bitmap()
3226 while (entry->bitmap) { in trim_no_bitmap()
3227 node = rb_next(&entry->offset_index); in trim_no_bitmap()
3233 entry = rb_entry(node, struct btrfs_free_space, in trim_no_bitmap()
3237 if (entry->offset >= end) { in trim_no_bitmap()
3243 extent_start = entry->offset; in trim_no_bitmap()
3244 extent_bytes = entry->bytes; in trim_no_bitmap()
3253 unlink_free_space(ctl, entry); in trim_no_bitmap()
3254 kmem_cache_free(btrfs_free_space_cachep, entry); in trim_no_bitmap()
3284 struct btrfs_free_space *entry; in trim_bitmaps() local
3303 entry = tree_search_offset(ctl, offset, 1, 0); in trim_bitmaps()
3304 if (!entry) { in trim_bitmaps()
3312 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3327 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3328 if (entry->bytes == 0) in trim_bitmaps()
3329 free_bitmap(ctl, entry); in trim_bitmaps()
3436 struct btrfs_free_space *entry = NULL; in btrfs_find_ino_for_alloc() local
3444 entry = rb_entry(rb_first(&ctl->free_space_offset), in btrfs_find_ino_for_alloc()
3447 if (!entry->bitmap) { in btrfs_find_ino_for_alloc()
3448 ino = entry->offset; in btrfs_find_ino_for_alloc()
3450 unlink_free_space(ctl, entry); in btrfs_find_ino_for_alloc()
3451 entry->offset++; in btrfs_find_ino_for_alloc()
3452 entry->bytes--; in btrfs_find_ino_for_alloc()
3453 if (!entry->bytes) in btrfs_find_ino_for_alloc()
3454 kmem_cache_free(btrfs_free_space_cachep, entry); in btrfs_find_ino_for_alloc()
3456 link_free_space(ctl, entry); in btrfs_find_ino_for_alloc()
3462 ret = search_bitmap(ctl, entry, &offset, &count, true); in btrfs_find_ino_for_alloc()
3467 bitmap_clear_bits(ctl, entry, offset, 1); in btrfs_find_ino_for_alloc()
3468 if (entry->bytes == 0) in btrfs_find_ino_for_alloc()
3469 free_bitmap(ctl, entry); in btrfs_find_ino_for_alloc()