Lines Matching +full:6 +full:bg
54 * BG A: 10 data extents | BG A: deleted
55 * BG B: 2 data extents | BG B: 10 data extents (2 old + 8 relocated)
56 * BG C: 1 extents | BG C: 3 data extents (1 old + 2 relocated)
3726 trans = btrfs_start_transaction(root, 6); in create_reloc_inode()
3933 struct btrfs_block_group *bg, s64 diff) in adjust_block_group_remap_bytes() argument
3939 spin_lock(&bg->lock); in adjust_block_group_remap_bytes()
3940 bg->remap_bytes += diff; in adjust_block_group_remap_bytes()
3941 if (bg->used == 0 && bg->remap_bytes == 0) in adjust_block_group_remap_bytes()
3943 spin_unlock(&bg->lock); in adjust_block_group_remap_bytes()
3946 btrfs_mark_bg_unused(bg); in adjust_block_group_remap_bytes()
3949 if (list_empty(&bg->dirty_list)) { in adjust_block_group_remap_bytes()
3950 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in adjust_block_group_remap_bytes()
3952 btrfs_get_block_group(bg); in adjust_block_group_remap_bytes()
4143 struct btrfs_block_group *bg, u64 new_addr, in move_existing_remap() argument
4154 const bool is_data = (bg->flags & BTRFS_BLOCK_GROUP_DATA); in move_existing_remap()
4155 struct btrfs_space_info *sinfo = bg->space_info; in move_existing_remap()
4217 * move_existing_remaps() loops until the BG contains no in move_existing_remap()
4292 adjust_block_group_remap_bytes(trans, bg, -dest_length); in move_existing_remap()
4344 struct btrfs_block_group *bg, in move_existing_remaps() argument
4354 while (bg->remap_bytes > 0) { in move_existing_remaps()
4355 key.objectid = bg->start; in move_existing_remaps()
4408 ret = move_existing_remap(fs_info, path, bg, key.objectid, in move_existing_remaps()
4414 ASSERT(bg->remap_bytes == 0); in move_existing_remaps()
4421 struct btrfs_block_group *bg) in create_remap_tree_entries() argument
4435 mutex_lock(&bg->free_space_lock); in create_remap_tree_entries()
4437 if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &bg->runtime_flags)) { in create_remap_tree_entries()
4438 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4440 ret = btrfs_add_block_group_free_space(trans, bg); in create_remap_tree_entries()
4444 mutex_lock(&bg->free_space_lock); in create_remap_tree_entries()
4447 fsi = btrfs_search_free_space_info(trans, bg, path, 0); in create_remap_tree_entries()
4449 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4459 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4463 key.objectid = bg->start; in create_remap_tree_entries()
4467 space_root = btrfs_free_space_root(bg); in create_remap_tree_entries()
4471 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4482 if (found_key.objectid >= bg->start + bg->length) in create_remap_tree_entries()
4510 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4543 mutex_unlock(&bg->free_space_lock); in create_remap_tree_entries()
4555 entries[num_entries].objectid = bg->start; in create_remap_tree_entries()
4557 entries[num_entries].offset = bg->length; in create_remap_tree_entries()
4560 if (space_runs[0].start > bg->start) { in create_remap_tree_entries()
4561 entries[num_entries].objectid = bg->start; in create_remap_tree_entries()
4563 entries[num_entries].offset = space_runs[0].start - bg->start; in create_remap_tree_entries()
4575 if (space_runs[num_space_runs - 1].end < bg->start + bg->length) { in create_remap_tree_entries()
4580 bg->start + bg->length - space_runs[num_space_runs - 1].end; in create_remap_tree_entries()
4588 bg->identity_remap_count = num_entries; in create_remap_tree_entries()
4696 struct btrfs_block_group *bg) in btrfs_last_identity_remap_gone() argument
4698 struct btrfs_fs_info *fs_info = bg->fs_info; in btrfs_last_identity_remap_gone()
4713 if (bg->flags & BTRFS_BLOCK_GROUP_DUP) in btrfs_last_identity_remap_gone()
4745 btrfs_remove_bg_from_sinfo(bg); in btrfs_last_identity_remap_gone()
4747 spin_lock(&bg->lock); in btrfs_last_identity_remap_gone()
4748 clear_bit(BLOCK_GROUP_FLAG_STRIPE_REMOVAL_PENDING, &bg->runtime_flags); in btrfs_last_identity_remap_gone()
4749 spin_unlock(&bg->lock); in btrfs_last_identity_remap_gone()
4766 struct btrfs_block_group *bg, int delta) in adjust_identity_remap_count() argument
4772 WARN_ON(delta < 0 && -delta > bg->identity_remap_count); in adjust_identity_remap_count()
4774 spin_lock(&bg->lock); in adjust_identity_remap_count()
4776 bg->identity_remap_count += delta; in adjust_identity_remap_count()
4778 if (bg->identity_remap_count == 0 && in adjust_identity_remap_count()
4779 !test_bit(BLOCK_GROUP_FLAG_FULLY_REMAPPED, &bg->runtime_flags)) { in adjust_identity_remap_count()
4780 set_bit(BLOCK_GROUP_FLAG_FULLY_REMAPPED, &bg->runtime_flags); in adjust_identity_remap_count()
4784 spin_unlock(&bg->lock); in adjust_identity_remap_count()
4787 if (list_empty(&bg->dirty_list)) { in adjust_identity_remap_count()
4788 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in adjust_identity_remap_count()
4790 btrfs_get_block_group(bg); in adjust_identity_remap_count()
4799 btrfs_mark_bg_fully_remapped(bg, trans); in adjust_identity_remap_count()
5116 struct btrfs_block_group *bg) in do_remap_reloc() argument
5118 u64 last_start = bg->start; in do_remap_reloc()
5122 ret = do_remap_reloc_trans(fs_info, bg, path, &last_start); in do_remap_reloc()
5185 struct btrfs_block_group *bg) in start_block_group_remapping() argument
5191 ret = btrfs_cache_block_group(bg, true); in start_block_group_remapping()
5208 if (bg->flags & BTRFS_BLOCK_GROUP_REMAPPED) { in start_block_group_remapping()
5213 ret = create_remap_tree_entries(trans, path, bg); in start_block_group_remapping()
5219 spin_lock(&bg->lock); in start_block_group_remapping()
5220 bg->flags |= BTRFS_BLOCK_GROUP_REMAPPED; in start_block_group_remapping()
5221 spin_unlock(&bg->lock); in start_block_group_remapping()
5224 if (list_empty(&bg->dirty_list)) { in start_block_group_remapping()
5225 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in start_block_group_remapping()
5227 btrfs_get_block_group(bg); in start_block_group_remapping()
5235 ret = mark_chunk_remapped(trans, path, bg->start); in start_block_group_remapping()
5241 ret = btrfs_remove_block_group_free_space(trans, bg); in start_block_group_remapping()
5247 btrfs_remove_free_space_cache(bg); in start_block_group_remapping()
5316 struct btrfs_block_group *bg; in btrfs_relocate_block_group() local
5344 bg = btrfs_lookup_block_group(fs_info, group_start); in btrfs_relocate_block_group()
5345 if (!bg) in btrfs_relocate_block_group()
5356 if (bg->flags & BTRFS_BLOCK_GROUP_DATA) in btrfs_relocate_block_group()
5359 if (btrfs_pinned_by_swapfile(fs_info, bg)) { in btrfs_relocate_block_group()
5360 btrfs_put_block_group(bg); in btrfs_relocate_block_group()
5366 btrfs_put_block_group(bg); in btrfs_relocate_block_group()
5375 rc->block_group = bg; in btrfs_relocate_block_group()
5418 if (should_relocate_using_remap_tree(bg)) { in btrfs_relocate_block_group()
5419 if (bg->remap_bytes != 0) { in btrfs_relocate_block_group()
5420 ret = move_existing_remaps(fs_info, bg, path); in btrfs_relocate_block_group()
5424 ret = start_block_group_remapping(fs_info, path, bg); in btrfs_relocate_block_group()
5445 btrfs_put_block_group(bg); in btrfs_relocate_block_group()
5930 struct btrfs_block_group *bg, in remove_range_from_remap_tree() argument
6016 adjust_identity_remap_count(trans, bg, identity_count_delta); in remove_range_from_remap_tree()
6053 struct btrfs_block_group *bg; in btrfs_remove_extent_from_remap_tree() local
6060 bg = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_remove_extent_from_remap_tree()
6061 if (!bg) in btrfs_remove_extent_from_remap_tree()
6066 if (!(bg->flags & BTRFS_BLOCK_GROUP_REMAPPED)) { in btrfs_remove_extent_from_remap_tree()
6068 btrfs_put_block_group(bg); in btrfs_remove_extent_from_remap_tree()
6103 length = remove_range_from_remap_tree(trans, path, bg, bytenr, num_bytes); in btrfs_remove_extent_from_remap_tree()
6118 btrfs_put_block_group(bg); in btrfs_remove_extent_from_remap_tree()