Lines Matching refs:block_group
21 struct btrfs_block_group *block_group,
25 struct btrfs_block_group *block_group) in btrfs_free_space_root() argument
33 if (btrfs_fs_incompat(block_group->fs_info, EXTENT_TREE_V2)) in btrfs_free_space_root()
34 key.offset = block_group->global_root_id; in btrfs_free_space_root()
35 return btrfs_global_root(block_group->fs_info, &key); in btrfs_free_space_root()
70 struct btrfs_block_group *block_group, in add_new_free_space_info() argument
73 struct btrfs_root *root = btrfs_free_space_root(block_group); in add_new_free_space_info()
79 key.objectid = block_group->start; in add_new_free_space_info()
81 key.offset = block_group->length; in add_new_free_space_info()
103 struct btrfs_block_group *block_group, in search_free_space_info() argument
106 struct btrfs_fs_info *fs_info = block_group->fs_info; in search_free_space_info()
107 struct btrfs_root *root = btrfs_free_space_root(block_group); in search_free_space_info()
111 key.objectid = block_group->start; in search_free_space_info()
113 key.offset = block_group->length; in search_free_space_info()
120 block_group->start); in search_free_space_info()
206 struct btrfs_block_group *block_group, in convert_free_space_to_bitmaps() argument
210 struct btrfs_root *root = btrfs_free_space_root(block_group); in convert_free_space_to_bitmaps()
223 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); in convert_free_space_to_bitmaps()
230 start = block_group->start; in convert_free_space_to_bitmaps()
231 end = block_group->start + block_group->length; in convert_free_space_to_bitmaps()
249 ASSERT(found_key.objectid == block_group->start); in convert_free_space_to_bitmaps()
250 ASSERT(found_key.offset == block_group->length); in convert_free_space_to_bitmaps()
280 info = search_free_space_info(trans, block_group, path, 1); in convert_free_space_to_bitmaps()
296 block_group->start, extent_count, in convert_free_space_to_bitmaps()
344 struct btrfs_block_group *block_group, in convert_free_space_to_extents() argument
348 struct btrfs_root *root = btrfs_free_space_root(block_group); in convert_free_space_to_extents()
360 bitmap_size = free_space_bitmap_size(fs_info, block_group->length); in convert_free_space_to_extents()
367 start = block_group->start; in convert_free_space_to_extents()
368 end = block_group->start + block_group->length; in convert_free_space_to_extents()
386 ASSERT(found_key.objectid == block_group->start); in convert_free_space_to_extents()
387 ASSERT(found_key.offset == block_group->length); in convert_free_space_to_extents()
423 info = search_free_space_info(trans, block_group, path, 1); in convert_free_space_to_extents()
436 nrbits = block_group->length >> block_group->fs_info->sectorsize_bits; in convert_free_space_to_extents()
443 key.objectid = start + start_bit * block_group->fs_info->sectorsize; in convert_free_space_to_extents()
445 key.offset = (end_bit - start_bit) * block_group->fs_info->sectorsize; in convert_free_space_to_extents()
460 block_group->start, extent_count, in convert_free_space_to_extents()
476 struct btrfs_block_group *block_group, in update_free_space_extent_count() argument
488 info = search_free_space_info(trans, block_group, path, 1); in update_free_space_extent_count()
502 extent_count > block_group->bitmap_high_thresh) { in update_free_space_extent_count()
503 ret = convert_free_space_to_bitmaps(trans, block_group, path); in update_free_space_extent_count()
505 extent_count < block_group->bitmap_low_thresh) { in update_free_space_extent_count()
506 ret = convert_free_space_to_extents(trans, block_group, path); in update_free_space_extent_count()
514 int free_space_test_bit(struct btrfs_block_group *block_group, in free_space_test_bit() argument
532 block_group->fs_info->sectorsize); in free_space_test_bit()
536 static void free_space_set_bits(struct btrfs_block_group *block_group, in free_space_set_bits() argument
540 struct btrfs_fs_info *fs_info = block_group->fs_info; in free_space_set_bits()
604 struct btrfs_block_group *block_group, in modify_free_space_bitmap() argument
608 struct btrfs_root *root = btrfs_free_space_root(block_group); in modify_free_space_bitmap()
620 if (start > block_group->start) { in modify_free_space_bitmap()
621 u64 prev_block = start - block_group->fs_info->sectorsize; in modify_free_space_bitmap()
631 prev_bit = free_space_test_bit(block_group, path, prev_block); in modify_free_space_bitmap()
659 free_space_set_bits(block_group, path, &cur_start, &cur_size, in modify_free_space_bitmap()
672 if (end < block_group->start + block_group->length) { in modify_free_space_bitmap()
681 next_bit = free_space_test_bit(block_group, path, end); in modify_free_space_bitmap()
709 ret = update_free_space_extent_count(trans, block_group, path, in modify_free_space_bitmap()
717 struct btrfs_block_group *block_group, in remove_free_space_extent() argument
721 struct btrfs_root *root = btrfs_free_space_root(block_group); in remove_free_space_extent()
795 ret = update_free_space_extent_count(trans, block_group, path, in remove_free_space_extent()
804 struct btrfs_block_group *block_group, in __remove_from_free_space_tree() argument
811 if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) { in __remove_from_free_space_tree()
812 ret = __add_block_group_free_space(trans, block_group, path); in __remove_from_free_space_tree()
817 info = search_free_space_info(NULL, block_group, path, 0); in __remove_from_free_space_tree()
824 return modify_free_space_bitmap(trans, block_group, path, in __remove_from_free_space_tree()
827 return remove_free_space_extent(trans, block_group, path, in __remove_from_free_space_tree()
835 struct btrfs_block_group *block_group; in remove_from_free_space_tree() local
848 block_group = btrfs_lookup_block_group(trans->fs_info, start); in remove_from_free_space_tree()
849 if (!block_group) { in remove_from_free_space_tree()
855 mutex_lock(&block_group->free_space_lock); in remove_from_free_space_tree()
856 ret = __remove_from_free_space_tree(trans, block_group, path, start, in remove_from_free_space_tree()
858 mutex_unlock(&block_group->free_space_lock); in remove_from_free_space_tree()
860 btrfs_put_block_group(block_group); in remove_from_free_space_tree()
869 struct btrfs_block_group *block_group, in add_free_space_extent() argument
873 struct btrfs_root *root = btrfs_free_space_root(block_group); in add_free_space_extent()
903 if (start == block_group->start) in add_free_space_extent()
923 ASSERT(found_start >= block_group->start && in add_free_space_extent()
924 found_end > block_group->start); in add_free_space_extent()
943 if (end == block_group->start + block_group->length) in add_free_space_extent()
963 ASSERT(found_start >= block_group->start && in add_free_space_extent()
964 found_end > block_group->start); in add_free_space_extent()
988 ret = update_free_space_extent_count(trans, block_group, path, in add_free_space_extent()
997 struct btrfs_block_group *block_group, in __add_to_free_space_tree() argument
1004 if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) { in __add_to_free_space_tree()
1005 ret = __add_block_group_free_space(trans, block_group, path); in __add_to_free_space_tree()
1010 info = search_free_space_info(NULL, block_group, path, 0); in __add_to_free_space_tree()
1017 return modify_free_space_bitmap(trans, block_group, path, in __add_to_free_space_tree()
1020 return add_free_space_extent(trans, block_group, path, start, in __add_to_free_space_tree()
1028 struct btrfs_block_group *block_group; in add_to_free_space_tree() local
1041 block_group = btrfs_lookup_block_group(trans->fs_info, start); in add_to_free_space_tree()
1042 if (!block_group) { in add_to_free_space_tree()
1048 mutex_lock(&block_group->free_space_lock); in add_to_free_space_tree()
1049 ret = __add_to_free_space_tree(trans, block_group, path, start, size); in add_to_free_space_tree()
1050 mutex_unlock(&block_group->free_space_lock); in add_to_free_space_tree()
1052 btrfs_put_block_group(block_group); in add_to_free_space_tree()
1066 struct btrfs_block_group *block_group) in populate_free_space_tree() argument
1085 ret = add_new_free_space_info(trans, block_group, path2); in populate_free_space_tree()
1089 mutex_lock(&block_group->free_space_lock); in populate_free_space_tree()
1098 key.objectid = block_group->start; in populate_free_space_tree()
1108 start = block_group->start; in populate_free_space_tree()
1109 end = block_group->start + block_group->length; in populate_free_space_tree()
1120 block_group, in populate_free_space_tree()
1133 if (key.objectid != block_group->start) in populate_free_space_tree()
1144 ret = __add_to_free_space_tree(trans, block_group, path2, in populate_free_space_tree()
1152 mutex_unlock(&block_group->free_space_lock); in populate_free_space_tree()
1164 struct btrfs_block_group *block_group; in btrfs_create_free_space_tree() local
1188 block_group = rb_entry(node, struct btrfs_block_group, in btrfs_create_free_space_tree()
1190 ret = populate_free_space_tree(trans, block_group); in btrfs_create_free_space_tree()
1302 struct btrfs_block_group *block_group, in __add_block_group_free_space() argument
1307 clear_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags); in __add_block_group_free_space()
1309 ret = add_new_free_space_info(trans, block_group, path); in __add_block_group_free_space()
1313 return __add_to_free_space_tree(trans, block_group, path, in __add_block_group_free_space()
1314 block_group->start, in __add_block_group_free_space()
1315 block_group->length); in __add_block_group_free_space()
1319 struct btrfs_block_group *block_group) in add_block_group_free_space() argument
1328 mutex_lock(&block_group->free_space_lock); in add_block_group_free_space()
1329 if (!test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) in add_block_group_free_space()
1338 ret = __add_block_group_free_space(trans, block_group, path); in add_block_group_free_space()
1342 mutex_unlock(&block_group->free_space_lock); in add_block_group_free_space()
1349 struct btrfs_block_group *block_group) in remove_block_group_free_space() argument
1351 struct btrfs_root *root = btrfs_free_space_root(block_group); in remove_block_group_free_space()
1362 if (test_bit(BLOCK_GROUP_FLAG_NEEDS_FREE_SPACE, &block_group->runtime_flags)) { in remove_block_group_free_space()
1373 start = block_group->start; in remove_block_group_free_space()
1374 end = block_group->start + block_group->length; in remove_block_group_free_space()
1392 ASSERT(found_key.objectid == block_group->start); in remove_block_group_free_space()
1393 ASSERT(found_key.offset == block_group->length); in remove_block_group_free_space()
1428 struct btrfs_block_group *block_group; in load_free_space_bitmaps() local
1440 block_group = caching_ctl->block_group; in load_free_space_bitmaps()
1441 fs_info = block_group->fs_info; in load_free_space_bitmaps()
1442 root = btrfs_free_space_root(block_group); in load_free_space_bitmaps()
1444 end = block_group->start + block_group->length; in load_free_space_bitmaps()
1463 bit = free_space_test_bit(block_group, path, offset); in load_free_space_bitmaps()
1467 total_found += add_new_free_space(block_group, in load_free_space_bitmaps()
1481 total_found += add_new_free_space(block_group, extent_start, in load_free_space_bitmaps()
1489 block_group->start, extent_count, in load_free_space_bitmaps()
1505 struct btrfs_block_group *block_group; in load_free_space_extents() local
1514 block_group = caching_ctl->block_group; in load_free_space_extents()
1515 fs_info = block_group->fs_info; in load_free_space_extents()
1516 root = btrfs_free_space_root(block_group); in load_free_space_extents()
1518 end = block_group->start + block_group->length; in load_free_space_extents()
1535 total_found += add_new_free_space(block_group, key.objectid, in load_free_space_extents()
1547 block_group->start, extent_count, in load_free_space_extents()
1561 struct btrfs_block_group *block_group; in load_free_space_tree() local
1567 block_group = caching_ctl->block_group; in load_free_space_tree()
1581 info = search_free_space_info(NULL, block_group, path, 0); in load_free_space_tree()