Lines Matching refs:trans

406 			struct btrfs_trans_handle *trans,  in build_backref_tree()  argument
438 ret = btrfs_backref_add_tree_node(trans, cache, path, iter, in build_backref_tree()
583 static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans, in create_reloc_root() argument
623 ret = btrfs_copy_root(trans, root, root->commit_root, &eb, in create_reloc_root()
646 ret = btrfs_copy_root(trans, root, root->node, &eb, in create_reloc_root()
660 btrfs_set_root_generation(root_item, trans->transid); in create_reloc_root()
672 ret = btrfs_insert_root(trans, fs_info->tree_root, in create_reloc_root()
683 btrfs_set_root_last_trans(reloc_root, trans->transid); in create_reloc_root()
687 btrfs_abort_transaction(trans, ret); in create_reloc_root()
698 int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, in btrfs_init_reloc_root() argument
728 btrfs_set_root_last_trans(reloc_root, trans->transid); in btrfs_init_reloc_root()
739 if (!trans->reloc_reserved) { in btrfs_init_reloc_root()
740 rsv = trans->block_rsv; in btrfs_init_reloc_root()
741 trans->block_rsv = rc->block_rsv; in btrfs_init_reloc_root()
744 reloc_root = create_reloc_root(trans, root, btrfs_root_id(root)); in btrfs_init_reloc_root()
746 trans->block_rsv = rsv; in btrfs_init_reloc_root()
764 int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, in btrfs_update_reloc_root() argument
804 ret = btrfs_update_root(trans, fs_info->tree_root, in btrfs_update_reloc_root()
855 int replace_file_extents(struct btrfs_trans_handle *trans, in replace_file_extents() argument
962 ret = btrfs_inc_extent_ref(trans, &ref); in replace_file_extents()
964 btrfs_abort_transaction(trans, ret); in replace_file_extents()
976 ret = btrfs_free_extent(trans, &ref); in replace_file_extents()
978 btrfs_abort_transaction(trans, ret); in replace_file_extents()
1008 int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, in replace_path() argument
1047 ret = btrfs_cow_block(trans, dest, eb, NULL, 0, &eb, in replace_path()
1110 ret = btrfs_cow_block(trans, dest, eb, parent, in replace_path()
1140 ret = btrfs_search_slot(trans, src, &key, path, 0, 1); in replace_path()
1187 ret = btrfs_inc_extent_ref(trans, &ref); in replace_path()
1189 btrfs_abort_transaction(trans, ret); in replace_path()
1200 ret = btrfs_inc_extent_ref(trans, &ref); in replace_path()
1202 btrfs_abort_transaction(trans, ret); in replace_path()
1214 ret = btrfs_free_extent(trans, &ref); in replace_path()
1216 btrfs_abort_transaction(trans, ret); in replace_path()
1228 ret = btrfs_free_extent(trans, &ref); in replace_path()
1230 btrfs_abort_transaction(trans, ret); in replace_path()
1423 static int insert_dirty_subvol(struct btrfs_trans_handle *trans, in insert_dirty_subvol() argument
1440 ret = btrfs_update_reloc_root(trans, root); in insert_dirty_subvol()
1510 struct btrfs_trans_handle *trans = NULL; in merge_reloc_root() local
1573 trans = btrfs_start_transaction(root, 0); in merge_reloc_root()
1574 if (IS_ERR(trans)) { in merge_reloc_root()
1575 ret = PTR_ERR(trans); in merge_reloc_root()
1576 trans = NULL; in merge_reloc_root()
1590 btrfs_set_root_last_trans(reloc_root, trans->transid); in merge_reloc_root()
1591 trans->block_rsv = rc->block_rsv; in merge_reloc_root()
1606 ret = replace_path(trans, rc, root, reloc_root, path, in merge_reloc_root()
1631 btrfs_end_transaction_throttle(trans); in merge_reloc_root()
1632 trans = NULL; in merge_reloc_root()
1645 ret = btrfs_cow_block(trans, root, leaf, NULL, 0, &leaf, in merge_reloc_root()
1653 ret = insert_dirty_subvol(trans, rc, root); in merge_reloc_root()
1655 btrfs_abort_transaction(trans, ret); in merge_reloc_root()
1658 if (trans) in merge_reloc_root()
1659 btrfs_end_transaction_throttle(trans); in merge_reloc_root()
1675 struct btrfs_trans_handle *trans; in prepare_to_merge() local
1694 trans = btrfs_join_transaction(rc->extent_root); in prepare_to_merge()
1695 if (IS_ERR(trans)) { in prepare_to_merge()
1699 return PTR_ERR(trans); in prepare_to_merge()
1704 btrfs_end_transaction(trans); in prepare_to_merge()
1726 btrfs_abort_transaction(trans, (int)PTR_ERR(root)); in prepare_to_merge()
1759 btrfs_abort_transaction(trans, -EUCLEAN); in prepare_to_merge()
1771 ret = btrfs_update_reloc_root(trans, root); in prepare_to_merge()
1781 btrfs_abort_transaction(trans, ret); in prepare_to_merge()
1791 err = btrfs_commit_transaction(trans); in prepare_to_merge()
1793 btrfs_end_transaction(trans); in prepare_to_merge()
1925 static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans, in record_reloc_root_in_trans() argument
1932 if (btrfs_get_root_last_trans(reloc_root) == trans->transid) in record_reloc_root_in_trans()
1957 ret = btrfs_record_root_in_trans(trans, root); in record_reloc_root_in_trans()
1964 struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, in select_reloc_root() argument
1989 btrfs_err(trans->fs_info, in select_reloc_root()
1995 btrfs_err(trans->fs_info, in select_reloc_root()
2002 ret = record_reloc_root_in_trans(trans, root); in select_reloc_root()
2008 ret = btrfs_record_root_in_trans(trans, root); in select_reloc_root()
2028 btrfs_err(trans->fs_info, in select_reloc_root()
2135 static int refill_metadata_space(struct btrfs_trans_handle *trans, in refill_metadata_space() argument
2138 struct btrfs_fs_info *fs_info = trans->fs_info; in refill_metadata_space()
2141 trans->block_rsv = rc->block_rsv; in refill_metadata_space()
2171 static int reserve_metadata_space(struct btrfs_trans_handle *trans, in reserve_metadata_space() argument
2178 return refill_metadata_space(trans, rc, num_bytes); in reserve_metadata_space()
2188 static int do_relocation(struct btrfs_trans_handle *trans, in do_relocation() argument
2216 root = select_reloc_root(trans, rc, upper, edges); in do_relocation()
2236 ret = btrfs_search_slot(trans, root, key, path, 0, 1); in do_relocation()
2288 ret = btrfs_cow_block(trans, root, eb, upper->eb, in do_relocation()
2312 trans->transid); in do_relocation()
2313 btrfs_mark_buffer_dirty(trans, upper->eb); in do_relocation()
2317 ret = btrfs_inc_extent_ref(trans, &ref); in do_relocation()
2319 ret = btrfs_drop_subtree(trans, root, eb, in do_relocation()
2322 btrfs_abort_transaction(trans, ret); in do_relocation()
2349 static int link_to_upper(struct btrfs_trans_handle *trans, in link_to_upper() argument
2357 return do_relocation(trans, rc, node, &key, path, 0); in link_to_upper()
2360 static int finish_pending_nodes(struct btrfs_trans_handle *trans, in finish_pending_nodes() argument
2378 ret = link_to_upper(trans, rc, node, path); in finish_pending_nodes()
2459 static int relocate_tree_block(struct btrfs_trans_handle *trans, in relocate_tree_block() argument
2475 ret = reserve_metadata_space(trans, rc, node); in relocate_tree_block()
2515 ret = btrfs_record_root_in_trans(trans, root); in relocate_tree_block()
2541 ret = do_relocation(trans, rc, node, key, path, 1); in relocate_tree_block()
2549 static int relocate_cowonly_block(struct btrfs_trans_handle *trans, in relocate_cowonly_block() argument
2553 struct btrfs_fs_info *fs_info = trans->fs_info; in relocate_cowonly_block()
2566 ret = refill_metadata_space(trans, rc, num_bytes); in relocate_cowonly_block()
2573 btrfs_reserve_chunk_metadata(trans, false); in relocate_cowonly_block()
2575 ret = btrfs_search_slot(trans, root, &block->key, path, 0, 1); in relocate_cowonly_block()
2580 btrfs_trans_release_chunk_metadata(trans); in relocate_cowonly_block()
2592 int relocate_tree_blocks(struct btrfs_trans_handle *trans, in relocate_tree_blocks() argument
2635 ret = relocate_cowonly_block(trans, rc, block, path); in relocate_tree_blocks()
2641 node = build_backref_tree(trans, rc, &block->key, in relocate_tree_blocks()
2648 ret = relocate_tree_block(trans, rc, node, &block->key, in relocate_tree_blocks()
2654 ret = finish_pending_nodes(trans, rc, path, ret); in relocate_tree_blocks()
3212 struct btrfs_trans_handle *trans; in delete_block_group_cache() local
3230 trans = btrfs_join_transaction(root); in delete_block_group_cache()
3231 if (IS_ERR(trans)) { in delete_block_group_cache()
3232 ret = PTR_ERR(trans); in delete_block_group_cache()
3236 ret = btrfs_truncate_free_space_cache(trans, block_group, inode); in delete_block_group_cache()
3238 btrfs_end_transaction(trans); in delete_block_group_cache()
3443 struct btrfs_trans_handle *trans; in prepare_to_relocate() local
3468 trans = btrfs_join_transaction(rc->extent_root); in prepare_to_relocate()
3469 if (IS_ERR(trans)) { in prepare_to_relocate()
3476 return PTR_ERR(trans); in prepare_to_relocate()
3479 ret = btrfs_commit_transaction(trans); in prepare_to_relocate()
3491 struct btrfs_trans_handle *trans = NULL; in relocate_block_group() local
3520 trans = btrfs_start_transaction(rc->extent_root, 0); in relocate_block_group()
3521 if (IS_ERR(trans)) { in relocate_block_group()
3522 err = PTR_ERR(trans); in relocate_block_group()
3523 trans = NULL; in relocate_block_group()
3527 if (rc->backref_cache.last_trans != trans->transid) in relocate_block_group()
3529 rc->backref_cache.last_trans = trans->transid; in relocate_block_group()
3573 ret = relocate_tree_blocks(trans, rc, &blocks); in relocate_block_group()
3584 btrfs_end_transaction_throttle(trans); in relocate_block_group()
3586 trans = NULL; in relocate_block_group()
3602 if (trans && progress && err == -ENOSPC) { in relocate_block_group()
3603 ret = btrfs_force_chunk_alloc(trans, rc->block_group->flags); in relocate_block_group()
3614 if (trans) { in relocate_block_group()
3615 btrfs_end_transaction_throttle(trans); in relocate_block_group()
3648 trans = btrfs_join_transaction(rc->extent_root); in relocate_block_group()
3649 if (IS_ERR(trans)) { in relocate_block_group()
3650 err = PTR_ERR(trans); in relocate_block_group()
3653 ret = btrfs_commit_transaction(trans); in relocate_block_group()
3664 static int __insert_orphan_inode(struct btrfs_trans_handle *trans, in __insert_orphan_inode() argument
3676 ret = btrfs_insert_empty_inode(trans, root, path, objectid); in __insert_orphan_inode()
3691 static void delete_orphan_inode(struct btrfs_trans_handle *trans, in delete_orphan_inode() argument
3707 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in delete_orphan_inode()
3713 ret = btrfs_del_item(trans, root, path); in delete_orphan_inode()
3716 btrfs_abort_transaction(trans, ret); in delete_orphan_inode()
3728 struct btrfs_trans_handle *trans; in create_reloc_inode() local
3734 trans = btrfs_start_transaction(root, 6); in create_reloc_inode()
3735 if (IS_ERR(trans)) { in create_reloc_inode()
3737 return ERR_CAST(trans); in create_reloc_inode()
3744 ret = __insert_orphan_inode(trans, root, objectid); in create_reloc_inode()
3750 delete_orphan_inode(trans, root, objectid); in create_reloc_inode()
3757 ret = btrfs_orphan_add(trans, inode); in create_reloc_inode()
3760 btrfs_end_transaction(trans); in create_reloc_inode()
3863 static int add_remap_tree_entries(struct btrfs_trans_handle *trans, struct btrfs_path *path, in add_remap_tree_entries() argument
3867 struct btrfs_fs_info *fs_info = trans->fs_info; in add_remap_tree_entries()
3872 max_items = BTRFS_LEAF_DATA_SIZE(trans->fs_info) / sizeof(struct btrfs_item); in add_remap_tree_entries()
3884 ret = btrfs_insert_empty_items(trans, fs_info->remap_root, path, &batch); in add_remap_tree_entries()
3940 static void adjust_block_group_remap_bytes(struct btrfs_trans_handle *trans, in adjust_block_group_remap_bytes() argument
3943 struct btrfs_fs_info *fs_info = trans->fs_info; in adjust_block_group_remap_bytes()
3956 spin_lock(&trans->transaction->dirty_bgs_lock); in adjust_block_group_remap_bytes()
3958 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in adjust_block_group_remap_bytes()
3962 spin_unlock(&trans->transaction->dirty_bgs_lock); in adjust_block_group_remap_bytes()
4091 static int add_remap_item(struct btrfs_trans_handle *trans, in add_remap_item() argument
4095 struct btrfs_fs_info *fs_info = trans->fs_info; in add_remap_item()
4105 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, path, in add_remap_item()
4120 static int add_remap_backref_item(struct btrfs_trans_handle *trans, in add_remap_backref_item() argument
4124 struct btrfs_fs_info *fs_info = trans->fs_info; in add_remap_backref_item()
4134 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, path, &key, in add_remap_backref_item()
4154 struct btrfs_trans_handle *trans; in move_existing_remap() local
4199 trans = btrfs_join_transaction(fs_info->remap_root); in move_existing_remap()
4200 if (IS_ERR(trans)) { in move_existing_remap()
4201 ret = PTR_ERR(trans); in move_existing_remap()
4202 trans = NULL; in move_existing_remap()
4214 ret = btrfs_search_slot(trans, fs_info->remap_root, &key, path, 0, 1); in move_existing_remap()
4237 btrfs_mark_buffer_dirty(trans, leaf); in move_existing_remap()
4241 btrfs_set_item_key_safe(trans, path, &key); in move_existing_remap()
4248 ret = add_remap_item(trans, path, new_addr + dest_length, in move_existing_remap()
4259 ret = btrfs_search_slot(trans, fs_info->remap_root, &key, path, -1, 1); in move_existing_remap()
4271 ret = btrfs_del_item(trans, fs_info->remap_root, path); in move_existing_remap()
4279 btrfs_set_item_key_safe(trans, path, &key); in move_existing_remap()
4290 ret = add_remap_backref_item(trans, path, dest_addr, dest_length, old_addr); in move_existing_remap()
4294 adjust_block_group_remap_bytes(trans, bg, -dest_length); in move_existing_remap()
4296 ret = btrfs_add_to_free_space_tree(trans, new_addr, dest_length); in move_existing_remap()
4300 adjust_block_group_remap_bytes(trans, dest_bg, dest_length); in move_existing_remap()
4308 ret = btrfs_add_block_group_free_space(trans, dest_bg); in move_existing_remap()
4313 ret = btrfs_remove_from_free_space_tree(trans, dest_addr, dest_length); in move_existing_remap()
4315 btrfs_remove_from_free_space_tree(trans, new_addr, dest_length); in move_existing_remap()
4330 if (trans) { in move_existing_remap()
4331 btrfs_abort_transaction(trans, ret); in move_existing_remap()
4332 btrfs_end_transaction(trans); in move_existing_remap()
4337 ret = btrfs_commit_transaction(trans); in move_existing_remap()
4421 static int create_remap_tree_entries(struct btrfs_trans_handle *trans, in create_remap_tree_entries() argument
4425 struct btrfs_fs_info *fs_info = trans->fs_info; in create_remap_tree_entries()
4442 ret = btrfs_add_block_group_free_space(trans, bg); in create_remap_tree_entries()
4449 fsi = btrfs_search_free_space_info(trans, bg, path, 0); in create_remap_tree_entries()
4471 ret = btrfs_search_slot(trans, space_root, &key, path, 0, 0); in create_remap_tree_entries()
4592 ret = add_remap_tree_entries(trans, path, entries, num_entries); in create_remap_tree_entries()
4601 static int find_next_identity_remap(struct btrfs_trans_handle *trans, in find_next_identity_remap() argument
4607 struct btrfs_root *remap_root = trans->fs_info->remap_root; in find_next_identity_remap()
4614 ret = btrfs_search_slot(trans, remap_root, &key, path, 0, 0); in find_next_identity_remap()
4655 static int remove_chunk_stripes(struct btrfs_trans_handle *trans, in remove_chunk_stripes() argument
4659 struct btrfs_fs_info *fs_info = trans->fs_info; in remove_chunk_stripes()
4669 btrfs_reserve_chunk_metadata(trans, false); in remove_chunk_stripes()
4671 ret = btrfs_search_slot(trans, fs_info->chunk_root, &key, path, 0, 1); in remove_chunk_stripes()
4677 btrfs_trans_release_chunk_metadata(trans); in remove_chunk_stripes()
4687 btrfs_truncate_item(trans, path, offsetof(struct btrfs_chunk, stripe), 1); in remove_chunk_stripes()
4689 btrfs_mark_buffer_dirty(trans, leaf); in remove_chunk_stripes()
4692 btrfs_trans_release_chunk_metadata(trans); in remove_chunk_stripes()
4701 struct btrfs_trans_handle *trans; in btrfs_last_identity_remap_gone() local
4720 trans = btrfs_start_transaction_fallback_global_rsv(fs_info->tree_root, num_items); in btrfs_last_identity_remap_gone()
4721 if (IS_ERR(trans)) in btrfs_last_identity_remap_gone()
4722 return PTR_ERR(trans); in btrfs_last_identity_remap_gone()
4724 ret = btrfs_remove_dev_extents(trans, chunk_map); in btrfs_last_identity_remap_gone()
4726 btrfs_abort_transaction(trans, ret); in btrfs_last_identity_remap_gone()
4727 btrfs_end_transaction(trans); in btrfs_last_identity_remap_gone()
4731 mutex_lock(&trans->fs_info->chunk_mutex); in btrfs_last_identity_remap_gone()
4733 ret = btrfs_update_device(trans, chunk_map->stripes[i].dev); in btrfs_last_identity_remap_gone()
4735 mutex_unlock(&trans->fs_info->chunk_mutex); in btrfs_last_identity_remap_gone()
4736 btrfs_abort_transaction(trans, ret); in btrfs_last_identity_remap_gone()
4737 btrfs_end_transaction(trans); in btrfs_last_identity_remap_gone()
4741 mutex_unlock(&trans->fs_info->chunk_mutex); in btrfs_last_identity_remap_gone()
4743 write_lock(&trans->fs_info->mapping_tree_lock); in btrfs_last_identity_remap_gone()
4745 write_unlock(&trans->fs_info->mapping_tree_lock); in btrfs_last_identity_remap_gone()
4753 ret = remove_chunk_stripes(trans, chunk_map, path); in btrfs_last_identity_remap_gone()
4755 btrfs_abort_transaction(trans, ret); in btrfs_last_identity_remap_gone()
4756 btrfs_end_transaction(trans); in btrfs_last_identity_remap_gone()
4760 ret = btrfs_commit_transaction(trans); in btrfs_last_identity_remap_gone()
4767 static void adjust_identity_remap_count(struct btrfs_trans_handle *trans, in adjust_identity_remap_count() argument
4770 struct btrfs_fs_info *fs_info = trans->fs_info; in adjust_identity_remap_count()
4788 spin_lock(&trans->transaction->dirty_bgs_lock); in adjust_identity_remap_count()
4790 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in adjust_identity_remap_count()
4794 spin_unlock(&trans->transaction->dirty_bgs_lock); in adjust_identity_remap_count()
4801 btrfs_mark_bg_fully_remapped(bg, trans); in adjust_identity_remap_count()
4804 static int add_remap_entry(struct btrfs_trans_handle *trans, in add_remap_entry() argument
4809 struct btrfs_fs_info *fs_info = trans->fs_info; in add_remap_entry()
4818 ret = btrfs_search_slot(trans, fs_info->remap_root, &key, path, -1, 1); in add_remap_entry()
4840 ret = btrfs_del_item(trans, fs_info->remap_root, path); in add_remap_entry()
4850 btrfs_set_item_key_safe(trans, path, &new_key); in add_remap_entry()
4856 ret = add_remap_item(trans, path, new_addr, length, old_addr); in add_remap_entry()
4866 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, in add_remap_entry()
4877 ret = add_remap_backref_item(trans, path, new_addr, length, old_addr); in add_remap_entry()
4882 adjust_identity_remap_count(trans, src_bg, identity_count_delta); in add_remap_entry()
4890 static int mark_chunk_remapped(struct btrfs_trans_handle *trans, in mark_chunk_remapped() argument
4893 struct btrfs_fs_info *fs_info = trans->fs_info; in mark_chunk_remapped()
4918 ret = btrfs_search_slot(trans, fs_info->chunk_root, &key, path, 0, 1); in mark_chunk_remapped()
4929 btrfs_mark_buffer_dirty(trans, leaf); in mark_chunk_remapped()
4943 struct btrfs_trans_handle *trans; in do_remap_reloc_trans() local
4963 trans = btrfs_start_transaction(extent_root, 0); in do_remap_reloc_trans()
4964 if (IS_ERR(trans)) in do_remap_reloc_trans()
4965 return PTR_ERR(trans); in do_remap_reloc_trans()
4969 ret = find_next_identity_remap(trans, path, src_bg->start + src_bg->length, in do_remap_reloc_trans()
4976 btrfs_end_transaction(trans); in do_remap_reloc_trans()
5007 btrfs_end_transaction(trans); in do_remap_reloc_trans()
5033 ret = btrfs_add_block_group_free_space(trans, dest_bg); in do_remap_reloc_trans()
5042 ret = btrfs_remove_from_free_space_tree(trans, new_addr, length); in do_remap_reloc_trans()
5046 ret = add_remap_entry(trans, path, src_bg, start, new_addr, length); in do_remap_reloc_trans()
5048 btrfs_add_to_free_space_tree(trans, new_addr, length); in do_remap_reloc_trans()
5052 adjust_block_group_remap_bytes(trans, dest_bg, length); in do_remap_reloc_trans()
5079 btrfs_mark_bg_fully_remapped(src_bg, trans); in do_remap_reloc_trans()
5082 ret = btrfs_end_transaction(trans); in do_remap_reloc_trans()
5100 btrfs_end_transaction(trans); in do_remap_reloc_trans()
5177 struct btrfs_trans_handle *trans; in start_block_group_remapping() local
5185 trans = btrfs_start_transaction(fs_info->remap_root, 0); in start_block_group_remapping()
5186 if (IS_ERR(trans)) in start_block_group_remapping()
5187 return PTR_ERR(trans); in start_block_group_remapping()
5190 ret = btrfs_run_delayed_refs(trans, U64_MAX); in start_block_group_remapping()
5192 btrfs_end_transaction(trans); in start_block_group_remapping()
5203 ret = create_remap_tree_entries(trans, path, bg); in start_block_group_remapping()
5205 btrfs_abort_transaction(trans, ret); in start_block_group_remapping()
5213 spin_lock(&trans->transaction->dirty_bgs_lock); in start_block_group_remapping()
5215 list_add_tail(&bg->dirty_list, &trans->transaction->dirty_bgs); in start_block_group_remapping()
5219 spin_unlock(&trans->transaction->dirty_bgs_lock); in start_block_group_remapping()
5225 ret = mark_chunk_remapped(trans, path, bg->start); in start_block_group_remapping()
5227 btrfs_abort_transaction(trans, ret); in start_block_group_remapping()
5231 ret = btrfs_remove_block_group_free_space(trans, bg); in start_block_group_remapping()
5233 btrfs_abort_transaction(trans, ret); in start_block_group_remapping()
5242 ret2 = btrfs_end_transaction(trans); in start_block_group_remapping()
5443 struct btrfs_trans_handle *trans; in mark_garbage_root() local
5446 trans = btrfs_start_transaction(fs_info->tree_root, 0); in mark_garbage_root()
5447 if (IS_ERR(trans)) in mark_garbage_root()
5448 return PTR_ERR(trans); in mark_garbage_root()
5454 ret = btrfs_update_root(trans, fs_info->tree_root, in mark_garbage_root()
5457 err = btrfs_end_transaction(trans); in mark_garbage_root()
5478 struct btrfs_trans_handle *trans; in btrfs_recover_relocation() local
5564 trans = btrfs_join_transaction(rc->extent_root); in btrfs_recover_relocation()
5565 if (IS_ERR(trans)) { in btrfs_recover_relocation()
5566 ret = PTR_ERR(trans); in btrfs_recover_relocation()
5587 btrfs_end_transaction(trans); in btrfs_recover_relocation()
5596 btrfs_end_transaction(trans); in btrfs_recover_relocation()
5603 ret = btrfs_commit_transaction(trans); in btrfs_recover_relocation()
5611 trans = btrfs_join_transaction(rc->extent_root); in btrfs_recover_relocation()
5612 if (IS_ERR(trans)) { in btrfs_recover_relocation()
5613 ret = PTR_ERR(trans); in btrfs_recover_relocation()
5616 ret = btrfs_commit_transaction(trans); in btrfs_recover_relocation()
5697 int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, in btrfs_reloc_cow_block() argument
5756 ret = replace_file_extents(trans, rc, root, cow); in btrfs_reloc_cow_block()
5799 int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, in btrfs_reloc_post_snapshot() argument
5823 reloc_root = create_reloc_root(trans, root->reloc_root, btrfs_root_id(new_root)); in btrfs_reloc_post_snapshot()
5854 static int insert_remap_item(struct btrfs_trans_handle *trans, struct btrfs_path *path, in insert_remap_item() argument
5858 struct btrfs_fs_info *fs_info = trans->fs_info; in insert_remap_item()
5868 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, path, in insert_remap_item()
5878 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, in insert_remap_item()
5896 ret = btrfs_insert_empty_item(trans, fs_info->remap_root, in insert_remap_item()
5918 static int remove_range_from_remap_tree(struct btrfs_trans_handle *trans, in remove_range_from_remap_tree() argument
5924 struct btrfs_fs_info *fs_info = trans->fs_info; in remove_range_from_remap_tree()
5952 ret = btrfs_del_item(trans, fs_info->remap_root, path); in remove_range_from_remap_tree()
5965 ret = btrfs_search_slot(trans, fs_info->remap_root, &key, path, -1, 1); in remove_range_from_remap_tree()
5974 ret = btrfs_del_item(trans, fs_info->remap_root, path); in remove_range_from_remap_tree()
5984 ret = insert_remap_item(trans, path, remap_start, in remove_range_from_remap_tree()
5995 ret = insert_remap_item(trans, path, hole_end, in remove_range_from_remap_tree()
6006 adjust_identity_remap_count(trans, bg, identity_count_delta); in remove_range_from_remap_tree()
6018 adjust_block_group_remap_bytes(trans, dest_bg, -overlap_length); in remove_range_from_remap_tree()
6020 ret = btrfs_add_to_free_space_tree(trans, in remove_range_from_remap_tree()
6036 int btrfs_remove_extent_from_remap_tree(struct btrfs_trans_handle *trans, in btrfs_remove_extent_from_remap_tree() argument
6040 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_remove_extent_from_remap_tree()
6067 ret = btrfs_search_slot(trans, fs_info->remap_root, &key, path, -1, 1); in btrfs_remove_extent_from_remap_tree()
6093 length = remove_range_from_remap_tree(trans, path, bg, bytenr, num_bytes); in btrfs_remove_extent_from_remap_tree()