Lines Matching refs:trans
15 static int __add_block_group_free_space(struct btrfs_trans_handle *trans,
50 static int add_new_free_space_info(struct btrfs_trans_handle *trans, in add_new_free_space_info() argument
54 struct btrfs_root *root = trans->fs_info->free_space_root; in add_new_free_space_info()
64 ret = btrfs_insert_empty_item(trans, root, path, &key, sizeof(*info)); in add_new_free_space_info()
83 struct btrfs_trans_handle *trans, in search_free_space_info() argument
96 ret = btrfs_search_slot(trans, root, &key, path, 0, cow); in search_free_space_info()
114 static int btrfs_search_prev_slot(struct btrfs_trans_handle *trans, in btrfs_search_prev_slot() argument
121 ret = btrfs_search_slot(trans, root, key, p, ins_len, cow); in btrfs_search_prev_slot()
185 int convert_free_space_to_bitmaps(struct btrfs_trans_handle *trans, in convert_free_space_to_bitmaps() argument
189 struct btrfs_fs_info *fs_info = trans->fs_info; in convert_free_space_to_bitmaps()
219 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in convert_free_space_to_bitmaps()
255 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); in convert_free_space_to_bitmaps()
261 info = search_free_space_info(trans, block_group, path, 1); in convert_free_space_to_bitmaps()
300 ret = btrfs_insert_empty_item(trans, root, path, &key, in convert_free_space_to_bitmaps()
320 btrfs_abort_transaction(trans, ret); in convert_free_space_to_bitmaps()
325 int convert_free_space_to_extents(struct btrfs_trans_handle *trans, in convert_free_space_to_extents() argument
329 struct btrfs_fs_info *fs_info = trans->fs_info; in convert_free_space_to_extents()
358 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in convert_free_space_to_extents()
400 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); in convert_free_space_to_extents()
406 info = search_free_space_info(trans, block_group, path, 1); in convert_free_space_to_extents()
430 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); in convert_free_space_to_extents()
454 btrfs_abort_transaction(trans, ret); in convert_free_space_to_extents()
458 static int update_free_space_extent_count(struct btrfs_trans_handle *trans, in update_free_space_extent_count() argument
471 info = search_free_space_info(trans, block_group, path, 1); in update_free_space_extent_count()
486 ret = convert_free_space_to_bitmaps(trans, block_group, path); in update_free_space_extent_count()
489 ret = convert_free_space_to_extents(trans, block_group, path); in update_free_space_extent_count()
561 static int free_space_next_bitmap(struct btrfs_trans_handle *trans, in free_space_next_bitmap() argument
578 return btrfs_search_prev_slot(trans, root, &key, p, 0, 1); in free_space_next_bitmap()
586 static int modify_free_space_bitmap(struct btrfs_trans_handle *trans, in modify_free_space_bitmap() argument
610 ret = btrfs_search_prev_slot(trans, root, &key, path, 0, 1); in modify_free_space_bitmap()
619 ret = free_space_next_bitmap(trans, root, path); in modify_free_space_bitmap()
628 ret = btrfs_search_prev_slot(trans, root, &key, path, 0, 1); in modify_free_space_bitmap()
646 ret = free_space_next_bitmap(trans, root, path); in modify_free_space_bitmap()
659 ret = free_space_next_bitmap(trans, root, path); in modify_free_space_bitmap()
692 ret = update_free_space_extent_count(trans, block_group, path, in modify_free_space_bitmap()
699 static int remove_free_space_extent(struct btrfs_trans_handle *trans, in remove_free_space_extent() argument
704 struct btrfs_root *root = trans->fs_info->free_space_root; in remove_free_space_extent()
715 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in remove_free_space_extent()
747 ret = btrfs_del_item(trans, root, path); in remove_free_space_extent()
758 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); in remove_free_space_extent()
771 ret = btrfs_insert_empty_item(trans, root, path, &key, 0); in remove_free_space_extent()
778 ret = update_free_space_extent_count(trans, block_group, path, in remove_free_space_extent()
786 int __remove_from_free_space_tree(struct btrfs_trans_handle *trans, in __remove_from_free_space_tree() argument
795 ret = __add_block_group_free_space(trans, block_group, path); in __remove_from_free_space_tree()
807 return modify_free_space_bitmap(trans, block_group, path, in __remove_from_free_space_tree()
810 return remove_free_space_extent(trans, block_group, path, in __remove_from_free_space_tree()
815 int remove_from_free_space_tree(struct btrfs_trans_handle *trans, in remove_from_free_space_tree() argument
822 if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE)) in remove_from_free_space_tree()
831 block_group = btrfs_lookup_block_group(trans->fs_info, start); in remove_from_free_space_tree()
839 ret = __remove_from_free_space_tree(trans, block_group, path, start, in remove_from_free_space_tree()
847 btrfs_abort_transaction(trans, ret); in remove_from_free_space_tree()
851 static int add_free_space_extent(struct btrfs_trans_handle *trans, in add_free_space_extent() argument
856 struct btrfs_root *root = trans->fs_info->free_space_root; in add_free_space_extent()
892 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in add_free_space_extent()
915 ret = btrfs_del_item(trans, root, path); in add_free_space_extent()
932 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in add_free_space_extent()
956 ret = btrfs_del_item(trans, root, path); in add_free_space_extent()
966 ret = btrfs_insert_empty_item(trans, root, path, &new_key, 0); in add_free_space_extent()
971 ret = update_free_space_extent_count(trans, block_group, path, in add_free_space_extent()
979 int __add_to_free_space_tree(struct btrfs_trans_handle *trans, in __add_to_free_space_tree() argument
988 ret = __add_block_group_free_space(trans, block_group, path); in __add_to_free_space_tree()
1000 return modify_free_space_bitmap(trans, block_group, path, in __add_to_free_space_tree()
1003 return add_free_space_extent(trans, block_group, path, start, in __add_to_free_space_tree()
1008 int add_to_free_space_tree(struct btrfs_trans_handle *trans, in add_to_free_space_tree() argument
1015 if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE)) in add_to_free_space_tree()
1024 block_group = btrfs_lookup_block_group(trans->fs_info, start); in add_to_free_space_tree()
1032 ret = __add_to_free_space_tree(trans, block_group, path, start, size); in add_to_free_space_tree()
1039 btrfs_abort_transaction(trans, ret); in add_to_free_space_tree()
1048 static int populate_free_space_tree(struct btrfs_trans_handle *trans, in populate_free_space_tree() argument
1051 struct btrfs_root *extent_root = trans->fs_info->extent_root; in populate_free_space_tree()
1068 ret = add_new_free_space_info(trans, block_group, path2); in populate_free_space_tree()
1101 ret = __add_to_free_space_tree(trans, in populate_free_space_tree()
1111 start += trans->fs_info->nodesize; in populate_free_space_tree()
1126 ret = __add_to_free_space_tree(trans, block_group, path2, in populate_free_space_tree()
1143 struct btrfs_trans_handle *trans; in btrfs_create_free_space_tree() local
1150 trans = btrfs_start_transaction(tree_root, 0); in btrfs_create_free_space_tree()
1151 if (IS_ERR(trans)) in btrfs_create_free_space_tree()
1152 return PTR_ERR(trans); in btrfs_create_free_space_tree()
1156 free_space_root = btrfs_create_tree(trans, in btrfs_create_free_space_tree()
1168 ret = populate_free_space_tree(trans, block_group); in btrfs_create_free_space_tree()
1177 ret = btrfs_commit_transaction(trans); in btrfs_create_free_space_tree()
1189 btrfs_abort_transaction(trans, ret); in btrfs_create_free_space_tree()
1190 btrfs_end_transaction(trans); in btrfs_create_free_space_tree()
1194 static int clear_free_space_tree(struct btrfs_trans_handle *trans, in clear_free_space_tree() argument
1213 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in clear_free_space_tree()
1222 ret = btrfs_del_items(trans, root, path, 0, nr); in clear_free_space_tree()
1237 struct btrfs_trans_handle *trans; in btrfs_clear_free_space_tree() local
1242 trans = btrfs_start_transaction(tree_root, 0); in btrfs_clear_free_space_tree()
1243 if (IS_ERR(trans)) in btrfs_clear_free_space_tree()
1244 return PTR_ERR(trans); in btrfs_clear_free_space_tree()
1250 ret = clear_free_space_tree(trans, free_space_root); in btrfs_clear_free_space_tree()
1254 ret = btrfs_del_root(trans, &free_space_root->root_key); in btrfs_clear_free_space_tree()
1263 btrfs_free_tree_block(trans, free_space_root, free_space_root->node, in btrfs_clear_free_space_tree()
1268 return btrfs_commit_transaction(trans); in btrfs_clear_free_space_tree()
1271 btrfs_abort_transaction(trans, ret); in btrfs_clear_free_space_tree()
1272 btrfs_end_transaction(trans); in btrfs_clear_free_space_tree()
1276 static int __add_block_group_free_space(struct btrfs_trans_handle *trans, in __add_block_group_free_space() argument
1284 ret = add_new_free_space_info(trans, block_group, path); in __add_block_group_free_space()
1288 return __add_to_free_space_tree(trans, block_group, path, in __add_block_group_free_space()
1293 int add_block_group_free_space(struct btrfs_trans_handle *trans, in add_block_group_free_space() argument
1296 struct btrfs_fs_info *fs_info = trans->fs_info; in add_block_group_free_space()
1313 ret = __add_block_group_free_space(trans, block_group, path); in add_block_group_free_space()
1319 btrfs_abort_transaction(trans, ret); in add_block_group_free_space()
1323 int remove_block_group_free_space(struct btrfs_trans_handle *trans, in remove_block_group_free_space() argument
1326 struct btrfs_root *root = trans->fs_info->free_space_root; in remove_block_group_free_space()
1334 if (!btrfs_fs_compat_ro(trans->fs_info, FREE_SPACE_TREE)) in remove_block_group_free_space()
1356 ret = btrfs_search_prev_slot(trans, root, &key, path, -1, 1); in remove_block_group_free_space()
1385 ret = btrfs_del_items(trans, root, path, path->slots[0], nr); in remove_block_group_free_space()
1395 btrfs_abort_transaction(trans, ret); in remove_block_group_free_space()