Lines Matching refs:trans
121 static int init_first_rw_device(struct btrfs_trans_handle *trans,
1406 int find_free_dev_extent(struct btrfs_trans_handle *trans, in find_free_dev_extent() argument
1411 return find_free_dev_extent_start(trans->transaction, device, in find_free_dev_extent()
1415 static int btrfs_free_dev_extent(struct btrfs_trans_handle *trans, in btrfs_free_dev_extent() argument
1435 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_dev_extent()
1461 ret = btrfs_del_item(trans, root, path); in btrfs_free_dev_extent()
1466 set_bit(BTRFS_TRANS_HAVE_FREE_BGS, &trans->transaction->flags); in btrfs_free_dev_extent()
1473 static int btrfs_alloc_dev_extent(struct btrfs_trans_handle *trans, in btrfs_alloc_dev_extent() argument
1494 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_alloc_dev_extent()
1577 static int btrfs_add_device(struct btrfs_trans_handle *trans, in btrfs_add_device() argument
1598 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_add_device()
1655 struct btrfs_trans_handle *trans; in btrfs_rm_dev_item() local
1663 trans = btrfs_start_transaction(root, 0); in btrfs_rm_dev_item()
1664 if (IS_ERR(trans)) { in btrfs_rm_dev_item()
1666 return PTR_ERR(trans); in btrfs_rm_dev_item()
1672 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_rm_dev_item()
1681 ret = btrfs_del_item(trans, root, path); in btrfs_rm_dev_item()
1686 btrfs_commit_transaction(trans, root); in btrfs_rm_dev_item()
2169 static int btrfs_finish_sprout(struct btrfs_trans_handle *trans, in btrfs_finish_sprout() argument
2192 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_finish_sprout()
2244 struct btrfs_trans_handle *trans; in btrfs_init_new_device() local
2298 trans = btrfs_start_transaction(root, 0); in btrfs_init_new_device()
2299 if (IS_ERR(trans)) { in btrfs_init_new_device()
2302 ret = PTR_ERR(trans); in btrfs_init_new_device()
2310 device->generation = trans->transid; in btrfs_init_new_device()
2373 ret = init_first_rw_device(trans, root, device); in btrfs_init_new_device()
2376 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2381 ret = btrfs_add_device(trans, root, device); in btrfs_init_new_device()
2383 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2390 ret = btrfs_finish_sprout(trans, root); in btrfs_init_new_device()
2392 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2409 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2424 trans = btrfs_attach_transaction(root); in btrfs_init_new_device()
2425 if (IS_ERR(trans)) { in btrfs_init_new_device()
2426 if (PTR_ERR(trans) == -ENOENT) in btrfs_init_new_device()
2428 return PTR_ERR(trans); in btrfs_init_new_device()
2430 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2438 btrfs_end_transaction(trans, root); in btrfs_init_new_device()
2558 static noinline int btrfs_update_device(struct btrfs_trans_handle *trans, in btrfs_update_device() argument
2578 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_update_device()
2606 int btrfs_grow_device(struct btrfs_trans_handle *trans, in btrfs_grow_device() argument
2641 return btrfs_update_device(trans, device); in btrfs_grow_device()
2644 static int btrfs_free_chunk(struct btrfs_trans_handle *trans, in btrfs_free_chunk() argument
2661 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_chunk()
2671 ret = btrfs_del_item(trans, root, path); in btrfs_free_chunk()
2728 int btrfs_remove_chunk(struct btrfs_trans_handle *trans, in btrfs_remove_chunk() argument
2761 check_system_chunk(trans, extent_root, map->type); in btrfs_remove_chunk()
2766 ret = btrfs_free_dev_extent(trans, device, in btrfs_remove_chunk()
2770 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2786 ret = btrfs_update_device(trans, map->stripes[i].dev); in btrfs_remove_chunk()
2788 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2793 ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2795 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2804 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2809 ret = btrfs_remove_block_group(trans, extent_root, chunk_offset, em); in btrfs_remove_chunk()
2811 btrfs_abort_transaction(trans, extent_root, ret); in btrfs_remove_chunk()
2824 struct btrfs_trans_handle *trans; in btrfs_relocate_chunk() local
2855 trans = btrfs_start_trans_remove_block_group(root->fs_info, in btrfs_relocate_chunk()
2857 if (IS_ERR(trans)) { in btrfs_relocate_chunk()
2858 ret = PTR_ERR(trans); in btrfs_relocate_chunk()
2867 ret = btrfs_remove_chunk(trans, root, chunk_offset); in btrfs_relocate_chunk()
2868 btrfs_end_transaction(trans, root); in btrfs_relocate_chunk()
2950 struct btrfs_trans_handle *trans; in insert_balance_item() local
2962 trans = btrfs_start_transaction(root, 0); in insert_balance_item()
2963 if (IS_ERR(trans)) { in insert_balance_item()
2965 return PTR_ERR(trans); in insert_balance_item()
2972 ret = btrfs_insert_empty_item(trans, root, path, &key, in insert_balance_item()
2994 err = btrfs_commit_transaction(trans, root); in insert_balance_item()
3002 struct btrfs_trans_handle *trans; in del_balance_item() local
3011 trans = btrfs_start_transaction(root, 0); in del_balance_item()
3012 if (IS_ERR(trans)) { in del_balance_item()
3014 return PTR_ERR(trans); in del_balance_item()
3021 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in del_balance_item()
3029 ret = btrfs_del_item(trans, root, path); in del_balance_item()
3032 err = btrfs_commit_transaction(trans, root); in del_balance_item()
3390 struct btrfs_trans_handle *trans; in __btrfs_balance() local
3422 trans = btrfs_start_transaction(dev_root, 0); in __btrfs_balance()
3423 BUG_ON(IS_ERR(trans)); in __btrfs_balance()
3425 ret = btrfs_grow_device(trans, device, old_size); in __btrfs_balance()
3428 btrfs_end_transaction(trans, dev_root); in __btrfs_balance()
3543 trans = btrfs_start_transaction(chunk_root, 0); in __btrfs_balance()
3544 if (IS_ERR(trans)) { in __btrfs_balance()
3546 ret = PTR_ERR(trans); in __btrfs_balance()
3550 ret = btrfs_force_chunk_alloc(trans, chunk_root, in __btrfs_balance()
3552 btrfs_end_transaction(trans, chunk_root); in __btrfs_balance()
3996 struct btrfs_trans_handle *trans = NULL; in btrfs_uuid_scan_kthread() local
4040 if (trans) in btrfs_uuid_scan_kthread()
4048 trans = btrfs_start_transaction(fs_info->uuid_root, 2); in btrfs_uuid_scan_kthread()
4049 if (IS_ERR(trans)) { in btrfs_uuid_scan_kthread()
4050 ret = PTR_ERR(trans); in btrfs_uuid_scan_kthread()
4059 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, in btrfs_uuid_scan_kthread()
4071 ret = btrfs_uuid_tree_add(trans, fs_info->uuid_root, in btrfs_uuid_scan_kthread()
4083 if (trans) { in btrfs_uuid_scan_kthread()
4084 ret = btrfs_end_transaction(trans, fs_info->uuid_root); in btrfs_uuid_scan_kthread()
4085 trans = NULL; in btrfs_uuid_scan_kthread()
4108 if (trans && !IS_ERR(trans)) in btrfs_uuid_scan_kthread()
4109 btrfs_end_transaction(trans, fs_info->uuid_root); in btrfs_uuid_scan_kthread()
4184 struct btrfs_trans_handle *trans; in btrfs_create_uuid_tree() local
4194 trans = btrfs_start_transaction(tree_root, 2); in btrfs_create_uuid_tree()
4195 if (IS_ERR(trans)) in btrfs_create_uuid_tree()
4196 return PTR_ERR(trans); in btrfs_create_uuid_tree()
4198 uuid_root = btrfs_create_tree(trans, fs_info, in btrfs_create_uuid_tree()
4202 btrfs_abort_transaction(trans, tree_root, ret); in btrfs_create_uuid_tree()
4208 ret = btrfs_commit_transaction(trans, tree_root); in btrfs_create_uuid_tree()
4247 struct btrfs_trans_handle *trans; in btrfs_shrink_device() local
4349 trans = btrfs_start_transaction(root, 0); in btrfs_shrink_device()
4350 if (IS_ERR(trans)) { in btrfs_shrink_device()
4351 ret = PTR_ERR(trans); in btrfs_shrink_device()
4373 if (contains_pending_extent(trans->transaction, device, in btrfs_shrink_device()
4379 ret = btrfs_commit_transaction(trans, root); in btrfs_shrink_device()
4396 ret = btrfs_update_device(trans, device); in btrfs_shrink_device()
4397 btrfs_end_transaction(trans, root); in btrfs_shrink_device()
4485 static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans, in __btrfs_alloc_chunk() argument
4600 ret = find_free_dev_extent(trans, device, in __btrfs_alloc_chunk()
4734 list_add_tail(&em->list, &trans->transaction->pending_chunks); in __btrfs_alloc_chunk()
4743 ret = btrfs_make_block_group(trans, extent_root, 0, type, in __btrfs_alloc_chunk()
4781 int btrfs_finish_chunk_alloc(struct btrfs_trans_handle *trans, in btrfs_finish_chunk_alloc() argument
4832 ret = btrfs_update_device(trans, device); in btrfs_finish_chunk_alloc()
4835 ret = btrfs_alloc_dev_extent(trans, device, in btrfs_finish_chunk_alloc()
4869 ret = btrfs_insert_item(trans, chunk_root, &key, chunk, item_size); in btrfs_finish_chunk_alloc()
4892 int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, in btrfs_alloc_chunk() argument
4899 return __btrfs_alloc_chunk(trans, extent_root, chunk_offset, type); in btrfs_alloc_chunk()
4902 static noinline int init_first_rw_device(struct btrfs_trans_handle *trans, in init_first_rw_device() argument
4915 ret = __btrfs_alloc_chunk(trans, extent_root, chunk_offset, in init_first_rw_device()
4922 ret = __btrfs_alloc_chunk(trans, extent_root, sys_chunk_offset, in init_first_rw_device()
6700 static int update_dev_stat_item(struct btrfs_trans_handle *trans, in update_dev_stat_item() argument
6717 ret = btrfs_search_slot(trans, dev_root, &key, path, -1, 1); in update_dev_stat_item()
6728 ret = btrfs_del_item(trans, dev_root, path); in update_dev_stat_item()
6741 ret = btrfs_insert_empty_item(trans, dev_root, path, in update_dev_stat_item()
6766 int btrfs_run_dev_stats(struct btrfs_trans_handle *trans, in btrfs_run_dev_stats() argument
6781 ret = update_dev_stat_item(trans, dev_root, device); in btrfs_run_dev_stats()