• Home
  • Raw
  • Download

Lines Matching refs:ctl

41 static int link_free_space(struct btrfs_free_space_ctl *ctl,
43 static void unlink_free_space(struct btrfs_free_space_ctl *ctl,
645 static void merge_space_tree(struct btrfs_free_space_ctl *ctl) in merge_space_tree() argument
651 spin_lock(&ctl->tree_lock); in merge_space_tree()
652 for (n = rb_first(&ctl->free_space_offset); n; n = rb_next(n)) { in merge_space_tree()
659 unlink_free_space(ctl, prev); in merge_space_tree()
660 unlink_free_space(ctl, e); in merge_space_tree()
663 link_free_space(ctl, prev); in merge_space_tree()
665 spin_unlock(&ctl->tree_lock); in merge_space_tree()
671 spin_unlock(&ctl->tree_lock); in merge_space_tree()
675 struct btrfs_free_space_ctl *ctl, in __load_free_space_cache() argument
775 spin_lock(&ctl->tree_lock); in __load_free_space_cache()
776 ret = link_free_space(ctl, e); in __load_free_space_cache()
777 spin_unlock(&ctl->tree_lock); in __load_free_space_cache()
794 spin_lock(&ctl->tree_lock); in __load_free_space_cache()
795 ret = link_free_space(ctl, e); in __load_free_space_cache()
796 ctl->total_bitmaps++; in __load_free_space_cache()
797 ctl->op->recalc_thresholds(ctl); in __load_free_space_cache()
798 spin_unlock(&ctl->tree_lock); in __load_free_space_cache()
825 merge_space_tree(ctl); in __load_free_space_cache()
832 __btrfs_remove_free_space_cache(ctl); in __load_free_space_cache()
839 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in load_free_space_cache() local
879 ret = __load_free_space_cache(fs_info->tree_root, inode, ctl, in load_free_space_cache()
885 spin_lock(&ctl->tree_lock); in load_free_space_cache()
886 matched = (ctl->free_space == (block_group->key.offset - used - in load_free_space_cache()
888 spin_unlock(&ctl->tree_lock); in load_free_space_cache()
891 __btrfs_remove_free_space_cache(ctl); in load_free_space_cache()
914 struct btrfs_free_space_ctl *ctl, in write_cache_extent_entries() argument
922 struct rb_node *node = rb_first(&ctl->free_space_offset); in write_cache_extent_entries()
974 list_for_each_entry(trim_entry, &ctl->trimming_ranges, list) { in write_cache_extent_entries()
1232 struct btrfs_free_space_ctl *ctl, in __btrfs_write_out_cache() argument
1278 mutex_lock(&ctl->cache_writeout_mutex); in __btrfs_write_out_cache()
1280 spin_lock(&ctl->tree_lock); in __btrfs_write_out_cache()
1281 ret = write_cache_extent_entries(io_ctl, ctl, in __btrfs_write_out_cache()
1305 spin_unlock(&ctl->tree_lock); in __btrfs_write_out_cache()
1306 mutex_unlock(&ctl->cache_writeout_mutex); in __btrfs_write_out_cache()
1358 spin_unlock(&ctl->tree_lock); in __btrfs_write_out_cache()
1359 mutex_unlock(&ctl->cache_writeout_mutex); in __btrfs_write_out_cache()
1376 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_write_out_cache() local
1393 ret = __btrfs_write_out_cache(root, inode, ctl, block_group, in btrfs_write_out_cache()
1431 static inline u64 offset_to_bitmap(struct btrfs_free_space_ctl *ctl, in offset_to_bitmap() argument
1437 bytes_per_bitmap = BITS_PER_BITMAP * ctl->unit; in offset_to_bitmap()
1438 bitmap_start = offset - ctl->start; in offset_to_bitmap()
1441 bitmap_start += ctl->start; in offset_to_bitmap()
1505 tree_search_offset(struct btrfs_free_space_ctl *ctl, in tree_search_offset() argument
1508 struct rb_node *n = ctl->free_space_offset.rb_node; in tree_search_offset()
1594 if (entry->offset + BITS_PER_BITMAP * ctl->unit > offset) in tree_search_offset()
1605 ctl->unit > offset) in tree_search_offset()
1621 __unlink_free_space(struct btrfs_free_space_ctl *ctl, in __unlink_free_space() argument
1624 rb_erase(&info->offset_index, &ctl->free_space_offset); in __unlink_free_space()
1625 ctl->free_extents--; in __unlink_free_space()
1628 static void unlink_free_space(struct btrfs_free_space_ctl *ctl, in unlink_free_space() argument
1631 __unlink_free_space(ctl, info); in unlink_free_space()
1632 ctl->free_space -= info->bytes; in unlink_free_space()
1635 static int link_free_space(struct btrfs_free_space_ctl *ctl, in link_free_space() argument
1641 ret = tree_insert_offset(&ctl->free_space_offset, info->offset, in link_free_space()
1646 ctl->free_space += info->bytes; in link_free_space()
1647 ctl->free_extents++; in link_free_space()
1651 static void recalculate_thresholds(struct btrfs_free_space_ctl *ctl) in recalculate_thresholds() argument
1653 struct btrfs_block_group_cache *block_group = ctl->private; in recalculate_thresholds()
1658 u32 bytes_per_bg = BITS_PER_BITMAP * ctl->unit; in recalculate_thresholds()
1663 ASSERT(ctl->total_bitmaps <= max_bitmaps); in recalculate_thresholds()
1681 bitmap_bytes = (ctl->total_bitmaps + 1) * PAGE_CACHE_SIZE; in recalculate_thresholds()
1684 ctl->extents_thresh = 0; in recalculate_thresholds()
1695 ctl->extents_thresh = in recalculate_thresholds()
1699 static inline void __bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, in __bitmap_clear_bits() argument
1705 start = offset_to_bit(info->offset, ctl->unit, offset); in __bitmap_clear_bits()
1706 count = bytes_to_bits(bytes, ctl->unit); in __bitmap_clear_bits()
1712 if (info->max_extent_size > ctl->unit) in __bitmap_clear_bits()
1716 static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl, in bitmap_clear_bits() argument
1720 __bitmap_clear_bits(ctl, info, offset, bytes); in bitmap_clear_bits()
1721 ctl->free_space -= bytes; in bitmap_clear_bits()
1724 static void bitmap_set_bits(struct btrfs_free_space_ctl *ctl, in bitmap_set_bits() argument
1730 start = offset_to_bit(info->offset, ctl->unit, offset); in bitmap_set_bits()
1731 count = bytes_to_bits(bytes, ctl->unit); in bitmap_set_bits()
1737 ctl->free_space += bytes; in bitmap_set_bits()
1744 static int search_bitmap(struct btrfs_free_space_ctl *ctl, in search_bitmap() argument
1765 i = offset_to_bit(bitmap_info->offset, ctl->unit, in search_bitmap()
1767 bits = bytes_to_bits(*bytes, ctl->unit); in search_bitmap()
1787 *offset = (u64)(i * ctl->unit) + bitmap_info->offset; in search_bitmap()
1788 *bytes = (u64)(found_bits) * ctl->unit; in search_bitmap()
1792 *bytes = (u64)(max_bits) * ctl->unit; in search_bitmap()
1806 find_free_space(struct btrfs_free_space_ctl *ctl, u64 *offset, u64 *bytes, in find_free_space() argument
1815 if (!ctl->free_space_offset.rb_node) in find_free_space()
1818 entry = tree_search_offset(ctl, offset_to_bitmap(ctl, *offset), 0, 1); in find_free_space()
1834 tmp = entry->offset - ctl->start + align - 1; in find_free_space()
1836 tmp = tmp * align + ctl->start; in find_free_space()
1852 ret = search_bitmap(ctl, entry, &tmp, &size, true); in find_free_space()
1873 static void add_new_bitmap(struct btrfs_free_space_ctl *ctl, in add_new_bitmap() argument
1876 info->offset = offset_to_bitmap(ctl, offset); in add_new_bitmap()
1879 link_free_space(ctl, info); in add_new_bitmap()
1880 ctl->total_bitmaps++; in add_new_bitmap()
1882 ctl->op->recalc_thresholds(ctl); in add_new_bitmap()
1885 static void free_bitmap(struct btrfs_free_space_ctl *ctl, in free_bitmap() argument
1888 unlink_free_space(ctl, bitmap_info); in free_bitmap()
1891 ctl->total_bitmaps--; in free_bitmap()
1892 ctl->op->recalc_thresholds(ctl); in free_bitmap()
1895 static noinline int remove_from_bitmap(struct btrfs_free_space_ctl *ctl, in remove_from_bitmap() argument
1904 end = bitmap_info->offset + (u64)(BITS_PER_BITMAP * ctl->unit) - 1; in remove_from_bitmap()
1913 search_bytes = ctl->unit; in remove_from_bitmap()
1915 ret = search_bitmap(ctl, bitmap_info, &search_start, &search_bytes, in remove_from_bitmap()
1926 bitmap_clear_bits(ctl, bitmap_info, search_start, search_bytes); in remove_from_bitmap()
1933 free_bitmap(ctl, bitmap_info); in remove_from_bitmap()
1959 search_bytes = ctl->unit; in remove_from_bitmap()
1960 ret = search_bitmap(ctl, bitmap_info, &search_start, in remove_from_bitmap()
1967 free_bitmap(ctl, bitmap_info); in remove_from_bitmap()
1972 static u64 add_bytes_to_bitmap(struct btrfs_free_space_ctl *ctl, in add_bytes_to_bitmap() argument
1979 end = info->offset + (u64)(BITS_PER_BITMAP * ctl->unit); in add_bytes_to_bitmap()
1983 bitmap_set_bits(ctl, info, offset, bytes_to_set); in add_bytes_to_bitmap()
1995 static bool use_bitmap(struct btrfs_free_space_ctl *ctl, in use_bitmap() argument
1998 struct btrfs_block_group_cache *block_group = ctl->private; in use_bitmap()
2011 if (!forced && ctl->free_extents < ctl->extents_thresh) { in use_bitmap()
2020 if (ctl->free_extents * 2 <= ctl->extents_thresh) in use_bitmap()
2035 if (((BITS_PER_BITMAP * ctl->unit) >> 1) > block_group->key.offset) in use_bitmap()
2046 static int insert_into_bitmap(struct btrfs_free_space_ctl *ctl, in insert_into_bitmap() argument
2058 if (!ctl->op->use_bitmap(ctl, info)) in insert_into_bitmap()
2061 if (ctl->op == &free_space_op) in insert_into_bitmap()
2062 block_group = ctl->private; in insert_into_bitmap()
2090 if (entry->offset == offset_to_bitmap(ctl, offset)) { in insert_into_bitmap()
2091 bytes_added = add_bytes_to_bitmap(ctl, entry, in insert_into_bitmap()
2104 bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), in insert_into_bitmap()
2111 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in insert_into_bitmap()
2124 add_new_bitmap(ctl, info, offset); in insert_into_bitmap()
2129 spin_unlock(&ctl->tree_lock); in insert_into_bitmap()
2136 spin_lock(&ctl->tree_lock); in insert_into_bitmap()
2144 spin_lock(&ctl->tree_lock); in insert_into_bitmap()
2162 static bool try_merge_free_space(struct btrfs_free_space_ctl *ctl, in try_merge_free_space() argument
2176 right_info = tree_search_offset(ctl, offset + bytes, 0, 0); in try_merge_free_space()
2181 left_info = tree_search_offset(ctl, offset - 1, 0, 0); in try_merge_free_space()
2185 unlink_free_space(ctl, right_info); in try_merge_free_space()
2187 __unlink_free_space(ctl, right_info); in try_merge_free_space()
2196 unlink_free_space(ctl, left_info); in try_merge_free_space()
2198 __unlink_free_space(ctl, left_info); in try_merge_free_space()
2208 static bool steal_from_bitmap_to_end(struct btrfs_free_space_ctl *ctl, in steal_from_bitmap_to_end() argument
2216 const u64 bitmap_offset = offset_to_bitmap(ctl, end); in steal_from_bitmap_to_end()
2219 bitmap = tree_search_offset(ctl, bitmap_offset, 1, 0); in steal_from_bitmap_to_end()
2223 i = offset_to_bit(bitmap->offset, ctl->unit, end); in steal_from_bitmap_to_end()
2227 bytes = (j - i) * ctl->unit; in steal_from_bitmap_to_end()
2231 bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2233 __bitmap_clear_bits(ctl, bitmap, end, bytes); in steal_from_bitmap_to_end()
2236 free_bitmap(ctl, bitmap); in steal_from_bitmap_to_end()
2241 static bool steal_from_bitmap_to_front(struct btrfs_free_space_ctl *ctl, in steal_from_bitmap_to_front() argument
2252 bitmap_offset = offset_to_bitmap(ctl, info->offset); in steal_from_bitmap_to_front()
2257 bitmap_offset = offset_to_bitmap(ctl, info->offset - 1); in steal_from_bitmap_to_front()
2260 bitmap = tree_search_offset(ctl, bitmap_offset, 1, 0); in steal_from_bitmap_to_front()
2264 i = offset_to_bit(bitmap->offset, ctl->unit, info->offset) - 1; in steal_from_bitmap_to_front()
2276 bytes = (i + 1) * ctl->unit; in steal_from_bitmap_to_front()
2278 bytes = (i - prev_j) * ctl->unit; in steal_from_bitmap_to_front()
2284 bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2286 __bitmap_clear_bits(ctl, bitmap, info->offset, bytes); in steal_from_bitmap_to_front()
2289 free_bitmap(ctl, bitmap); in steal_from_bitmap_to_front()
2305 static void steal_from_bitmap(struct btrfs_free_space_ctl *ctl, in steal_from_bitmap() argument
2316 if (ctl->total_bitmaps > 0) { in steal_from_bitmap()
2320 stole_end = steal_from_bitmap_to_end(ctl, info, update_stat); in steal_from_bitmap()
2321 if (ctl->total_bitmaps > 0) in steal_from_bitmap()
2322 stole_front = steal_from_bitmap_to_front(ctl, info, in steal_from_bitmap()
2326 try_merge_free_space(ctl, info, update_stat); in steal_from_bitmap()
2330 int __btrfs_add_free_space(struct btrfs_free_space_ctl *ctl, in __btrfs_add_free_space() argument
2344 spin_lock(&ctl->tree_lock); in __btrfs_add_free_space()
2346 if (try_merge_free_space(ctl, info, true)) in __btrfs_add_free_space()
2354 ret = insert_into_bitmap(ctl, info); in __btrfs_add_free_space()
2368 steal_from_bitmap(ctl, info, true); in __btrfs_add_free_space()
2370 ret = link_free_space(ctl, info); in __btrfs_add_free_space()
2374 spin_unlock(&ctl->tree_lock); in __btrfs_add_free_space()
2387 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_remove_free_space() local
2392 spin_lock(&ctl->tree_lock); in btrfs_remove_free_space()
2399 info = tree_search_offset(ctl, offset, 0, 0); in btrfs_remove_free_space()
2405 info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), in btrfs_remove_free_space()
2420 unlink_free_space(ctl, info); in btrfs_remove_free_space()
2427 ret = link_free_space(ctl, info); in btrfs_remove_free_space()
2440 ret = link_free_space(ctl, info); in btrfs_remove_free_space()
2454 spin_unlock(&ctl->tree_lock); in btrfs_remove_free_space()
2463 ret = remove_from_bitmap(ctl, info, &offset, &bytes); in btrfs_remove_free_space()
2469 spin_unlock(&ctl->tree_lock); in btrfs_remove_free_space()
2477 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_dump_free_space() local
2482 spin_lock(&ctl->tree_lock); in btrfs_dump_free_space()
2483 for (n = rb_first(&ctl->free_space_offset); n; n = rb_next(n)) { in btrfs_dump_free_space()
2492 spin_unlock(&ctl->tree_lock); in btrfs_dump_free_space()
2501 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_init_free_space_ctl() local
2503 spin_lock_init(&ctl->tree_lock); in btrfs_init_free_space_ctl()
2504 ctl->unit = block_group->sectorsize; in btrfs_init_free_space_ctl()
2505 ctl->start = block_group->key.objectid; in btrfs_init_free_space_ctl()
2506 ctl->private = block_group; in btrfs_init_free_space_ctl()
2507 ctl->op = &free_space_op; in btrfs_init_free_space_ctl()
2508 INIT_LIST_HEAD(&ctl->trimming_ranges); in btrfs_init_free_space_ctl()
2509 mutex_init(&ctl->cache_writeout_mutex); in btrfs_init_free_space_ctl()
2516 ctl->extents_thresh = ((1024 * 32) / 2) / in btrfs_init_free_space_ctl()
2531 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in __btrfs_return_cluster_to_free_space() local
2554 try_merge_free_space(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2555 steal_from_bitmap(ctl, entry, false); in __btrfs_return_cluster_to_free_space()
2557 tree_insert_offset(&ctl->free_space_offset, in __btrfs_return_cluster_to_free_space()
2569 struct btrfs_free_space_ctl *ctl) in __btrfs_remove_free_space_cache_locked() argument
2574 while ((node = rb_last(&ctl->free_space_offset)) != NULL) { in __btrfs_remove_free_space_cache_locked()
2577 unlink_free_space(ctl, info); in __btrfs_remove_free_space_cache_locked()
2580 free_bitmap(ctl, info); in __btrfs_remove_free_space_cache_locked()
2583 cond_resched_lock(&ctl->tree_lock); in __btrfs_remove_free_space_cache_locked()
2587 void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl) in __btrfs_remove_free_space_cache() argument
2589 spin_lock(&ctl->tree_lock); in __btrfs_remove_free_space_cache()
2590 __btrfs_remove_free_space_cache_locked(ctl); in __btrfs_remove_free_space_cache()
2591 spin_unlock(&ctl->tree_lock); in __btrfs_remove_free_space_cache()
2596 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_remove_free_space_cache() local
2600 spin_lock(&ctl->tree_lock); in btrfs_remove_free_space_cache()
2609 cond_resched_lock(&ctl->tree_lock); in btrfs_remove_free_space_cache()
2611 __btrfs_remove_free_space_cache_locked(ctl); in btrfs_remove_free_space_cache()
2612 spin_unlock(&ctl->tree_lock); in btrfs_remove_free_space_cache()
2620 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_find_space_for_alloc() local
2627 spin_lock(&ctl->tree_lock); in btrfs_find_space_for_alloc()
2628 entry = find_free_space(ctl, &offset, &bytes_search, in btrfs_find_space_for_alloc()
2635 bitmap_clear_bits(ctl, entry, offset, bytes); in btrfs_find_space_for_alloc()
2637 free_bitmap(ctl, entry); in btrfs_find_space_for_alloc()
2639 unlink_free_space(ctl, entry); in btrfs_find_space_for_alloc()
2650 link_free_space(ctl, entry); in btrfs_find_space_for_alloc()
2653 spin_unlock(&ctl->tree_lock); in btrfs_find_space_for_alloc()
2656 __btrfs_add_free_space(ctl, align_gap, align_gap_len); in btrfs_find_space_for_alloc()
2672 struct btrfs_free_space_ctl *ctl; in btrfs_return_cluster_to_free_space() local
2691 ctl = block_group->free_space_ctl; in btrfs_return_cluster_to_free_space()
2694 spin_lock(&ctl->tree_lock); in btrfs_return_cluster_to_free_space()
2696 spin_unlock(&ctl->tree_lock); in btrfs_return_cluster_to_free_space()
2709 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_alloc_from_bitmap() local
2718 err = search_bitmap(ctl, entry, &search_start, &search_bytes, true); in btrfs_alloc_from_bitmap()
2726 __bitmap_clear_bits(ctl, entry, ret, bytes); in btrfs_alloc_from_bitmap()
2740 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_alloc_from_cluster() local
2803 spin_lock(&ctl->tree_lock); in btrfs_alloc_from_cluster()
2805 ctl->free_space -= bytes; in btrfs_alloc_from_cluster()
2807 ctl->free_extents--; in btrfs_alloc_from_cluster()
2810 ctl->total_bitmaps--; in btrfs_alloc_from_cluster()
2811 ctl->op->recalc_thresholds(ctl); in btrfs_alloc_from_cluster()
2816 spin_unlock(&ctl->tree_lock); in btrfs_alloc_from_cluster()
2827 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_bitmap_cluster() local
2838 i = offset_to_bit(entry->offset, ctl->unit, in btrfs_bitmap_cluster()
2840 want_bits = bytes_to_bits(bytes, ctl->unit); in btrfs_bitmap_cluster()
2841 min_bits = bytes_to_bits(min_bytes, ctl->unit); in btrfs_bitmap_cluster()
2867 entry->max_extent_size = (u64)max_bits * ctl->unit; in btrfs_bitmap_cluster()
2878 if (cluster->max_size < found_bits * ctl->unit) in btrfs_bitmap_cluster()
2879 cluster->max_size = found_bits * ctl->unit; in btrfs_bitmap_cluster()
2886 cluster->window_start = start * ctl->unit + entry->offset; in btrfs_bitmap_cluster()
2887 rb_erase(&entry->offset_index, &ctl->free_space_offset); in btrfs_bitmap_cluster()
2893 total_found * ctl->unit, 1); in btrfs_bitmap_cluster()
2908 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in setup_cluster_no_bitmap() local
2917 entry = tree_search_offset(ctl, offset, 0, 1); in setup_cluster_no_bitmap()
2977 rb_erase(&entry->offset_index, &ctl->free_space_offset); in setup_cluster_no_bitmap()
2999 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in setup_cluster_bitmap() local
3002 u64 bitmap_offset = offset_to_bitmap(ctl, offset); in setup_cluster_bitmap()
3004 if (ctl->total_bitmaps == 0) in setup_cluster_bitmap()
3015 entry = tree_search_offset(ctl, bitmap_offset, 1, 0); in setup_cluster_bitmap()
3049 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in btrfs_find_space_cluster() local
3072 spin_lock(&ctl->tree_lock); in btrfs_find_space_cluster()
3078 if (ctl->free_space < bytes) { in btrfs_find_space_cluster()
3079 spin_unlock(&ctl->tree_lock); in btrfs_find_space_cluster()
3116 spin_unlock(&ctl->tree_lock); in btrfs_find_space_cluster()
3142 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in do_trimming() local
3162 mutex_lock(&ctl->cache_writeout_mutex); in do_trimming()
3165 mutex_unlock(&ctl->cache_writeout_mutex); in do_trimming()
3184 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in trim_no_bitmap() local
3195 mutex_lock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3196 spin_lock(&ctl->tree_lock); in trim_no_bitmap()
3198 if (ctl->free_space < minlen) { in trim_no_bitmap()
3199 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3200 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3204 entry = tree_search_offset(ctl, start, 0, 1); in trim_no_bitmap()
3206 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3207 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3215 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3216 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3224 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3225 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3234 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3235 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3239 unlink_free_space(ctl, entry); in trim_no_bitmap()
3242 spin_unlock(&ctl->tree_lock); in trim_no_bitmap()
3245 list_add_tail(&trim_entry.list, &ctl->trimming_ranges); in trim_no_bitmap()
3246 mutex_unlock(&ctl->cache_writeout_mutex); in trim_no_bitmap()
3269 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in trim_bitmaps() local
3274 u64 offset = offset_to_bitmap(ctl, start); in trim_bitmaps()
3280 mutex_lock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3281 spin_lock(&ctl->tree_lock); in trim_bitmaps()
3283 if (ctl->free_space < minlen) { in trim_bitmaps()
3284 spin_unlock(&ctl->tree_lock); in trim_bitmaps()
3285 mutex_unlock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3289 entry = tree_search_offset(ctl, offset, 1, 0); in trim_bitmaps()
3291 spin_unlock(&ctl->tree_lock); in trim_bitmaps()
3292 mutex_unlock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3298 ret2 = search_bitmap(ctl, entry, &start, &bytes, false); in trim_bitmaps()
3300 spin_unlock(&ctl->tree_lock); in trim_bitmaps()
3301 mutex_unlock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3308 spin_unlock(&ctl->tree_lock); in trim_bitmaps()
3309 mutex_unlock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3313 bitmap_clear_bits(ctl, entry, start, bytes); in trim_bitmaps()
3315 free_bitmap(ctl, entry); in trim_bitmaps()
3317 spin_unlock(&ctl->tree_lock); in trim_bitmaps()
3320 list_add_tail(&trim_entry.list, &ctl->trimming_ranges); in trim_bitmaps()
3321 mutex_unlock(&ctl->cache_writeout_mutex); in trim_bitmaps()
3329 offset += BITS_PER_BITMAP * ctl->unit; in trim_bitmaps()
3332 if (start >= offset + BITS_PER_BITMAP * ctl->unit) in trim_bitmaps()
3333 offset += BITS_PER_BITMAP * ctl->unit; in trim_bitmaps()
3424 struct btrfs_free_space_ctl *ctl = fs_root->free_ino_ctl; in btrfs_find_ino_for_alloc() local
3428 spin_lock(&ctl->tree_lock); in btrfs_find_ino_for_alloc()
3430 if (RB_EMPTY_ROOT(&ctl->free_space_offset)) in btrfs_find_ino_for_alloc()
3433 entry = rb_entry(rb_first(&ctl->free_space_offset), in btrfs_find_ino_for_alloc()
3439 unlink_free_space(ctl, entry); in btrfs_find_ino_for_alloc()
3445 link_free_space(ctl, entry); in btrfs_find_ino_for_alloc()
3451 ret = search_bitmap(ctl, entry, &offset, &count, true); in btrfs_find_ino_for_alloc()
3456 bitmap_clear_bits(ctl, entry, offset, 1); in btrfs_find_ino_for_alloc()
3458 free_bitmap(ctl, entry); in btrfs_find_ino_for_alloc()
3461 spin_unlock(&ctl->tree_lock); in btrfs_find_ino_for_alloc()
3500 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; in load_free_ino_cache() local
3527 ret = __load_free_space_cache(root, inode, ctl, path, 0); in load_free_ino_cache()
3545 struct btrfs_free_space_ctl *ctl = root->free_ino_ctl; in btrfs_write_out_ino_cache() local
3554 ret = __btrfs_write_out_cache(root, inode, ctl, NULL, &io_ctl, in btrfs_write_out_ino_cache()
3590 struct btrfs_free_space_ctl *ctl = cache->free_space_ctl; in test_add_free_space_entry() local
3604 spin_lock(&ctl->tree_lock); in test_add_free_space_entry()
3608 ret = link_free_space(ctl, info); in test_add_free_space_entry()
3609 spin_unlock(&ctl->tree_lock); in test_add_free_space_entry()
3623 spin_lock(&ctl->tree_lock); in test_add_free_space_entry()
3624 bitmap_info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), in test_add_free_space_entry()
3629 add_new_bitmap(ctl, info, offset); in test_add_free_space_entry()
3634 bytes_added = add_bytes_to_bitmap(ctl, bitmap_info, offset, bytes); in test_add_free_space_entry()
3638 spin_unlock(&ctl->tree_lock); in test_add_free_space_entry()
3658 struct btrfs_free_space_ctl *ctl = cache->free_space_ctl; in test_check_exists() local
3662 spin_lock(&ctl->tree_lock); in test_check_exists()
3663 info = tree_search_offset(ctl, offset, 0, 0); in test_check_exists()
3665 info = tree_search_offset(ctl, offset_to_bitmap(ctl, offset), in test_check_exists()
3678 bit_bytes = ctl->unit; in test_check_exists()
3679 ret = search_bitmap(ctl, info, &bit_off, &bit_bytes, false); in test_check_exists()
3731 spin_unlock(&ctl->tree_lock); in test_check_exists()