Lines Matching refs:fs_info

27 static u64 get_restripe_target(struct btrfs_fs_info *fs_info, u64 flags)  in get_restripe_target()  argument
29 struct btrfs_balance_control *bctl = fs_info->balance_ctl; in get_restripe_target()
56 static u64 btrfs_reduce_alloc_profile(struct btrfs_fs_info *fs_info, u64 flags) in btrfs_reduce_alloc_profile() argument
58 u64 num_devices = fs_info->fs_devices->rw_devices; in btrfs_reduce_alloc_profile()
67 spin_lock(&fs_info->balance_lock); in btrfs_reduce_alloc_profile()
68 target = get_restripe_target(fs_info, flags); in btrfs_reduce_alloc_profile()
70 spin_unlock(&fs_info->balance_lock); in btrfs_reduce_alloc_profile()
73 spin_unlock(&fs_info->balance_lock); in btrfs_reduce_alloc_profile()
98 u64 btrfs_get_alloc_profile(struct btrfs_fs_info *fs_info, u64 orig_flags) in btrfs_get_alloc_profile() argument
105 seq = read_seqbegin(&fs_info->profiles_lock); in btrfs_get_alloc_profile()
108 flags |= fs_info->avail_data_alloc_bits; in btrfs_get_alloc_profile()
110 flags |= fs_info->avail_system_alloc_bits; in btrfs_get_alloc_profile()
112 flags |= fs_info->avail_metadata_alloc_bits; in btrfs_get_alloc_profile()
113 } while (read_seqretry(&fs_info->profiles_lock, seq)); in btrfs_get_alloc_profile()
115 return btrfs_reduce_alloc_profile(fs_info, flags); in btrfs_get_alloc_profile()
135 btrfs_discard_cancel_work(&cache->fs_info->discard_ctl, in btrfs_put_block_group()
258 struct btrfs_fs_info *fs_info = cache->fs_info; in btrfs_next_block_group() local
261 spin_lock(&fs_info->block_group_cache_lock); in btrfs_next_block_group()
267 spin_unlock(&fs_info->block_group_cache_lock); in btrfs_next_block_group()
269 cache = btrfs_lookup_first_block_group(fs_info, next_bytenr); return cache; in btrfs_next_block_group()
278 spin_unlock(&fs_info->block_group_cache_lock); in btrfs_next_block_group()
282 bool btrfs_inc_nocow_writers(struct btrfs_fs_info *fs_info, u64 bytenr) in btrfs_inc_nocow_writers() argument
287 bg = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_inc_nocow_writers()
305 void btrfs_dec_nocow_writers(struct btrfs_fs_info *fs_info, u64 bytenr) in btrfs_dec_nocow_writers() argument
309 bg = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_dec_nocow_writers()
326 void btrfs_dec_block_group_reservations(struct btrfs_fs_info *fs_info, in btrfs_dec_block_group_reservations() argument
331 bg = btrfs_lookup_block_group(fs_info, start); in btrfs_dec_block_group_reservations()
450 struct btrfs_fs_info *fs_info = block_group->fs_info; in fragment_free_space() local
454 fs_info->nodesize : fs_info->sectorsize; in fragment_free_space()
476 struct btrfs_fs_info *info = block_group->fs_info; in add_new_free_space()
516 struct btrfs_fs_info *fs_info = block_group->fs_info; in load_extent_tree_free() local
517 struct btrfs_root *extent_root = fs_info->extent_root; in load_extent_tree_free()
565 if (btrfs_fs_closing(fs_info) > 1) { in load_extent_tree_free()
578 rwsem_is_contended(&fs_info->commit_root_sem)) { in load_extent_tree_free()
582 up_read(&fs_info->commit_root_sem); in load_extent_tree_free()
586 down_read(&fs_info->commit_root_sem); in load_extent_tree_free()
625 fs_info->nodesize; in load_extent_tree_free()
651 struct btrfs_fs_info *fs_info; in caching_thread() local
657 fs_info = block_group->fs_info; in caching_thread()
660 down_read(&fs_info->commit_root_sem); in caching_thread()
662 if (btrfs_test_opt(fs_info, SPACE_CACHE)) { in caching_thread()
686 if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE) && in caching_thread()
687 !(test_bit(BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, &fs_info->flags))) in caching_thread()
713 up_read(&fs_info->commit_root_sem); in caching_thread()
726 struct btrfs_fs_info *fs_info = cache->fs_info; in btrfs_cache_block_group() local
731 if (btrfs_is_zoned(fs_info)) in btrfs_cache_block_group()
758 if (btrfs_test_opt(fs_info, SPACE_CACHE)) in btrfs_cache_block_group()
765 spin_lock(&fs_info->block_group_cache_lock); in btrfs_cache_block_group()
767 list_add_tail(&caching_ctl->list, &fs_info->caching_block_groups); in btrfs_cache_block_group()
768 spin_unlock(&fs_info->block_group_cache_lock); in btrfs_cache_block_group()
772 btrfs_queue_work(fs_info->caching_workers, &caching_ctl->work); in btrfs_cache_block_group()
782 static void clear_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) in clear_avail_alloc_bits() argument
787 write_seqlock(&fs_info->profiles_lock); in clear_avail_alloc_bits()
789 fs_info->avail_data_alloc_bits &= ~extra_flags; in clear_avail_alloc_bits()
791 fs_info->avail_metadata_alloc_bits &= ~extra_flags; in clear_avail_alloc_bits()
793 fs_info->avail_system_alloc_bits &= ~extra_flags; in clear_avail_alloc_bits()
794 write_sequnlock(&fs_info->profiles_lock); in clear_avail_alloc_bits()
805 static void clear_incompat_bg_bits(struct btrfs_fs_info *fs_info, u64 flags) in clear_incompat_bg_bits() argument
813 struct list_head *head = &fs_info->space_info; in clear_incompat_bg_bits()
829 btrfs_clear_fs_incompat(fs_info, RAID56); in clear_incompat_bg_bits()
831 btrfs_clear_fs_incompat(fs_info, RAID1C34); in clear_incompat_bg_bits()
839 struct btrfs_fs_info *fs_info = trans->fs_info; in remove_block_group_item() local
844 root = fs_info->extent_root; in remove_block_group_item()
862 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_remove_block_group() local
875 block_group = btrfs_lookup_block_group(fs_info, group_start); in btrfs_remove_block_group()
885 btrfs_free_ref_tree_range(fs_info, block_group->start, in btrfs_remove_block_group()
892 cluster = &fs_info->data_alloc_cluster; in btrfs_remove_block_group()
901 cluster = &fs_info->meta_alloc_cluster; in btrfs_remove_block_group()
950 spin_lock(&fs_info->block_group_cache_lock); in btrfs_remove_block_group()
952 &fs_info->block_group_cache_tree); in btrfs_remove_block_group()
958 if (fs_info->first_logical_byte == block_group->start) in btrfs_remove_block_group()
959 fs_info->first_logical_byte = (u64)-1; in btrfs_remove_block_group()
960 spin_unlock(&fs_info->block_group_cache_lock); in btrfs_remove_block_group()
971 clear_avail_alloc_bits(fs_info, block_group->flags); in btrfs_remove_block_group()
974 clear_incompat_bg_bits(fs_info, block_group->flags); in btrfs_remove_block_group()
985 spin_lock(&fs_info->block_group_cache_lock); in btrfs_remove_block_group()
990 &fs_info->caching_block_groups, list) in btrfs_remove_block_group()
999 spin_unlock(&fs_info->block_group_cache_lock); in btrfs_remove_block_group()
1017 if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { in btrfs_remove_block_group()
1089 em_tree = &fs_info->mapping_tree; in btrfs_remove_block_group()
1101 btrfs_delayed_refs_rsv_release(fs_info, 1); in btrfs_remove_block_group()
1107 struct btrfs_fs_info *fs_info, const u64 chunk_offset) in btrfs_start_trans_remove_block_group() argument
1109 struct extent_map_tree *em_tree = &fs_info->mapping_tree; in btrfs_start_trans_remove_block_group()
1142 return btrfs_start_transaction_fallback_global_rsv(fs_info->extent_root, in btrfs_start_trans_remove_block_group()
1204 if (btrfs_can_overcommit(cache->fs_info, sinfo, num_bytes, in inc_block_group_ro()
1211 if (btrfs_is_zoned(cache->fs_info)) { in inc_block_group_ro()
1223 if (ret == -ENOSPC && btrfs_test_opt(cache->fs_info, ENOSPC_DEBUG)) { in inc_block_group_ro()
1224 btrfs_info(cache->fs_info, in inc_block_group_ro()
1226 btrfs_dump_space_info(cache->fs_info, cache->space_info, 0, 0); in inc_block_group_ro()
1234 struct btrfs_fs_info *fs_info = bg->fs_info; in clean_pinned_extents() local
1240 spin_lock(&fs_info->trans_lock); in clean_pinned_extents()
1241 if (trans->transaction->list.prev != &fs_info->trans_list) { in clean_pinned_extents()
1246 spin_unlock(&fs_info->trans_lock); in clean_pinned_extents()
1258 mutex_lock(&fs_info->unused_bg_unpin_mutex); in clean_pinned_extents()
1269 mutex_unlock(&fs_info->unused_bg_unpin_mutex); in clean_pinned_extents()
1280 void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info) in btrfs_delete_unused_bgs() argument
1285 const bool async_trim_enabled = btrfs_test_opt(fs_info, DISCARD_ASYNC); in btrfs_delete_unused_bgs()
1288 if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags)) in btrfs_delete_unused_bgs()
1295 if (!mutex_trylock(&fs_info->reclaim_bgs_lock)) in btrfs_delete_unused_bgs()
1298 spin_lock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1299 while (!list_empty(&fs_info->unused_bgs)) { in btrfs_delete_unused_bgs()
1302 block_group = list_first_entry(&fs_info->unused_bgs, in btrfs_delete_unused_bgs()
1313 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1315 btrfs_discard_cancel_work(&fs_info->discard_ctl, block_group); in btrfs_delete_unused_bgs()
1325 if (btrfs_test_opt(fs_info, DISCARD_ASYNC) && in btrfs_delete_unused_bgs()
1330 btrfs_discard_queue_work(&fs_info->discard_ctl, in btrfs_delete_unused_bgs()
1364 trans = btrfs_start_trans_remove_block_group(fs_info, in btrfs_delete_unused_bgs()
1388 spin_lock(&fs_info->discard_ctl.lock); in btrfs_delete_unused_bgs()
1390 spin_unlock(&fs_info->discard_ctl.lock); in btrfs_delete_unused_bgs()
1392 btrfs_discard_queue_work(&fs_info->discard_ctl, in btrfs_delete_unused_bgs()
1396 spin_unlock(&fs_info->discard_ctl.lock); in btrfs_delete_unused_bgs()
1402 btrfs_space_info_update_bytes_pinned(fs_info, space_info, in btrfs_delete_unused_bgs()
1417 if (!async_trim_enabled && btrfs_test_opt(fs_info, DISCARD_ASYNC)) in btrfs_delete_unused_bgs()
1424 trimming = btrfs_test_opt(fs_info, DISCARD_SYNC) || in btrfs_delete_unused_bgs()
1425 btrfs_is_zoned(fs_info); in btrfs_delete_unused_bgs()
1449 spin_lock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1457 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1464 spin_lock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1466 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_delete_unused_bgs()
1467 mutex_unlock(&fs_info->reclaim_bgs_lock); in btrfs_delete_unused_bgs()
1472 mutex_unlock(&fs_info->reclaim_bgs_lock); in btrfs_delete_unused_bgs()
1474 btrfs_discard_punt_unused_bgs_list(fs_info); in btrfs_delete_unused_bgs()
1479 struct btrfs_fs_info *fs_info = bg->fs_info; in btrfs_mark_bg_unused() local
1481 spin_lock(&fs_info->unused_bgs_lock); in btrfs_mark_bg_unused()
1485 list_add_tail(&bg->bg_list, &fs_info->unused_bgs); in btrfs_mark_bg_unused()
1487 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_mark_bg_unused()
1507 struct btrfs_fs_info *fs_info = in btrfs_reclaim_bgs_work() local
1513 if (!test_bit(BTRFS_FS_OPEN, &fs_info->flags)) in btrfs_reclaim_bgs_work()
1516 if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_BALANCE)) in btrfs_reclaim_bgs_work()
1523 if (!mutex_trylock(&fs_info->reclaim_bgs_lock)) { in btrfs_reclaim_bgs_work()
1524 btrfs_exclop_finish(fs_info); in btrfs_reclaim_bgs_work()
1528 spin_lock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs_work()
1534 list_sort(NULL, &fs_info->reclaim_bgs, reclaim_bgs_cmp); in btrfs_reclaim_bgs_work()
1535 while (!list_empty(&fs_info->reclaim_bgs)) { in btrfs_reclaim_bgs_work()
1539 bg = list_first_entry(&fs_info->reclaim_bgs, in btrfs_reclaim_bgs_work()
1545 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs_work()
1565 if (btrfs_fs_closing(fs_info)) { in btrfs_reclaim_bgs_work()
1582 btrfs_info(fs_info, in btrfs_reclaim_bgs_work()
1587 ret = btrfs_relocate_chunk(fs_info, bg->start); in btrfs_reclaim_bgs_work()
1589 btrfs_err(fs_info, "error relocating chunk %llu", in btrfs_reclaim_bgs_work()
1593 spin_lock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs_work()
1599 list_splice_tail(&again_list, &fs_info->reclaim_bgs); in btrfs_reclaim_bgs_work()
1600 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs_work()
1601 mutex_unlock(&fs_info->reclaim_bgs_lock); in btrfs_reclaim_bgs_work()
1602 btrfs_exclop_finish(fs_info); in btrfs_reclaim_bgs_work()
1605 void btrfs_reclaim_bgs(struct btrfs_fs_info *fs_info) in btrfs_reclaim_bgs() argument
1607 spin_lock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs()
1608 if (!list_empty(&fs_info->reclaim_bgs)) in btrfs_reclaim_bgs()
1609 queue_work(system_unbound_wq, &fs_info->reclaim_bgs_work); in btrfs_reclaim_bgs()
1610 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_reclaim_bgs()
1615 struct btrfs_fs_info *fs_info = bg->fs_info; in btrfs_mark_bg_to_reclaim() local
1617 spin_lock(&fs_info->unused_bgs_lock); in btrfs_mark_bg_to_reclaim()
1621 list_add_tail(&bg->bg_list, &fs_info->reclaim_bgs); in btrfs_mark_bg_to_reclaim()
1623 spin_unlock(&fs_info->unused_bgs_lock); in btrfs_mark_bg_to_reclaim()
1626 static int read_bg_from_eb(struct btrfs_fs_info *fs_info, struct btrfs_key *key, in read_bg_from_eb() argument
1640 em_tree = &fs_info->mapping_tree; in read_bg_from_eb()
1645 btrfs_err(fs_info, in read_bg_from_eb()
1652 btrfs_err(fs_info, in read_bg_from_eb()
1665 btrfs_err(fs_info, in read_bg_from_eb()
1677 static int find_first_block_group(struct btrfs_fs_info *fs_info, in find_first_block_group() argument
1681 struct btrfs_root *root = fs_info->extent_root; in find_first_block_group()
1706 ret = read_bg_from_eb(fs_info, &found_key, path); in find_first_block_group()
1716 static void set_avail_alloc_bits(struct btrfs_fs_info *fs_info, u64 flags) in set_avail_alloc_bits() argument
1721 write_seqlock(&fs_info->profiles_lock); in set_avail_alloc_bits()
1723 fs_info->avail_data_alloc_bits |= extra_flags; in set_avail_alloc_bits()
1725 fs_info->avail_metadata_alloc_bits |= extra_flags; in set_avail_alloc_bits()
1727 fs_info->avail_system_alloc_bits |= extra_flags; in set_avail_alloc_bits()
1728 write_sequnlock(&fs_info->profiles_lock); in set_avail_alloc_bits()
1746 int btrfs_rmap_block(struct btrfs_fs_info *fs_info, u64 chunk_start, in btrfs_rmap_block() argument
1759 em = btrfs_get_chunk_map(fs_info, chunk_start, 1); in btrfs_rmap_block()
1830 struct btrfs_fs_info *fs_info = cache->fs_info; in exclude_super_stripes() local
1831 const bool zoned = btrfs_is_zoned(fs_info); in exclude_super_stripes()
1840 ret = btrfs_add_excluded_extent(fs_info, cache->start, in exclude_super_stripes()
1848 ret = btrfs_rmap_block(fs_info, cache->start, NULL, in exclude_super_stripes()
1855 btrfs_err(fs_info, in exclude_super_stripes()
1866 ret = btrfs_add_excluded_extent(fs_info, logical[nr], in exclude_super_stripes()
1890 struct btrfs_fs_info *fs_info, u64 start) in btrfs_create_block_group_cache() argument
1907 cache->fs_info = fs_info; in btrfs_create_block_group_cache()
1908 cache->full_stripe_len = btrfs_full_stripe_len(fs_info, start); in btrfs_create_block_group_cache()
1935 static int check_chunk_block_group_mappings(struct btrfs_fs_info *fs_info) in check_chunk_block_group_mappings() argument
1937 struct extent_map_tree *map_tree = &fs_info->mapping_tree; in check_chunk_block_group_mappings()
1955 bg = btrfs_lookup_block_group(fs_info, em->start); in check_chunk_block_group_mappings()
1957 btrfs_err(fs_info, in check_chunk_block_group_mappings()
1967 btrfs_err(fs_info, in check_chunk_block_group_mappings()
2110 static int fill_dummy_bgs(struct btrfs_fs_info *fs_info) in fill_dummy_bgs() argument
2112 struct extent_map_tree *em_tree = &fs_info->mapping_tree; in fill_dummy_bgs()
2124 bg = btrfs_create_block_group_cache(fs_info, em->start); in fill_dummy_bgs()
2137 ret = btrfs_add_block_group_cache(fs_info, bg); in fill_dummy_bgs()
2154 btrfs_update_space_info(fs_info, bg->flags, em->len, em->len, in fill_dummy_bgs()
2159 set_avail_alloc_bits(fs_info, bg->flags); in fill_dummy_bgs()
2162 btrfs_init_global_block_rsv(fs_info); in fill_dummy_bgs()
2277 struct btrfs_fs_info *fs_info = trans->fs_info; in insert_block_group_item() local
2292 root = fs_info->extent_root; in insert_block_group_item()
2300 struct btrfs_fs_info *fs_info = device->fs_info; in insert_dev_extent() local
2301 struct btrfs_root *root = fs_info->dev_root; in insert_dev_extent()
2344 struct btrfs_fs_info *fs_info = trans->fs_info; in insert_dev_extents() local
2353 em = btrfs_get_chunk_map(fs_info, chunk_offset, chunk_size); in insert_dev_extents()
2369 mutex_lock(&fs_info->fs_devices->device_list_mutex); in insert_dev_extents()
2379 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in insert_dev_extents()
2394 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_create_pending_block_groups() local
2413 mutex_lock(&fs_info->chunk_mutex); in btrfs_create_pending_block_groups()
2415 mutex_unlock(&fs_info->chunk_mutex); in btrfs_create_pending_block_groups()
2436 btrfs_delayed_refs_rsv_release(fs_info, 1); in btrfs_create_pending_block_groups()
2446 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_make_block_group() local
2452 cache = btrfs_create_block_group_cache(fs_info, chunk_offset); in btrfs_make_block_group()
2462 if (btrfs_fs_compat_ro(fs_info, FREE_SPACE_TREE)) in btrfs_make_block_group()
2502 cache->space_info = btrfs_find_space_info(fs_info, cache->flags); in btrfs_make_block_group()
2505 ret = btrfs_add_block_group_cache(fs_info, cache); in btrfs_make_block_group()
2516 trace_btrfs_add_block_group(fs_info, cache, 1); in btrfs_make_block_group()
2517 btrfs_update_space_info(fs_info, cache->flags, size, bytes_used, in btrfs_make_block_group()
2520 btrfs_update_global_block_rsv(fs_info); in btrfs_make_block_group()
2528 set_avail_alloc_bits(fs_info, type); in btrfs_make_block_group()
2544 struct btrfs_fs_info *fs_info = cache->fs_info; in btrfs_inc_block_group_ro() local
2551 trans = btrfs_join_transaction(fs_info->extent_root); in btrfs_inc_block_group_ro()
2562 mutex_lock(&fs_info->ro_block_group_mutex); in btrfs_inc_block_group_ro()
2566 mutex_unlock(&fs_info->ro_block_group_mutex); in btrfs_inc_block_group_ro()
2569 ret = btrfs_wait_for_commit(fs_info, transid); in btrfs_inc_block_group_ro()
2581 alloc_flags = btrfs_get_alloc_profile(fs_info, cache->flags); in btrfs_inc_block_group_ro()
2601 alloc_flags = btrfs_get_alloc_profile(fs_info, cache->space_info->flags); in btrfs_inc_block_group_ro()
2610 alloc_flags = btrfs_get_alloc_profile(fs_info, cache->flags); in btrfs_inc_block_group_ro()
2611 mutex_lock(&fs_info->chunk_mutex); in btrfs_inc_block_group_ro()
2613 mutex_unlock(&fs_info->chunk_mutex); in btrfs_inc_block_group_ro()
2616 mutex_unlock(&fs_info->ro_block_group_mutex); in btrfs_inc_block_group_ro()
2632 if (btrfs_is_zoned(cache->fs_info)) { in btrfs_dec_block_group_ro()
2654 struct btrfs_fs_info *fs_info = trans->fs_info; in update_block_group_item() local
2656 struct btrfs_root *root = fs_info->extent_root; in update_block_group_item()
2691 struct btrfs_fs_info *fs_info = block_group->fs_info; in cache_save_setup() local
2692 struct btrfs_root *root = fs_info->tree_root; in cache_save_setup()
2701 if (!btrfs_test_opt(fs_info, SPACE_CACHE)) in cache_save_setup()
2769 ret = btrfs_check_trunc_cache_free_space(fs_info, in cache_save_setup()
2770 &fs_info->global_block_rsv); in cache_save_setup()
2781 !btrfs_test_opt(fs_info, SPACE_CACHE)) { in cache_save_setup()
2814 cache_size *= fs_info->sectorsize; in cache_save_setup()
2854 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_setup_space_cache() local
2860 !btrfs_test_opt(fs_info, SPACE_CACHE)) in btrfs_setup_space_cache()
2892 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_start_dirty_block_groups() local
3013 btrfs_delayed_refs_rsv_release(fs_info, 1); in btrfs_start_dirty_block_groups()
3051 btrfs_cleanup_dirty_bgs(cur_trans, fs_info); in btrfs_start_dirty_block_groups()
3060 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_write_dirty_block_groups() local
3163 btrfs_delayed_refs_rsv_release(fs_info, 1); in btrfs_write_dirty_block_groups()
3187 struct btrfs_fs_info *info = trans->fs_info; in btrfs_update_block_group()
3314 trace_btrfs_space_reservation(cache->fs_info, "space_info", in btrfs_add_reserved_bytes()
3316 btrfs_space_info_update_bytes_may_use(cache->fs_info, in btrfs_add_reserved_bytes()
3326 btrfs_try_granting_tickets(cache->fs_info, space_info); in btrfs_add_reserved_bytes()
3361 btrfs_try_granting_tickets(cache->fs_info, space_info); in btrfs_free_reserved_bytes()
3376 static int should_alloc_chunk(struct btrfs_fs_info *fs_info, in should_alloc_chunk() argument
3390 thresh = btrfs_super_total_bytes(fs_info->super_copy); in should_alloc_chunk()
3404 u64 alloc_flags = btrfs_get_alloc_profile(trans->fs_info, type); in btrfs_force_chunk_alloc()
3468 const u64 sys_flags = btrfs_system_alloc_profile(trans->fs_info); in do_chunk_alloc()
3609 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_chunk_alloc() local
3642 space_info = btrfs_find_space_info(fs_info, flags); in btrfs_chunk_alloc()
3649 should_alloc = should_alloc_chunk(fs_info, space_info, force); in btrfs_chunk_alloc()
3670 mutex_lock(&fs_info->chunk_mutex); in btrfs_chunk_alloc()
3671 mutex_unlock(&fs_info->chunk_mutex); in btrfs_chunk_alloc()
3682 mutex_lock(&fs_info->chunk_mutex); in btrfs_chunk_alloc()
3697 if (flags & BTRFS_BLOCK_GROUP_DATA && fs_info->metadata_ratio) { in btrfs_chunk_alloc()
3698 fs_info->data_chunk_allocations++; in btrfs_chunk_alloc()
3699 if (!(fs_info->data_chunk_allocations % in btrfs_chunk_alloc()
3700 fs_info->metadata_ratio)) in btrfs_chunk_alloc()
3701 force_metadata_allocation(fs_info); in btrfs_chunk_alloc()
3722 mutex_unlock(&fs_info->chunk_mutex); in btrfs_chunk_alloc()
3727 static u64 get_profile_num_devs(struct btrfs_fs_info *fs_info, u64 type) in get_profile_num_devs() argument
3733 num_dev = fs_info->fs_devices->rw_devices; in get_profile_num_devs()
3742 struct btrfs_fs_info *fs_info = trans->fs_info; in reserve_chunk_space() local
3751 lockdep_assert_held(&fs_info->chunk_mutex); in reserve_chunk_space()
3753 info = btrfs_find_space_info(fs_info, BTRFS_BLOCK_GROUP_SYSTEM); in reserve_chunk_space()
3758 if (left < bytes && btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { in reserve_chunk_space()
3759 btrfs_info(fs_info, "left=%llu, need=%llu, flags=%llu", in reserve_chunk_space()
3761 btrfs_dump_space_info(fs_info, info, 0, 0); in reserve_chunk_space()
3765 u64 flags = btrfs_system_alloc_profile(fs_info); in reserve_chunk_space()
3793 ret = btrfs_block_rsv_add(fs_info->chunk_root, in reserve_chunk_space()
3794 &fs_info->chunk_block_rsv, in reserve_chunk_space()
3807 struct btrfs_fs_info *fs_info = trans->fs_info; in check_system_chunk() local
3808 const u64 num_devs = get_profile_num_devs(fs_info, type); in check_system_chunk()
3812 bytes = btrfs_calc_metadata_size(fs_info, num_devs) + in check_system_chunk()
3813 btrfs_calc_insert_metadata_size(fs_info, 1); in check_system_chunk()
3837 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_reserve_chunk_metadata() local
3841 bytes = btrfs_calc_insert_metadata_size(fs_info, 1); in btrfs_reserve_chunk_metadata()
3843 bytes = btrfs_calc_metadata_size(fs_info, 1); in btrfs_reserve_chunk_metadata()
3845 mutex_lock(&fs_info->chunk_mutex); in btrfs_reserve_chunk_metadata()
3847 mutex_unlock(&fs_info->chunk_mutex); in btrfs_reserve_chunk_metadata()
3999 struct btrfs_fs_info *fs_info = block_group->fs_info; in btrfs_unfreeze_block_group() local
4010 em_tree = &fs_info->mapping_tree; in btrfs_unfreeze_block_group()