Lines Matching refs:block_group

2657 	struct btrfs_block_group *block_group;  in __exclude_logged_extent()  local
2659 block_group = btrfs_lookup_block_group(fs_info, start); in __exclude_logged_extent()
2660 if (!block_group) in __exclude_logged_extent()
2663 ret = btrfs_cache_block_group(block_group, true); in __exclude_logged_extent()
2667 ret = btrfs_remove_free_space(block_group, start, num_bytes); in __exclude_logged_extent()
2669 btrfs_put_block_group(block_group); in __exclude_logged_extent()
2825 struct btrfs_block_group *block_group, *tmp; in btrfs_finish_extent_commit() local
2867 list_for_each_entry_safe(block_group, tmp, deleted_bgs, bg_list) { in btrfs_finish_extent_commit()
2873 block_group->start, in btrfs_finish_extent_commit()
2874 block_group->length, in btrfs_finish_extent_commit()
2877 list_del_init(&block_group->bg_list); in btrfs_finish_extent_commit()
2878 btrfs_unfreeze_block_group(block_group); in btrfs_finish_extent_commit()
2879 btrfs_put_block_group(block_group); in btrfs_finish_extent_commit()
3579 struct btrfs_block_group *block_group, in btrfs_lock_cluster() argument
3588 used_bg = cluster->block_group; in btrfs_lock_cluster()
3592 if (used_bg == block_group) in btrfs_lock_cluster()
3609 if (used_bg == cluster->block_group) in btrfs_lock_cluster()
3661 WARN_ON(last_ptr->block_group != cluster_bg); in find_free_extent_clustered()
3767 static int do_allocation_clustered(struct btrfs_block_group *block_group, in do_allocation_clustered() argument
3775 ret = find_free_extent_clustered(block_group, ffe_ctl, bg_ret); in do_allocation_clustered()
3781 return find_free_extent_unclustered(block_group, ffe_ctl); in do_allocation_clustered()
3805 static int do_allocation_zoned(struct btrfs_block_group *block_group, in do_allocation_zoned() argument
3809 struct btrfs_fs_info *fs_info = block_group->fs_info; in do_allocation_zoned()
3810 struct btrfs_space_info *space_info = block_group->space_info; in do_allocation_zoned()
3811 struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl; in do_allocation_zoned()
3812 u64 start = block_group->start; in do_allocation_zoned()
3815 u64 bytenr = block_group->start; in do_allocation_zoned()
3821 ASSERT(btrfs_is_zoned(block_group->fs_info)); in do_allocation_zoned()
3851 spin_lock(&block_group->lock); in do_allocation_zoned()
3852 if (block_group->ro || btrfs_zoned_bg_is_full(block_group)) { in do_allocation_zoned()
3859 spin_unlock(&block_group->lock); in do_allocation_zoned()
3862 if (!ret && (block_group->flags & BTRFS_BLOCK_GROUP_DATA) && in do_allocation_zoned()
3863 !btrfs_zone_activate(block_group)) { in do_allocation_zoned()
3872 spin_lock(&block_group->lock); in do_allocation_zoned()
3880 block_group->start == fs_info->treelog_bg || in do_allocation_zoned()
3883 block_group->start == fs_info->data_reloc_bg || in do_allocation_zoned()
3886 if (block_group->ro || in do_allocation_zoned()
3888 test_bit(BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, &block_group->runtime_flags))) { in do_allocation_zoned()
3898 (block_group->used || block_group->reserved)) { in do_allocation_zoned()
3908 (block_group->used || block_group->reserved)) { in do_allocation_zoned()
3913 WARN_ON_ONCE(block_group->alloc_offset > block_group->zone_capacity); in do_allocation_zoned()
3914 avail = block_group->zone_capacity - block_group->alloc_offset; in do_allocation_zoned()
3929 fs_info->treelog_bg = block_group->start; in do_allocation_zoned()
3933 fs_info->data_reloc_bg = block_group->start; in do_allocation_zoned()
3949 set_bit(BLOCK_GROUP_FLAG_ZONED_DATA_RELOC, &block_group->runtime_flags); in do_allocation_zoned()
3952 ffe_ctl->found_offset = start + block_group->alloc_offset; in do_allocation_zoned()
3953 block_group->alloc_offset += num_bytes; in do_allocation_zoned()
3972 spin_unlock(&block_group->lock); in do_allocation_zoned()
3977 static int do_allocation(struct btrfs_block_group *block_group, in do_allocation() argument
3983 return do_allocation_clustered(block_group, ffe_ctl, bg_ret); in do_allocation()
3985 return do_allocation_zoned(block_group, ffe_ctl, bg_ret); in do_allocation()
3991 static void release_block_group(struct btrfs_block_group *block_group, in release_block_group() argument
4006 BUG_ON(btrfs_bg_flags_to_raid_index(block_group->flags) != in release_block_group()
4008 btrfs_release_block_group(block_group, delalloc); in release_block_group()
4252 if (last_ptr->block_group) in prepare_allocation_clustered()
4283 struct btrfs_block_group *block_group; in prepare_allocation_zoned() local
4286 list_for_each_entry(block_group, &fs_info->zone_active_bgs, active_bg_list) { in prepare_allocation_zoned()
4291 u64 avail = block_group->zone_capacity - block_group->alloc_offset; in prepare_allocation_zoned()
4293 if (block_group_bits(block_group, ffe_ctl->flags) && in prepare_allocation_zoned()
4295 ffe_ctl->hint_byte = block_group->start; in prepare_allocation_zoned()
4353 struct btrfs_block_group *block_group = NULL; in find_free_extent() local
4399 block_group = btrfs_lookup_block_group(fs_info, in find_free_extent()
4408 if (block_group && block_group_bits(block_group, ffe_ctl->flags) && in find_free_extent()
4409 block_group->cached != BTRFS_CACHE_NO) { in find_free_extent()
4411 if (list_empty(&block_group->list) || in find_free_extent()
4412 block_group->ro) { in find_free_extent()
4419 btrfs_put_block_group(block_group); in find_free_extent()
4423 block_group->flags); in find_free_extent()
4424 btrfs_lock_block_group(block_group, in find_free_extent()
4429 } else if (block_group) { in find_free_extent()
4430 btrfs_put_block_group(block_group); in find_free_extent()
4440 list_for_each_entry(block_group, in find_free_extent()
4446 if (unlikely(block_group->ro)) { in find_free_extent()
4448 btrfs_clear_treelog_bg(block_group); in find_free_extent()
4450 btrfs_clear_data_reloc_bg(block_group); in find_free_extent()
4454 btrfs_grab_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4455 ffe_ctl->search_start = block_group->start; in find_free_extent()
4462 if (!block_group_bits(block_group, ffe_ctl->flags)) { in find_free_extent()
4473 if ((ffe_ctl->flags & extra) && !(block_group->flags & extra)) in find_free_extent()
4481 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4486 trace_find_free_extent_have_block_group(root, ffe_ctl, block_group); in find_free_extent()
4487 ffe_ctl->cached = btrfs_block_group_done(block_group); in find_free_extent()
4490 ret = btrfs_cache_block_group(block_group, false); in find_free_extent()
4508 if (unlikely(block_group->cached == BTRFS_CACHE_ERROR)) { in find_free_extent()
4514 if (!find_free_extent_check_size_class(ffe_ctl, block_group)) in find_free_extent()
4518 ret = do_allocation(block_group, ffe_ctl, &bg_ret); in find_free_extent()
4522 if (bg_ret && bg_ret != block_group) { in find_free_extent()
4523 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4524 block_group = bg_ret; in find_free_extent()
4533 block_group->start + block_group->length) { in find_free_extent()
4534 btrfs_add_free_space_unused(block_group, in find_free_extent()
4541 btrfs_add_free_space_unused(block_group, in find_free_extent()
4545 ret = btrfs_add_reserved_bytes(block_group, ffe_ctl->ram_bytes, in find_free_extent()
4550 btrfs_add_free_space_unused(block_group, in find_free_extent()
4555 btrfs_inc_block_group_reservations(block_group); in find_free_extent()
4561 trace_btrfs_reserve_extent(block_group, ffe_ctl); in find_free_extent()
4562 btrfs_release_block_group(block_group, ffe_ctl->delalloc); in find_free_extent()
4568 btrfs_wait_block_group_cache_progress(block_group, in find_free_extent()
4574 release_block_group(block_group, ffe_ctl, ffe_ctl->delalloc); in find_free_extent()
4944 struct btrfs_block_group *block_group; in btrfs_alloc_logged_file_extent() local
4965 block_group = btrfs_lookup_block_group(fs_info, ins->objectid); in btrfs_alloc_logged_file_extent()
4966 if (!block_group) in btrfs_alloc_logged_file_extent()
4969 space_info = block_group->space_info; in btrfs_alloc_logged_file_extent()
4971 spin_lock(&block_group->lock); in btrfs_alloc_logged_file_extent()
4973 block_group->reserved += ins->offset; in btrfs_alloc_logged_file_extent()
4974 spin_unlock(&block_group->lock); in btrfs_alloc_logged_file_extent()
4982 btrfs_put_block_group(block_group); in btrfs_alloc_logged_file_extent()