Lines Matching refs:trans

77 static int update_block_group(struct btrfs_trans_handle *trans,
80 static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
90 static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans,
95 static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans,
101 static int do_chunk_alloc(struct btrfs_trans_handle *trans,
743 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans, in btrfs_lookup_extent_info() argument
771 if (!trans) { in btrfs_lookup_extent_info()
784 ret = btrfs_search_slot(trans, root->fs_info->extent_root, in btrfs_lookup_extent_info()
829 if (!trans) in btrfs_lookup_extent_info()
832 delayed_refs = &trans->transaction->delayed_refs; in btrfs_lookup_extent_info()
834 head = btrfs_find_delayed_ref_head(trans, bytenr); in btrfs_lookup_extent_info()
980 static int convert_extent_item_v0(struct btrfs_trans_handle *trans, in convert_extent_item_v0() argument
1032 ret = btrfs_search_slot(trans, root, &key, path, in convert_extent_item_v0()
1096 static noinline int lookup_extent_data_ref(struct btrfs_trans_handle *trans, in lookup_extent_data_ref() argument
1122 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in lookup_extent_data_ref()
1134 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in lookup_extent_data_ref()
1183 static noinline int insert_extent_data_ref(struct btrfs_trans_handle *trans, in insert_extent_data_ref() argument
1208 ret = btrfs_insert_empty_item(trans, root, path, &key, size); in insert_extent_data_ref()
1234 ret = btrfs_insert_empty_item(trans, root, path, &key, in insert_extent_data_ref()
1262 static noinline int remove_extent_data_ref(struct btrfs_trans_handle *trans, in remove_extent_data_ref() argument
1300 ret = btrfs_del_item(trans, root, path); in remove_extent_data_ref()
1362 static noinline int lookup_tree_block_ref(struct btrfs_trans_handle *trans, in lookup_tree_block_ref() argument
1380 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in lookup_tree_block_ref()
1387 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in lookup_tree_block_ref()
1395 static noinline int insert_tree_block_ref(struct btrfs_trans_handle *trans, in insert_tree_block_ref() argument
1413 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); in insert_tree_block_ref()
1470 int lookup_inline_extent_backref(struct btrfs_trans_handle *trans, in lookup_inline_extent_backref() argument
1515 ret = btrfs_search_slot(trans, root, &key, path, extra_size, 1); in lookup_inline_extent_backref()
1561 ret = convert_extent_item_v0(trans, root, path, owner, in lookup_inline_extent_backref()
1723 static int lookup_extent_backref(struct btrfs_trans_handle *trans, in lookup_extent_backref() argument
1732 ret = lookup_inline_extent_backref(trans, root, path, ref_ret, in lookup_extent_backref()
1742 ret = lookup_tree_block_ref(trans, root, path, bytenr, parent, in lookup_extent_backref()
1745 ret = lookup_extent_data_ref(trans, root, path, bytenr, parent, in lookup_extent_backref()
1819 int insert_inline_extent_backref(struct btrfs_trans_handle *trans, in insert_inline_extent_backref() argument
1830 ret = lookup_inline_extent_backref(trans, root, path, &iref, in insert_inline_extent_backref()
1846 static int insert_extent_backref(struct btrfs_trans_handle *trans, in insert_extent_backref() argument
1855 ret = insert_tree_block_ref(trans, root, path, bytenr, in insert_extent_backref()
1858 ret = insert_extent_data_ref(trans, root, path, bytenr, in insert_extent_backref()
1865 static int remove_extent_backref(struct btrfs_trans_handle *trans, in remove_extent_backref() argument
1878 ret = remove_extent_data_ref(trans, root, path, refs_to_drop, in remove_extent_backref()
1882 ret = btrfs_del_item(trans, root, path); in remove_extent_backref()
1942 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, in btrfs_inc_extent_ref() argument
1955 ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr, in btrfs_inc_extent_ref()
1960 ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr, in btrfs_inc_extent_ref()
1968 static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, in __btrfs_inc_extent_ref() argument
1995 ret = insert_inline_extent_backref(trans, fs_info->extent_root, path, in __btrfs_inc_extent_ref()
2015 ret = btrfs_qgroup_record_ref(trans, fs_info, root_objectid, in __btrfs_inc_extent_ref()
2039 ret = btrfs_qgroup_record_ref(trans, fs_info, root_objectid, in __btrfs_inc_extent_ref()
2048 ret = insert_extent_backref(trans, root->fs_info->extent_root, in __btrfs_inc_extent_ref()
2052 btrfs_abort_transaction(trans, root, ret); in __btrfs_inc_extent_ref()
2058 static int run_delayed_data_ref(struct btrfs_trans_handle *trans, in run_delayed_data_ref() argument
2085 ret = alloc_reserved_file_extent(trans, root, in run_delayed_data_ref()
2090 ret = __btrfs_inc_extent_ref(trans, root, node->bytenr, in run_delayed_data_ref()
2096 ret = __btrfs_free_extent(trans, root, node->bytenr, in run_delayed_data_ref()
2125 static int run_delayed_extent_op(struct btrfs_trans_handle *trans, in run_delayed_extent_op() argument
2139 if (trans->aborted) in run_delayed_extent_op()
2162 ret = btrfs_search_slot(trans, root->fs_info->extent_root, &key, in run_delayed_extent_op()
2198 ret = convert_extent_item_v0(trans, root->fs_info->extent_root, in run_delayed_extent_op()
2218 static int run_delayed_tree_ref(struct btrfs_trans_handle *trans, in run_delayed_tree_ref() argument
2251 ret = alloc_reserved_tree_block(trans, root, in run_delayed_tree_ref()
2258 ret = __btrfs_inc_extent_ref(trans, root, node->bytenr, in run_delayed_tree_ref()
2263 ret = __btrfs_free_extent(trans, root, node->bytenr, in run_delayed_tree_ref()
2274 static int run_one_delayed_ref(struct btrfs_trans_handle *trans, in run_one_delayed_ref() argument
2282 if (trans->aborted) { in run_one_delayed_ref()
2305 ret = btrfs_del_csums(trans, root, in run_one_delayed_ref()
2315 ret = run_delayed_tree_ref(trans, root, node, extent_op, in run_one_delayed_ref()
2319 ret = run_delayed_data_ref(trans, root, node, extent_op, in run_one_delayed_ref()
2354 static noinline int __btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, in __btrfs_run_delayed_refs() argument
2369 delayed_refs = &trans->transaction->delayed_refs; in __btrfs_run_delayed_refs()
2376 locked_ref = btrfs_select_ref_head(trans); in __btrfs_run_delayed_refs()
2384 ret = btrfs_delayed_ref_lock(trans, locked_ref); in __btrfs_run_delayed_refs()
2407 btrfs_merge_delayed_refs(trans, fs_info, delayed_refs, in __btrfs_run_delayed_refs()
2456 ret = run_delayed_extent_op(trans, root, in __btrfs_run_delayed_refs()
2522 ret = run_one_delayed_ref(trans, root, ref, extent_op, in __btrfs_run_delayed_refs()
2654 int btrfs_check_space_for_delayed_refs(struct btrfs_trans_handle *trans, in btrfs_check_space_for_delayed_refs() argument
2658 u64 num_heads = trans->transaction->delayed_refs.num_heads_ready; in btrfs_check_space_for_delayed_refs()
2659 u64 csum_bytes = trans->transaction->delayed_refs.pending_csums; in btrfs_check_space_for_delayed_refs()
2660 u64 num_dirty_bgs = trans->transaction->num_dirty_bgs; in btrfs_check_space_for_delayed_refs()
2690 int btrfs_should_throttle_delayed_refs(struct btrfs_trans_handle *trans, in btrfs_should_throttle_delayed_refs() argument
2695 atomic_read(&trans->transaction->delayed_refs.num_entries); in btrfs_should_throttle_delayed_refs()
2707 return btrfs_check_space_for_delayed_refs(trans, root); in btrfs_should_throttle_delayed_refs()
2722 struct btrfs_trans_handle *trans; in delayed_ref_async_start() local
2727 trans = btrfs_join_transaction(async->root); in delayed_ref_async_start()
2728 if (IS_ERR(trans)) { in delayed_ref_async_start()
2729 async->error = PTR_ERR(trans); in delayed_ref_async_start()
2737 trans->sync = true; in delayed_ref_async_start()
2738 ret = btrfs_run_delayed_refs(trans, async->root, async->count); in delayed_ref_async_start()
2742 ret = btrfs_end_transaction(trans, async->root); in delayed_ref_async_start()
2795 int btrfs_run_delayed_refs(struct btrfs_trans_handle *trans, in btrfs_run_delayed_refs() argument
2805 if (trans->aborted) in btrfs_run_delayed_refs()
2811 delayed_refs = &trans->transaction->delayed_refs; in btrfs_run_delayed_refs()
2819 ret = __btrfs_run_delayed_refs(trans, root, count); in btrfs_run_delayed_refs()
2821 btrfs_abort_transaction(trans, root, ret); in btrfs_run_delayed_refs()
2826 if (!list_empty(&trans->new_bgs)) in btrfs_run_delayed_refs()
2827 btrfs_create_pending_block_groups(trans, root); in btrfs_run_delayed_refs()
2867 ret = btrfs_delayed_qgroup_accounting(trans, root->fs_info); in btrfs_run_delayed_refs()
2870 assert_qgroups_uptodate(trans); in btrfs_run_delayed_refs()
2874 int btrfs_set_disk_extent_flags(struct btrfs_trans_handle *trans, in btrfs_set_disk_extent_flags() argument
2892 ret = btrfs_add_delayed_extent_op(root->fs_info, trans, bytenr, in btrfs_set_disk_extent_flags()
2899 static noinline int check_delayed_ref(struct btrfs_trans_handle *trans, in check_delayed_ref() argument
2911 delayed_refs = &trans->transaction->delayed_refs; in check_delayed_ref()
2913 head = btrfs_find_delayed_ref_head(trans, bytenr); in check_delayed_ref()
2966 static noinline int check_committed_ref(struct btrfs_trans_handle *trans, in check_committed_ref() argument
3037 int btrfs_cross_ref_exist(struct btrfs_trans_handle *trans, in btrfs_cross_ref_exist() argument
3050 ret = check_committed_ref(trans, root, path, objectid, in btrfs_cross_ref_exist()
3055 ret2 = check_delayed_ref(trans, root, path, objectid, in btrfs_cross_ref_exist()
3073 static int __btrfs_mod_ref(struct btrfs_trans_handle *trans, in __btrfs_mod_ref() argument
3128 ret = process_func(trans, root, bytenr, num_bytes, in __btrfs_mod_ref()
3136 ret = process_func(trans, root, bytenr, num_bytes, in __btrfs_mod_ref()
3148 int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, in btrfs_inc_ref() argument
3151 return __btrfs_mod_ref(trans, root, buf, full_backref, 1); in btrfs_inc_ref()
3154 int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, in btrfs_dec_ref() argument
3157 return __btrfs_mod_ref(trans, root, buf, full_backref, 0); in btrfs_dec_ref()
3160 static int write_one_cache_group(struct btrfs_trans_handle *trans, in write_one_cache_group() argument
3170 ret = btrfs_search_slot(trans, extent_root, &cache->key, path, 0, 1); in write_one_cache_group()
3218 struct btrfs_trans_handle *trans, in cache_save_setup() argument
3240 if (trans->aborted) in cache_save_setup()
3257 ret = create_free_space_inode(root, trans, block_group, path); in cache_save_setup()
3264 if (block_group->cache_generation == trans->transid && in cache_save_setup()
3276 ret = btrfs_update_inode(trans, root, inode); in cache_save_setup()
3288 btrfs_abort_transaction(trans, root, ret); in cache_save_setup()
3299 ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode); in cache_save_setup()
3335 ret = btrfs_prealloc_file_range_trans(inode, trans, 0, 0, num_pages, in cache_save_setup()
3349 block_group->cache_generation = trans->transid; in cache_save_setup()
3356 int btrfs_setup_space_cache(struct btrfs_trans_handle *trans, in btrfs_setup_space_cache() argument
3360 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_setup_space_cache()
3375 cache_save_setup(cache, trans, path); in btrfs_setup_space_cache()
3394 int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans, in btrfs_start_dirty_block_groups() argument
3398 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_start_dirty_block_groups()
3420 btrfs_create_pending_block_groups(trans, root); in btrfs_start_dirty_block_groups()
3433 mutex_lock(&trans->transaction->cache_write_mutex); in btrfs_start_dirty_block_groups()
3445 btrfs_wait_cache_io(root, trans, cache, in btrfs_start_dirty_block_groups()
3466 cache_save_setup(cache, trans, path); in btrfs_start_dirty_block_groups()
3470 ret = btrfs_write_out_cache(root, trans, cache, path); in btrfs_start_dirty_block_groups()
3489 ret = write_one_cache_group(trans, root, path, cache); in btrfs_start_dirty_block_groups()
3509 btrfs_abort_transaction(trans, root, ret); in btrfs_start_dirty_block_groups()
3525 mutex_unlock(&trans->transaction->cache_write_mutex); in btrfs_start_dirty_block_groups()
3526 mutex_lock(&trans->transaction->cache_write_mutex); in btrfs_start_dirty_block_groups()
3528 mutex_unlock(&trans->transaction->cache_write_mutex); in btrfs_start_dirty_block_groups()
3534 ret = btrfs_run_delayed_refs(trans, root, 0); in btrfs_start_dirty_block_groups()
3554 int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans, in btrfs_write_dirty_block_groups() argument
3558 struct btrfs_transaction *cur_trans = trans->transaction; in btrfs_write_dirty_block_groups()
3587 btrfs_wait_cache_io(root, trans, cache, in btrfs_write_dirty_block_groups()
3600 cache_save_setup(cache, trans, path); in btrfs_write_dirty_block_groups()
3603 ret = btrfs_run_delayed_refs(trans, root, (unsigned long) -1); in btrfs_write_dirty_block_groups()
3607 ret = btrfs_write_out_cache(root, trans, cache, path); in btrfs_write_dirty_block_groups()
3621 ret = write_one_cache_group(trans, root, path, cache); in btrfs_write_dirty_block_groups()
3623 btrfs_abort_transaction(trans, root, ret); in btrfs_write_dirty_block_groups()
3635 btrfs_wait_cache_io(root, trans, cache, in btrfs_write_dirty_block_groups()
3916 struct btrfs_trans_handle *trans; in btrfs_check_data_free_space() local
3939 trans = btrfs_join_transaction(root); in btrfs_check_data_free_space()
3940 if (IS_ERR(trans)) in btrfs_check_data_free_space()
3941 return PTR_ERR(trans); in btrfs_check_data_free_space()
3943 ret = do_chunk_alloc(trans, root->fs_info->extent_root, in btrfs_check_data_free_space()
3946 btrfs_end_transaction(trans, root); in btrfs_check_data_free_space()
3983 trans = btrfs_join_transaction(root); in btrfs_check_data_free_space()
3984 if (IS_ERR(trans)) in btrfs_check_data_free_space()
3985 return PTR_ERR(trans); in btrfs_check_data_free_space()
3987 trans->transaction->have_free_bgs || in btrfs_check_data_free_space()
3989 ret = btrfs_commit_transaction(trans, root); in btrfs_check_data_free_space()
4001 btrfs_end_transaction(trans, root); in btrfs_check_data_free_space()
4115 static void check_system_chunk(struct btrfs_trans_handle *trans, in check_system_chunk() argument
4139 btrfs_alloc_chunk(trans, root, flags); in check_system_chunk()
4143 static int do_chunk_alloc(struct btrfs_trans_handle *trans, in do_chunk_alloc() argument
4152 if (trans->allocating_chunk) in do_chunk_alloc()
4201 trans->allocating_chunk = true; in do_chunk_alloc()
4226 check_system_chunk(trans, extent_root, flags); in do_chunk_alloc()
4228 ret = btrfs_alloc_chunk(trans, extent_root, flags); in do_chunk_alloc()
4229 trans->allocating_chunk = false; in do_chunk_alloc()
4348 struct btrfs_trans_handle *trans; in shrink_delalloc() local
4361 trans = (struct btrfs_trans_handle *)current->journal_info; in shrink_delalloc()
4368 if (trans) in shrink_delalloc()
4397 if (!trans) in shrink_delalloc()
4409 if (wait_ordered && !trans) { in shrink_delalloc()
4436 struct btrfs_trans_handle *trans; in may_commit_transaction() local
4438 trans = (struct btrfs_trans_handle *)current->journal_info; in may_commit_transaction()
4439 if (trans) in may_commit_transaction()
4466 trans = btrfs_join_transaction(root); in may_commit_transaction()
4467 if (IS_ERR(trans)) in may_commit_transaction()
4470 return btrfs_commit_transaction(trans, root); in may_commit_transaction()
4486 struct btrfs_trans_handle *trans; in flush_space() local
4498 trans = btrfs_join_transaction(root); in flush_space()
4499 if (IS_ERR(trans)) { in flush_space()
4500 ret = PTR_ERR(trans); in flush_space()
4503 ret = btrfs_run_delayed_items_nr(trans, root, nr); in flush_space()
4504 btrfs_end_transaction(trans, root); in flush_space()
4512 trans = btrfs_join_transaction(root); in flush_space()
4513 if (IS_ERR(trans)) { in flush_space()
4514 ret = PTR_ERR(trans); in flush_space()
4517 ret = do_chunk_alloc(trans, root->fs_info->extent_root, in flush_space()
4520 btrfs_end_transaction(trans, root); in flush_space()
4816 const struct btrfs_trans_handle *trans, in get_block_rsv() argument
4822 block_rsv = trans->block_rsv; in get_block_rsv()
4824 if (root == root->fs_info->csum_root && trans->adding_csums) in get_block_rsv()
4825 block_rsv = trans->block_rsv; in get_block_rsv()
4828 block_rsv = trans->block_rsv; in get_block_rsv()
5182 void btrfs_trans_release_metadata(struct btrfs_trans_handle *trans, in btrfs_trans_release_metadata() argument
5185 if (!trans->block_rsv) in btrfs_trans_release_metadata()
5188 if (!trans->bytes_reserved) in btrfs_trans_release_metadata()
5192 trans->transid, trans->bytes_reserved, 0); in btrfs_trans_release_metadata()
5193 btrfs_block_rsv_release(root, trans->block_rsv, trans->bytes_reserved); in btrfs_trans_release_metadata()
5194 trans->bytes_reserved = 0; in btrfs_trans_release_metadata()
5198 int btrfs_orphan_reserve_metadata(struct btrfs_trans_handle *trans, in btrfs_orphan_reserve_metadata() argument
5202 struct btrfs_block_rsv *src_rsv = get_block_rsv(trans, root); in btrfs_orphan_reserve_metadata()
5615 static int update_block_group(struct btrfs_trans_handle *trans, in update_block_group() argument
5704 spin_lock(&trans->transaction->dirty_bgs_lock); in update_block_group()
5707 &trans->transaction->dirty_bgs); in update_block_group()
5708 trans->transaction->num_dirty_bgs++; in update_block_group()
5711 spin_unlock(&trans->transaction->dirty_bgs_lock); in update_block_group()
5945 void btrfs_prepare_extent_commit(struct btrfs_trans_handle *trans, in btrfs_prepare_extent_commit() argument
6039 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans, in btrfs_finish_extent_commit() argument
6048 if (trans->aborted) in btrfs_finish_extent_commit()
6099 static int __btrfs_free_extent(struct btrfs_trans_handle *trans, in __btrfs_free_extent() argument
6142 ret = lookup_extent_backref(trans, extent_root, path, &iref, in __btrfs_free_extent()
6174 ret = remove_extent_backref(trans, extent_root, path, in __btrfs_free_extent()
6178 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6193 ret = btrfs_search_slot(trans, extent_root, in __btrfs_free_extent()
6215 ret = btrfs_search_slot(trans, extent_root, in __btrfs_free_extent()
6227 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6238 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6241 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6250 ret = convert_extent_item_v0(trans, extent_root, path, in __btrfs_free_extent()
6253 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6264 ret = btrfs_search_slot(trans, extent_root, &key, path, in __btrfs_free_extent()
6272 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6297 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6317 ret = remove_extent_backref(trans, extent_root, path, in __btrfs_free_extent()
6321 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6341 ret = btrfs_del_items(trans, extent_root, path, path->slots[0], in __btrfs_free_extent()
6344 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6350 ret = btrfs_del_csums(trans, root, bytenr, num_bytes); in __btrfs_free_extent()
6352 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6357 ret = update_block_group(trans, root, bytenr, num_bytes, 0); in __btrfs_free_extent()
6359 btrfs_abort_transaction(trans, extent_root, ret); in __btrfs_free_extent()
6373 ret = btrfs_qgroup_record_ref(trans, info, root_objectid, in __btrfs_free_extent()
6388 static noinline int check_ref_cleanup(struct btrfs_trans_handle *trans, in check_ref_cleanup() argument
6395 delayed_refs = &trans->transaction->delayed_refs; in check_ref_cleanup()
6397 head = btrfs_find_delayed_ref_head(trans, bytenr); in check_ref_cleanup()
6454 void btrfs_free_tree_block(struct btrfs_trans_handle *trans, in btrfs_free_tree_block() argument
6463 ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, in btrfs_free_tree_block()
6474 if (btrfs_header_generation(buf) == trans->transid) { in btrfs_free_tree_block()
6478 ret = check_ref_cleanup(trans, root, buf->start); in btrfs_free_tree_block()
6513 int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, in btrfs_free_extent() argument
6535 ret = btrfs_add_delayed_tree_ref(fs_info, trans, bytenr, in btrfs_free_extent()
6540 ret = btrfs_add_delayed_data_ref(fs_info, trans, bytenr, in btrfs_free_extent()
7084 struct btrfs_trans_handle *trans; in find_free_extent() local
7087 trans = current->journal_info; in find_free_extent()
7088 if (trans) in find_free_extent()
7091 trans = btrfs_join_transaction(root); in find_free_extent()
7093 if (IS_ERR(trans)) { in find_free_extent()
7094 ret = PTR_ERR(trans); in find_free_extent()
7098 ret = do_chunk_alloc(trans, root, flags, in find_free_extent()
7105 btrfs_abort_transaction(trans, in find_free_extent()
7110 btrfs_end_transaction(trans, root); in find_free_extent()
7251 static int alloc_reserved_file_extent(struct btrfs_trans_handle *trans, in alloc_reserved_file_extent() argument
7278 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, in alloc_reserved_file_extent()
7289 btrfs_set_extent_generation(leaf, extent_item, trans->transid); in alloc_reserved_file_extent()
7313 ret = btrfs_qgroup_record_ref(trans, fs_info, root_objectid, in alloc_reserved_file_extent()
7319 ret = update_block_group(trans, root, ins->objectid, ins->offset, 1); in alloc_reserved_file_extent()
7329 static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, in alloc_reserved_tree_block() argument
7359 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, in alloc_reserved_tree_block()
7372 btrfs_set_extent_generation(leaf, extent_item, trans->transid); in alloc_reserved_tree_block()
7401 ret = btrfs_qgroup_record_ref(trans, fs_info, root_objectid, in alloc_reserved_tree_block()
7408 ret = update_block_group(trans, root, ins->objectid, root->nodesize, in alloc_reserved_tree_block()
7420 int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, in btrfs_alloc_reserved_file_extent() argument
7429 ret = btrfs_add_delayed_data_ref(root->fs_info, trans, ins->objectid, in btrfs_alloc_reserved_file_extent()
7441 int btrfs_alloc_logged_file_extent(struct btrfs_trans_handle *trans, in btrfs_alloc_logged_file_extent() argument
7466 ret = alloc_reserved_file_extent(trans, root, 0, root_objectid, in btrfs_alloc_logged_file_extent()
7473 btrfs_init_new_buffer(struct btrfs_trans_handle *trans, struct btrfs_root *root, in btrfs_init_new_buffer() argument
7481 btrfs_set_header_generation(buf, trans->transid); in btrfs_init_new_buffer()
7484 clean_tree_block(trans, root->fs_info, buf); in btrfs_init_new_buffer()
7504 set_extent_dirty(&trans->transaction->dirty_pages, buf->start, in btrfs_init_new_buffer()
7507 trans->blocks_used++; in btrfs_init_new_buffer()
7513 use_block_rsv(struct btrfs_trans_handle *trans, in use_block_rsv() argument
7521 block_rsv = get_block_rsv(trans, root); in use_block_rsv()
7580 struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans, in btrfs_alloc_tree_block() argument
7597 buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr, in btrfs_alloc_tree_block()
7604 block_rsv = use_block_rsv(trans, root, blocksize); in btrfs_alloc_tree_block()
7613 buf = btrfs_init_new_buffer(trans, root, ins.objectid, level); in btrfs_alloc_tree_block()
7645 ret = btrfs_add_delayed_tree_ref(root->fs_info, trans, in btrfs_alloc_tree_block()
7683 static noinline void reada_walk_down(struct btrfs_trans_handle *trans, in reada_walk_down() argument
7729 ret = btrfs_lookup_extent_info(trans, root, bytenr, in reada_walk_down()
7764 static int account_leaf_items(struct btrfs_trans_handle *trans, in account_leaf_items() argument
7793 ret = btrfs_qgroup_record_ref(trans, root->fs_info, in account_leaf_items()
7868 static int account_shared_subtree(struct btrfs_trans_handle *trans, in account_shared_subtree() argument
7892 ret = account_leaf_items(trans, root, root_eb); in account_shared_subtree()
7941 ret = btrfs_qgroup_record_ref(trans, root->fs_info, in account_shared_subtree()
7953 ret = account_leaf_items(trans, root, path->nodes[level]); in account_shared_subtree()
7984 static noinline int walk_down_proc(struct btrfs_trans_handle *trans, in walk_down_proc() argument
8006 ret = btrfs_lookup_extent_info(trans, root, in walk_down_proc()
8030 ret = btrfs_inc_ref(trans, root, eb, 1); in walk_down_proc()
8032 ret = btrfs_dec_ref(trans, root, eb, 0); in walk_down_proc()
8034 ret = btrfs_set_disk_extent_flags(trans, root, eb->start, in walk_down_proc()
8065 static noinline int do_walk_down(struct btrfs_trans_handle *trans, in do_walk_down() argument
8109 ret = btrfs_lookup_extent_info(trans, root, bytenr, level - 1, 1, in do_walk_down()
8158 reada_walk_down(trans, root, wc, path); in do_walk_down()
8190 ret = account_shared_subtree(trans, root, next, in do_walk_down()
8199 ret = btrfs_free_extent(trans, root, bytenr, blocksize, parent, in do_walk_down()
8221 static noinline int walk_up_proc(struct btrfs_trans_handle *trans, in walk_up_proc() argument
8255 ret = btrfs_lookup_extent_info(trans, root, in walk_up_proc()
8279 ret = btrfs_dec_ref(trans, root, eb, 1); in walk_up_proc()
8281 ret = btrfs_dec_ref(trans, root, eb, 0); in walk_up_proc()
8283 ret = account_leaf_items(trans, root, eb); in walk_up_proc()
8293 btrfs_header_generation(eb) == trans->transid) { in walk_up_proc()
8298 clean_tree_block(trans, root->fs_info, eb); in walk_up_proc()
8315 btrfs_free_tree_block(trans, root, eb, parent, wc->refs[level] == 1); in walk_up_proc()
8322 static noinline int walk_down_tree(struct btrfs_trans_handle *trans, in walk_down_tree() argument
8332 ret = walk_down_proc(trans, root, path, wc, lookup_info); in walk_down_tree()
8343 ret = do_walk_down(trans, root, path, wc, &lookup_info); in walk_down_tree()
8354 static noinline int walk_up_tree(struct btrfs_trans_handle *trans, in walk_up_tree() argument
8370 ret = walk_up_proc(trans, root, path, wc); in walk_up_tree()
8405 struct btrfs_trans_handle *trans; in btrfs_drop_snapshot() local
8430 trans = btrfs_start_transaction(tree_root, 0); in btrfs_drop_snapshot()
8431 if (IS_ERR(trans)) { in btrfs_drop_snapshot()
8432 err = PTR_ERR(trans); in btrfs_drop_snapshot()
8437 trans->block_rsv = block_rsv; in btrfs_drop_snapshot()
8475 ret = btrfs_lookup_extent_info(trans, root, in btrfs_drop_snapshot()
8505 ret = walk_down_tree(trans, root, path, wc); in btrfs_drop_snapshot()
8511 ret = walk_up_tree(trans, root, path, wc, BTRFS_MAX_LEVEL); in btrfs_drop_snapshot()
8531 if (btrfs_should_end_transaction(trans, tree_root) || in btrfs_drop_snapshot()
8533 ret = btrfs_update_root(trans, tree_root, in btrfs_drop_snapshot()
8537 btrfs_abort_transaction(trans, tree_root, ret); in btrfs_drop_snapshot()
8551 ret = btrfs_delayed_qgroup_accounting(trans, in btrfs_drop_snapshot()
8560 btrfs_end_transaction_throttle(trans, tree_root); in btrfs_drop_snapshot()
8567 trans = btrfs_start_transaction(tree_root, 0); in btrfs_drop_snapshot()
8568 if (IS_ERR(trans)) { in btrfs_drop_snapshot()
8569 err = PTR_ERR(trans); in btrfs_drop_snapshot()
8573 trans->block_rsv = block_rsv; in btrfs_drop_snapshot()
8580 ret = btrfs_del_root(trans, tree_root, &root->root_key); in btrfs_drop_snapshot()
8582 btrfs_abort_transaction(trans, tree_root, ret); in btrfs_drop_snapshot()
8590 btrfs_abort_transaction(trans, tree_root, ret); in btrfs_drop_snapshot()
8599 btrfs_del_orphan_item(trans, tree_root, in btrfs_drop_snapshot()
8613 ret = btrfs_delayed_qgroup_accounting(trans, tree_root->fs_info); in btrfs_drop_snapshot()
8621 btrfs_end_transaction_throttle(trans, tree_root); in btrfs_drop_snapshot()
8646 int btrfs_drop_subtree(struct btrfs_trans_handle *trans, in btrfs_drop_subtree() argument
8693 wret = walk_down_tree(trans, root, path, wc); in btrfs_drop_subtree()
8699 wret = walk_up_tree(trans, root, path, wc, parent_level); in btrfs_drop_subtree()
8809 struct btrfs_trans_handle *trans; in btrfs_set_block_group_ro() local
8816 trans = btrfs_join_transaction(root); in btrfs_set_block_group_ro()
8817 if (IS_ERR(trans)) in btrfs_set_block_group_ro()
8818 return PTR_ERR(trans); in btrfs_set_block_group_ro()
8826 if (trans->transaction->dirty_bg_run) { in btrfs_set_block_group_ro()
8827 u64 transid = trans->transid; in btrfs_set_block_group_ro()
8830 btrfs_end_transaction(trans, root); in btrfs_set_block_group_ro()
8844 ret = do_chunk_alloc(trans, root, alloc_flags, in btrfs_set_block_group_ro()
8861 ret = do_chunk_alloc(trans, root, alloc_flags, in btrfs_set_block_group_ro()
8870 check_system_chunk(trans, root, alloc_flags); in btrfs_set_block_group_ro()
8875 btrfs_end_transaction(trans, root); in btrfs_set_block_group_ro()
8879 int btrfs_force_chunk_alloc(struct btrfs_trans_handle *trans, in btrfs_force_chunk_alloc() argument
8883 return do_chunk_alloc(trans, root, alloc_flags, in btrfs_force_chunk_alloc()
8959 struct btrfs_trans_handle *trans; in btrfs_can_relocate() local
9047 trans = btrfs_join_transaction(root); in btrfs_can_relocate()
9048 if (IS_ERR(trans)) { in btrfs_can_relocate()
9049 ret = PTR_ERR(trans); in btrfs_can_relocate()
9063 ret = find_free_dev_extent(trans, device, min_free, in btrfs_can_relocate()
9075 btrfs_end_transaction(trans, root); in btrfs_can_relocate()
9500 void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans, in btrfs_create_pending_block_groups() argument
9509 list_for_each_entry_safe(block_group, tmp, &trans->new_bgs, bg_list) { in btrfs_create_pending_block_groups()
9518 ret = btrfs_insert_item(trans, extent_root, &key, &item, in btrfs_create_pending_block_groups()
9521 btrfs_abort_transaction(trans, extent_root, ret); in btrfs_create_pending_block_groups()
9522 ret = btrfs_finish_chunk_alloc(trans, extent_root, in btrfs_create_pending_block_groups()
9525 btrfs_abort_transaction(trans, extent_root, ret); in btrfs_create_pending_block_groups()
9531 int btrfs_make_block_group(struct btrfs_trans_handle *trans, in btrfs_make_block_group() argument
9542 btrfs_set_log_full_commit(root->fs_info, trans); in btrfs_make_block_group()
9598 list_add_tail(&cache->bg_list, &trans->new_bgs); in btrfs_make_block_group()
9620 int btrfs_remove_block_group(struct btrfs_trans_handle *trans, in btrfs_remove_block_group() argument
9685 mutex_lock(&trans->transaction->cache_write_mutex); in btrfs_remove_block_group()
9690 spin_lock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9696 spin_unlock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9697 btrfs_wait_cache_io(root, trans, block_group, in btrfs_remove_block_group()
9701 spin_lock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9708 spin_unlock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9709 mutex_unlock(&trans->transaction->cache_write_mutex); in btrfs_remove_block_group()
9712 ret = btrfs_orphan_add(trans, inode); in btrfs_remove_block_group()
9736 ret = btrfs_search_slot(trans, tree_root, &key, path, -1, 1); in btrfs_remove_block_group()
9742 ret = btrfs_del_item(trans, tree_root, path); in btrfs_remove_block_group()
9801 spin_lock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9808 spin_unlock(&trans->transaction->dirty_bgs_lock); in btrfs_remove_block_group()
9898 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_remove_block_group()
9904 ret = btrfs_del_item(trans, root, path); in btrfs_remove_block_group()
9919 struct btrfs_trans_handle *trans; in btrfs_delete_unused_bgs() local
9971 trans = btrfs_start_transaction(root, 1); in btrfs_delete_unused_bgs()
9972 if (IS_ERR(trans)) { in btrfs_delete_unused_bgs()
9974 ret = PTR_ERR(trans); in btrfs_delete_unused_bgs()
10029 ret = btrfs_remove_chunk(trans, root, in btrfs_delete_unused_bgs()
10032 btrfs_end_transaction(trans, root); in btrfs_delete_unused_bgs()