Lines Matching refs:block_group
2658 struct btrfs_block_group *block_group; in __exclude_logged_extent() local
2660 block_group = btrfs_lookup_block_group(fs_info, start); in __exclude_logged_extent()
2661 if (!block_group) in __exclude_logged_extent()
2664 ret = btrfs_cache_block_group(block_group, true); in __exclude_logged_extent()
2668 ret = btrfs_remove_free_space(block_group, start, num_bytes); in __exclude_logged_extent()
2670 btrfs_put_block_group(block_group); in __exclude_logged_extent()
2826 struct btrfs_block_group *block_group, *tmp; in btrfs_finish_extent_commit() local
2897 list_for_each_entry_safe(block_group, tmp, deleted_bgs, bg_list) { in btrfs_finish_extent_commit()
2900 ret = btrfs_discard_extent(fs_info, block_group->start, in btrfs_finish_extent_commit()
2901 block_group->length, NULL); in btrfs_finish_extent_commit()
2907 ASSERT(block_group->ro); in btrfs_finish_extent_commit()
2909 list_del_init(&block_group->bg_list); in btrfs_finish_extent_commit()
2912 btrfs_unfreeze_block_group(block_group); in btrfs_finish_extent_commit()
2913 btrfs_put_block_group(block_group); in btrfs_finish_extent_commit()
3607 struct btrfs_block_group *block_group, in btrfs_lock_cluster() argument
3616 used_bg = cluster->block_group; in btrfs_lock_cluster()
3620 if (used_bg == block_group) in btrfs_lock_cluster()
3637 if (used_bg == cluster->block_group) in btrfs_lock_cluster()
3705 WARN_ON(last_ptr->block_group != cluster_bg); in find_free_extent_clustered()
3811 static int do_allocation_clustered(struct btrfs_block_group *block_group, in do_allocation_clustered() argument
3819 ret = find_free_extent_clustered(block_group, ffe_ctl, bg_ret); in do_allocation_clustered()
3825 return find_free_extent_unclustered(block_group, ffe_ctl); in do_allocation_clustered()
3849 static int do_allocation_zoned(struct btrfs_block_group *block_group, in do_allocation_zoned() argument
3853 struct btrfs_fs_info *fs_info = block_group->fs_info; in do_allocation_zoned()
3854 struct btrfs_space_info *space_info = block_group->space_info; in do_allocation_zoned()
3855 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in do_allocation_zoned()
3856 u64 start = block_group->start; in do_allocation_zoned()
3859 u64 bytenr = block_group->start; in do_allocation_zoned()
3865 ASSERT(btrfs_is_zoned(block_group->fs_info)); in do_allocation_zoned()
3895 spin_lock(&block_group->lock); in do_allocation_zoned()
3896 if (block_group->ro || btrfs_zoned_bg_is_full(block_group)) { in do_allocation_zoned()
3903 spin_unlock(&block_group->lock); in do_allocation_zoned()
3906 if (!ret && (block_group->flags & BTRFS_BLOCK_GROUP_DATA) && in do_allocation_zoned()
3907 !btrfs_zone_activate(block_group)) { in do_allocation_zoned()
3916 spin_lock(&block_group->lock); in do_allocation_zoned()
3924 block_group->start == fs_info->treelog_bg || in do_allocation_zoned()
3927 block_group->start == fs_info->data_reloc_bg || in do_allocation_zoned()
3930 if (block_group->ro || in do_allocation_zoned()
3932 test_bit(BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, &block_group->runtime_flags))) { in do_allocation_zoned()
3942 (block_group->used || block_group->reserved)) { in do_allocation_zoned()
3952 (block_group->used || block_group->reserved)) { in do_allocation_zoned()
3957 WARN_ON_ONCE(block_group->alloc_offset > block_group->zone_capacity); in do_allocation_zoned()
3958 avail = block_group->zone_capacity - block_group->alloc_offset; in do_allocation_zoned()
3973 fs_info->treelog_bg = block_group->start; in do_allocation_zoned()
3977 fs_info->data_reloc_bg = block_group->start; in do_allocation_zoned()
3993 set_bit(BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, &block_group->runtime_flags); in do_allocation_zoned()
3996 ffe_ctl->found_offset = start + block_group->alloc_offset; in do_allocation_zoned()
3997 block_group->alloc_offset += num_bytes; in do_allocation_zoned()
4016 spin_unlock(&block_group->lock); in do_allocation_zoned()
4021 static int do_allocation(struct btrfs_block_group *block_group, in do_allocation() argument
4027 return do_allocation_clustered(block_group, ffe_ctl, bg_ret); in do_allocation()
4029 return do_allocation_zoned(block_group, ffe_ctl, bg_ret); in do_allocation()
4035 static void release_block_group(struct btrfs_block_group *block_group, in release_block_group() argument
4050 BUG_ON(btrfs_bg_flags_to_raid_index(block_group->flags) != in release_block_group()
4052 btrfs_release_block_group(block_group, delalloc); in release_block_group()
4282 if (last_ptr->block_group) in prepare_allocation_clustered()
4313 struct btrfs_block_group *block_group; in prepare_allocation_zoned() local
4316 list_for_each_entry(block_group, &fs_info->zone_active_bgs, active_bg_list) { in prepare_allocation_zoned()
4321 u64 avail = block_group->zone_capacity - block_group->alloc_offset; in prepare_allocation_zoned()
4323 if (block_group_bits(block_group, ffe_ctl->flags) && in prepare_allocation_zoned()
4325 ffe_ctl->hint_byte = block_group->start; in prepare_allocation_zoned()
4383 struct btrfs_block_group *block_group = NULL; in find_free_extent() local
4440 block_group = btrfs_lookup_block_group(fs_info, in find_free_extent()
4449 if (block_group && block_group_bits(block_group, ffe_ctl->flags) && in find_free_extent()
4450 block_group->space_info == space_info && in find_free_extent()
4451 block_group->cached != BTRFS_CACHE_NO) { in find_free_extent()
4453 if (list_empty(&block_group->list) || in find_free_extent()
4454 block_group->ro) { in find_free_extent()
4461 btrfs_put_block_group(block_group); in find_free_extent()
4465 block_group->flags); in find_free_extent()
4466 btrfs_lock_block_group(block_group, in find_free_extent()
4471 } else if (block_group) { in find_free_extent()
4472 btrfs_put_block_group(block_group); in find_free_extent()
4482 list_for_each_entry(block_group, in find_free_extent()
4488 if (unlikely(block_group->ro)) { in find_free_extent()
4490 btrfs_clear_treelog_bg(block_group); in find_free_extent()
4492 btrfs_clear_data_reloc_bg(block_group); in find_free_extent()
4496 btrfs_grab_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4497 ffe_ctl->search_start = block_group->start; in find_free_extent()
4504 if (!block_group_bits(block_group, ffe_ctl->flags)) { in find_free_extent()
4515 if ((ffe_ctl->flags & extra) && !(block_group->flags & extra)) in find_free_extent()
4523 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4528 trace_btrfs_find_free_extent_have_block_group(root, ffe_ctl, block_group); in find_free_extent()
4529 ffe_ctl->cached = btrfs_block_group_done(block_group); in find_free_extent()
4532 ret = btrfs_cache_block_group(block_group, false); in find_free_extent()
4550 if (unlikely(block_group->cached == BTRFS_CACHE_ERROR)) { in find_free_extent()
4556 if (!find_free_extent_check_size_class(ffe_ctl, block_group)) in find_free_extent()
4560 ret = do_allocation(block_group, ffe_ctl, &bg_ret); in find_free_extent()
4564 if (bg_ret && bg_ret != block_group) { in find_free_extent()
4565 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4566 block_group = bg_ret; in find_free_extent()
4575 block_group->start + block_group->length) { in find_free_extent()
4576 btrfs_add_free_space_unused(block_group, in find_free_extent()
4583 btrfs_add_free_space_unused(block_group, in find_free_extent()
4587 ret = btrfs_add_reserved_bytes(block_group, ffe_ctl->ram_bytes, in find_free_extent()
4592 btrfs_add_free_space_unused(block_group, in find_free_extent()
4597 btrfs_inc_block_group_reservations(block_group); in find_free_extent()
4603 trace_btrfs_reserve_extent(block_group, ffe_ctl); in find_free_extent()
4604 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4610 btrfs_wait_block_group_cache_progress(block_group, in find_free_extent()
4616 release_block_group(block_group, ffe_ctl, ffe_ctl->delalloc); in find_free_extent()
4987 struct btrfs_block_group *block_group; in btrfs_alloc_logged_file_extent() local
5008 block_group = btrfs_lookup_block_group(fs_info, ins->objectid); in btrfs_alloc_logged_file_extent()
5009 if (!block_group) in btrfs_alloc_logged_file_extent()
5012 space_info = block_group->space_info; in btrfs_alloc_logged_file_extent()
5014 spin_lock(&block_group->lock); in btrfs_alloc_logged_file_extent()
5016 block_group->reserved += ins->offset; in btrfs_alloc_logged_file_extent()
5017 spin_unlock(&block_group->lock); in btrfs_alloc_logged_file_extent()
5025 btrfs_put_block_group(block_group); in btrfs_alloc_logged_file_extent()