Lines Matching refs:trans
470 static int update_backref_cache(struct btrfs_trans_handle *trans, in update_backref_cache() argument
477 cache->last_trans = trans->transid; in update_backref_cache()
481 if (cache->last_trans == trans->transid) in update_backref_cache()
1201 static int clone_backref_node(struct btrfs_trans_handle *trans, in clone_backref_node() argument
1215 update_backref_cache(trans, cache); in clone_backref_node()
1382 static struct btrfs_root *create_reloc_root(struct btrfs_trans_handle *trans, in create_reloc_root() argument
1403 ret = btrfs_copy_root(trans, root, root->commit_root, &eb, in create_reloc_root()
1424 ret = btrfs_copy_root(trans, root, root->node, &eb, in create_reloc_root()
1432 btrfs_set_root_generation(root_item, trans->transid); in create_reloc_root()
1444 ret = btrfs_insert_root(trans, fs_info->tree_root, in create_reloc_root()
1451 reloc_root->last_trans = trans->transid; in create_reloc_root()
1459 int btrfs_init_reloc_root(struct btrfs_trans_handle *trans, in btrfs_init_reloc_root() argument
1489 reloc_root->last_trans = trans->transid; in btrfs_init_reloc_root()
1501 if (!trans->reloc_reserved) { in btrfs_init_reloc_root()
1502 rsv = trans->block_rsv; in btrfs_init_reloc_root()
1503 trans->block_rsv = rc->block_rsv; in btrfs_init_reloc_root()
1506 reloc_root = create_reloc_root(trans, root, root->root_key.objectid); in btrfs_init_reloc_root()
1508 trans->block_rsv = rsv; in btrfs_init_reloc_root()
1519 int btrfs_update_reloc_root(struct btrfs_trans_handle *trans, in btrfs_update_reloc_root() argument
1552 ret = btrfs_update_root(trans, fs_info->tree_root, in btrfs_update_reloc_root()
1675 int replace_file_extents(struct btrfs_trans_handle *trans, in replace_file_extents() argument
1773 ret = btrfs_inc_extent_ref(trans, &ref); in replace_file_extents()
1775 btrfs_abort_transaction(trans, ret); in replace_file_extents()
1784 ret = btrfs_free_extent(trans, &ref); in replace_file_extents()
1786 btrfs_abort_transaction(trans, ret); in replace_file_extents()
1818 int replace_path(struct btrfs_trans_handle *trans, struct reloc_control *rc, in replace_path() argument
1858 ret = btrfs_cow_block(trans, dest, eb, NULL, 0, &eb); in replace_path()
1925 ret = btrfs_cow_block(trans, dest, eb, parent, in replace_path()
1950 ret = btrfs_search_slot(trans, src, &key, path, 0, 1); in replace_path()
1968 ret = btrfs_qgroup_add_swapped_blocks(trans, dest, in replace_path()
1991 ret = btrfs_inc_extent_ref(trans, &ref); in replace_path()
1997 ret = btrfs_inc_extent_ref(trans, &ref); in replace_path()
2004 ret = btrfs_free_extent(trans, &ref); in replace_path()
2011 ret = btrfs_free_extent(trans, &ref); in replace_path()
2211 static void insert_dirty_subvol(struct btrfs_trans_handle *trans, in insert_dirty_subvol() argument
2227 btrfs_update_reloc_root(trans, root); in insert_dirty_subvol()
2283 struct btrfs_trans_handle *trans = NULL; in merge_reloc_root() local
2348 trans = btrfs_start_transaction(root, 0); in merge_reloc_root()
2349 if (IS_ERR(trans)) { in merge_reloc_root()
2350 err = PTR_ERR(trans); in merge_reloc_root()
2351 trans = NULL; in merge_reloc_root()
2365 reloc_root->last_trans = trans->transid; in merge_reloc_root()
2366 trans->block_rsv = rc->block_rsv; in merge_reloc_root()
2383 ret = replace_path(trans, rc, root, reloc_root, path, in merge_reloc_root()
2411 btrfs_end_transaction_throttle(trans); in merge_reloc_root()
2412 trans = NULL; in merge_reloc_root()
2425 ret = btrfs_cow_block(trans, root, leaf, NULL, 0, &leaf); in merge_reloc_root()
2434 insert_dirty_subvol(trans, rc, root); in merge_reloc_root()
2436 if (trans) in merge_reloc_root()
2437 btrfs_end_transaction_throttle(trans); in merge_reloc_root()
2453 struct btrfs_trans_handle *trans; in prepare_to_merge() local
2472 trans = btrfs_join_transaction(rc->extent_root); in prepare_to_merge()
2473 if (IS_ERR(trans)) { in prepare_to_merge()
2477 return PTR_ERR(trans); in prepare_to_merge()
2482 btrfs_end_transaction(trans); in prepare_to_merge()
2506 btrfs_update_reloc_root(trans, root); in prepare_to_merge()
2514 err = btrfs_commit_transaction(trans); in prepare_to_merge()
2516 btrfs_end_transaction(trans); in prepare_to_merge()
2635 static int record_reloc_root_in_trans(struct btrfs_trans_handle *trans, in record_reloc_root_in_trans() argument
2641 if (reloc_root->last_trans == trans->transid) in record_reloc_root_in_trans()
2648 return btrfs_record_root_in_trans(trans, root); in record_reloc_root_in_trans()
2652 struct btrfs_root *select_reloc_root(struct btrfs_trans_handle *trans, in select_reloc_root() argument
2670 record_reloc_root_in_trans(trans, root); in select_reloc_root()
2674 btrfs_record_root_in_trans(trans, root); in select_reloc_root()
2784 static int reserve_metadata_space(struct btrfs_trans_handle *trans, in reserve_metadata_space() argument
2796 trans->block_rsv = rc->block_rsv; in reserve_metadata_space()
2832 static int do_relocation(struct btrfs_trans_handle *trans, in do_relocation() argument
2862 root = select_reloc_root(trans, rc, upper, edges); in do_relocation()
2882 ret = btrfs_search_slot(trans, root, key, path, 0, 1); in do_relocation()
2947 ret = btrfs_cow_block(trans, root, eb, upper->eb, in do_relocation()
2960 trans->transid); in do_relocation()
2969 ret = btrfs_inc_extent_ref(trans, &ref); in do_relocation()
2972 ret = btrfs_drop_subtree(trans, root, eb, upper->eb); in do_relocation()
2995 static int link_to_upper(struct btrfs_trans_handle *trans, in link_to_upper() argument
3003 return do_relocation(trans, rc, node, &key, path, 0); in link_to_upper()
3006 static int finish_pending_nodes(struct btrfs_trans_handle *trans, in finish_pending_nodes() argument
3024 ret = link_to_upper(trans, rc, node, path); in finish_pending_nodes()
3121 static int relocate_tree_block(struct btrfs_trans_handle *trans, in relocate_tree_block() argument
3141 ret = reserve_metadata_space(trans, rc, node); in relocate_tree_block()
3150 btrfs_record_root_in_trans(trans, root); in relocate_tree_block()
3157 ret = btrfs_search_slot(trans, root, key, path, 0, 1); in relocate_tree_block()
3165 ret = do_relocation(trans, rc, node, key, path, 1); in relocate_tree_block()
3177 int relocate_tree_blocks(struct btrfs_trans_handle *trans, in relocate_tree_blocks() argument
3218 ret = relocate_tree_block(trans, rc, node, &block->key, in relocate_tree_blocks()
3226 err = finish_pending_nodes(trans, rc, path, err); in relocate_tree_blocks()
3649 struct btrfs_trans_handle *trans; in delete_block_group_cache() local
3669 trans = btrfs_join_transaction(root); in delete_block_group_cache()
3670 if (IS_ERR(trans)) { in delete_block_group_cache()
3671 ret = PTR_ERR(trans); in delete_block_group_cache()
3675 ret = btrfs_truncate_free_space_cache(trans, block_group, inode); in delete_block_group_cache()
3677 btrfs_end_transaction(trans); in delete_block_group_cache()
4070 struct btrfs_trans_handle *trans; in prepare_to_relocate() local
4095 trans = btrfs_join_transaction(rc->extent_root); in prepare_to_relocate()
4096 if (IS_ERR(trans)) { in prepare_to_relocate()
4103 return PTR_ERR(trans); in prepare_to_relocate()
4106 ret = btrfs_commit_transaction(trans); in prepare_to_relocate()
4118 struct btrfs_trans_handle *trans = NULL; in relocate_block_group() local
4148 trans = btrfs_start_transaction(rc->extent_root, 0); in relocate_block_group()
4149 if (IS_ERR(trans)) { in relocate_block_group()
4150 err = PTR_ERR(trans); in relocate_block_group()
4151 trans = NULL; in relocate_block_group()
4155 if (update_backref_cache(trans, &rc->backref_cache)) { in relocate_block_group()
4156 btrfs_end_transaction(trans); in relocate_block_group()
4157 trans = NULL; in relocate_block_group()
4178 btrfs_print_v0_err(trans->fs_info); in relocate_block_group()
4179 btrfs_abort_transaction(trans, err); in relocate_block_group()
4200 ret = relocate_tree_blocks(trans, rc, &blocks); in relocate_block_group()
4211 btrfs_end_transaction_throttle(trans); in relocate_block_group()
4213 trans = NULL; in relocate_block_group()
4226 if (trans && progress && err == -ENOSPC) { in relocate_block_group()
4227 ret = btrfs_force_chunk_alloc(trans, rc->block_group->flags); in relocate_block_group()
4238 if (trans) { in relocate_block_group()
4239 btrfs_end_transaction_throttle(trans); in relocate_block_group()
4265 trans = btrfs_join_transaction(rc->extent_root); in relocate_block_group()
4266 if (IS_ERR(trans)) { in relocate_block_group()
4267 err = PTR_ERR(trans); in relocate_block_group()
4270 ret = btrfs_commit_transaction(trans); in relocate_block_group()
4282 static int __insert_orphan_inode(struct btrfs_trans_handle *trans, in __insert_orphan_inode() argument
4294 ret = btrfs_insert_empty_inode(trans, root, path, objectid); in __insert_orphan_inode()
4321 struct btrfs_trans_handle *trans; in create_reloc_inode() local
4331 trans = btrfs_start_transaction(root, 6); in create_reloc_inode()
4332 if (IS_ERR(trans)) in create_reloc_inode()
4333 return ERR_CAST(trans); in create_reloc_inode()
4339 err = __insert_orphan_inode(trans, root, objectid); in create_reloc_inode()
4349 err = btrfs_orphan_add(trans, BTRFS_I(inode)); in create_reloc_inode()
4351 btrfs_end_transaction(trans); in create_reloc_inode()
4529 struct btrfs_trans_handle *trans; in mark_garbage_root() local
4532 trans = btrfs_start_transaction(fs_info->tree_root, 0); in mark_garbage_root()
4533 if (IS_ERR(trans)) in mark_garbage_root()
4534 return PTR_ERR(trans); in mark_garbage_root()
4540 ret = btrfs_update_root(trans, fs_info->tree_root, in mark_garbage_root()
4543 err = btrfs_end_transaction(trans); in mark_garbage_root()
4565 struct btrfs_trans_handle *trans; in btrfs_recover_relocation() local
4643 trans = btrfs_join_transaction(rc->extent_root); in btrfs_recover_relocation()
4644 if (IS_ERR(trans)) { in btrfs_recover_relocation()
4645 err = PTR_ERR(trans); in btrfs_recover_relocation()
4666 btrfs_end_transaction(trans); in btrfs_recover_relocation()
4675 err = btrfs_commit_transaction(trans); in btrfs_recover_relocation()
4683 trans = btrfs_join_transaction(rc->extent_root); in btrfs_recover_relocation()
4684 if (IS_ERR(trans)) { in btrfs_recover_relocation()
4685 err = PTR_ERR(trans); in btrfs_recover_relocation()
4688 err = btrfs_commit_transaction(trans); in btrfs_recover_relocation()
4764 int btrfs_reloc_cow_block(struct btrfs_trans_handle *trans, in btrfs_reloc_cow_block() argument
4814 ret = replace_file_extents(trans, rc, root, cow); in btrfs_reloc_cow_block()
4853 int btrfs_reloc_post_snapshot(struct btrfs_trans_handle *trans, in btrfs_reloc_post_snapshot() argument
4877 reloc_root = create_reloc_root(trans, root->reloc_root, in btrfs_reloc_post_snapshot()
4887 ret = clone_backref_node(trans, rc, root, reloc_root); in btrfs_reloc_post_snapshot()