Lines Matching refs:fs_info

64 int btrfs_add_excluded_extent(struct btrfs_fs_info *fs_info,  in btrfs_add_excluded_extent()  argument
68 set_extent_bits(&fs_info->excluded_extents, start, end, in btrfs_add_excluded_extent()
75 struct btrfs_fs_info *fs_info = cache->fs_info; in btrfs_free_excluded_extents() local
81 clear_extent_bits(&fs_info->excluded_extents, start, end, in btrfs_free_excluded_extents()
86 int btrfs_lookup_data_extent(struct btrfs_fs_info *fs_info, u64 start, u64 len) in btrfs_lookup_data_extent() argument
99 ret = btrfs_search_slot(NULL, fs_info->extent_root, &key, path, 0, 0); in btrfs_lookup_data_extent()
114 struct btrfs_fs_info *fs_info, u64 bytenr, in btrfs_lookup_extent_info() argument
132 if (metadata && !btrfs_fs_incompat(fs_info, SKINNY_METADATA)) { in btrfs_lookup_extent_info()
133 offset = fs_info->nodesize; in btrfs_lookup_extent_info()
154 ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 0); in btrfs_lookup_extent_info()
165 key.offset == fs_info->nodesize) in btrfs_lookup_extent_info()
180 btrfs_print_v0_err(fs_info); in btrfs_lookup_extent_info()
184 btrfs_handle_fs_error(fs_info, ret, NULL); in btrfs_lookup_extent_info()
366 ASSERT(eb->fs_info); in btrfs_get_extent_inline_ref_type()
372 IS_ALIGNED(offset, eb->fs_info->sectorsize)) in btrfs_get_extent_inline_ref_type()
379 ASSERT(eb->fs_info); in btrfs_get_extent_inline_ref_type()
385 IS_ALIGNED(offset, eb->fs_info->sectorsize)) in btrfs_get_extent_inline_ref_type()
395 btrfs_err(eb->fs_info, in btrfs_get_extent_inline_ref_type()
444 struct btrfs_root *root = trans->fs_info->extent_root; in lookup_extent_data_ref()
520 struct btrfs_root *root = trans->fs_info->extent_root; in insert_extent_data_ref()
616 btrfs_print_v0_err(trans->fs_info); in remove_extent_data_ref()
627 ret = btrfs_del_item(trans, trans->fs_info->extent_root, path); in remove_extent_data_ref()
686 struct btrfs_root *root = trans->fs_info->extent_root; in lookup_tree_block_ref()
722 ret = btrfs_insert_empty_item(trans, trans->fs_info->extent_root, in insert_tree_block_ref()
787 struct btrfs_fs_info *fs_info = trans->fs_info; in lookup_inline_extent_backref() local
788 struct btrfs_root *root = fs_info->extent_root; in lookup_inline_extent_backref()
802 bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); in lookup_inline_extent_backref()
868 btrfs_print_v0_err(fs_info); in lookup_inline_extent_backref()
973 void setup_inline_extent_backref(struct btrfs_fs_info *fs_info, in setup_inline_extent_backref() argument
1150 btrfs_crit(trans->fs_info, in insert_inline_extent_backref()
1155 btrfs_crit(trans->fs_info, in insert_inline_extent_backref()
1164 setup_inline_extent_backref(trans->fs_info, path, iref, parent, in insert_inline_extent_backref()
1188 ret = btrfs_del_item(trans, trans->fs_info->extent_root, path); in remove_extent_backref()
1265 int btrfs_discard_extent(struct btrfs_fs_info *fs_info, u64 bytenr, in btrfs_discard_extent() argument
1279 btrfs_bio_counter_inc_blocked(fs_info); in btrfs_discard_extent()
1286 ret = btrfs_map_block(fs_info, BTRFS_MAP_DISCARD, cur, in btrfs_discard_extent()
1303 ASSERT(btrfs_test_opt(fs_info, DEGRADED)); in btrfs_discard_extent()
1342 btrfs_bio_counter_dec(fs_info); in btrfs_discard_extent()
1357 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_inc_extent_ref() local
1370 btrfs_ref_tree_mod(fs_info, generic_ref); in btrfs_inc_extent_ref()
1490 trace_run_delayed_data_ref(trans->fs_info, node, ref, node->action); in run_delayed_data_ref()
1540 struct btrfs_fs_info *fs_info = trans->fs_info; in run_delayed_extent_op() local
1553 if (metadata && !btrfs_fs_incompat(fs_info, SKINNY_METADATA)) in run_delayed_extent_op()
1572 ret = btrfs_search_slot(trans, fs_info->extent_root, &key, path, 0, 1); in run_delayed_extent_op()
1608 btrfs_print_v0_err(fs_info); in run_delayed_extent_op()
1633 trace_run_delayed_tree_ref(trans->fs_info, node, ref, node->action); in run_delayed_tree_ref()
1640 btrfs_err(trans->fs_info, in run_delayed_tree_ref()
1756 void btrfs_cleanup_ref_head_accounting(struct btrfs_fs_info *fs_info, in btrfs_cleanup_ref_head_accounting() argument
1770 nr_items += btrfs_csum_bytes_to_leaves(fs_info, head->num_bytes); in btrfs_cleanup_ref_head_accounting()
1783 btrfs_mod_total_bytes_pinned(fs_info, flags, -head->num_bytes); in btrfs_cleanup_ref_head_accounting()
1786 btrfs_delayed_refs_rsv_release(fs_info, nr_items); in btrfs_cleanup_ref_head_accounting()
1793 struct btrfs_fs_info *fs_info = trans->fs_info; in cleanup_ref_head() local
1802 btrfs_debug(fs_info, "run_delayed_extent_op returned %d", ret); in cleanup_ref_head()
1827 ret = btrfs_del_csums(trans, fs_info->csum_root, in cleanup_ref_head()
1832 btrfs_cleanup_ref_head_accounting(fs_info, delayed_refs, head); in cleanup_ref_head()
1834 trace_run_delayed_ref_head(fs_info, head, 0); in cleanup_ref_head()
1877 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_run_delayed_refs_for_head() local
1891 btrfs_check_delayed_seq(fs_info, ref->seq)) { in btrfs_run_delayed_refs_for_head()
1938 btrfs_debug(fs_info, "run_one_delayed_ref returned %d", in btrfs_run_delayed_refs_for_head()
1960 struct btrfs_fs_info *fs_info = trans->fs_info; in __btrfs_run_delayed_refs() local
2042 avg = fs_info->avg_delayed_ref_runtime * 3 + runtime; in __btrfs_run_delayed_refs()
2043 fs_info->avg_delayed_ref_runtime = avg >> 2; /* div by 4 */ in __btrfs_run_delayed_refs()
2096 u64 btrfs_csum_bytes_to_leaves(struct btrfs_fs_info *fs_info, u64 csum_bytes) in btrfs_csum_bytes_to_leaves() argument
2102 csum_size = BTRFS_MAX_ITEM_SIZE(fs_info); in btrfs_csum_bytes_to_leaves()
2104 (u64)btrfs_super_csum_size(fs_info->super_copy)); in btrfs_csum_bytes_to_leaves()
2105 num_csums = div64_u64(csum_bytes, fs_info->sectorsize); in btrfs_csum_bytes_to_leaves()
2124 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_run_delayed_refs() local
2135 if (test_bit(BTRFS_FS_CREATING_FREE_SPACE_TREE, &fs_info->flags)) in btrfs_run_delayed_refs()
2213 spin_lock(&root->fs_info->trans_lock); in check_delayed_ref()
2214 cur_trans = root->fs_info->running_transaction; in check_delayed_ref()
2217 spin_unlock(&root->fs_info->trans_lock); in check_delayed_ref()
2286 struct btrfs_fs_info *fs_info = root->fs_info; in check_committed_ref() local
2287 struct btrfs_root *extent_root = fs_info->extent_root; in check_committed_ref()
2387 struct btrfs_fs_info *fs_info = root->fs_info; in __btrfs_mod_ref() local
2402 if (btrfs_is_testing(fs_info)) in __btrfs_mod_ref()
2451 num_bytes = fs_info->nodesize; in __btrfs_mod_ref()
2482 int btrfs_extent_readonly(struct btrfs_fs_info *fs_info, u64 bytenr) in btrfs_extent_readonly() argument
2487 block_group = btrfs_lookup_block_group(fs_info, bytenr); in btrfs_extent_readonly()
2497 struct btrfs_fs_info *fs_info = root->fs_info; in get_alloc_profile_by_root() local
2503 else if (root == fs_info->chunk_root) in get_alloc_profile_by_root()
2508 ret = btrfs_get_alloc_profile(fs_info, flags); in get_alloc_profile_by_root()
2512 static u64 first_logical_byte(struct btrfs_fs_info *fs_info, u64 search_start) in first_logical_byte() argument
2517 spin_lock(&fs_info->block_group_cache_lock); in first_logical_byte()
2518 bytenr = fs_info->first_logical_byte; in first_logical_byte()
2519 spin_unlock(&fs_info->block_group_cache_lock); in first_logical_byte()
2524 cache = btrfs_lookup_first_block_group(fs_info, search_start); in first_logical_byte()
2538 struct btrfs_fs_info *fs_info = cache->fs_info; in pin_down_extent() local
2543 btrfs_space_info_update_bytes_pinned(fs_info, cache->space_info, in pin_down_extent()
2563 cache = btrfs_lookup_block_group(trans->fs_info, bytenr); in btrfs_pin_extent()
2581 btrfs_add_excluded_extent(trans->fs_info, bytenr, num_bytes); in btrfs_pin_extent_for_log_replay()
2583 cache = btrfs_lookup_block_group(trans->fs_info, bytenr); in btrfs_pin_extent_for_log_replay()
2603 static int __exclude_logged_extent(struct btrfs_fs_info *fs_info, in __exclude_logged_extent() argument
2610 block_group = btrfs_lookup_block_group(fs_info, start); in __exclude_logged_extent()
2625 ret = btrfs_add_excluded_extent(fs_info, start, in __exclude_logged_extent()
2640 ret = btrfs_add_excluded_extent(fs_info, start, in __exclude_logged_extent()
2653 struct btrfs_fs_info *fs_info = eb->fs_info; in btrfs_exclude_logged_extents() local
2660 if (!btrfs_fs_incompat(fs_info, MIXED_GROUPS)) in btrfs_exclude_logged_extents()
2675 ret = __exclude_logged_extent(fs_info, key.objectid, key.offset); in btrfs_exclude_logged_extents()
2694 fetch_cluster_info(struct btrfs_fs_info *fs_info, in fetch_cluster_info() argument
2704 ret = &fs_info->meta_alloc_cluster; in fetch_cluster_info()
2705 if (btrfs_test_opt(fs_info, SSD)) in fetch_cluster_info()
2710 btrfs_test_opt(fs_info, SSD_SPREAD)) { in fetch_cluster_info()
2712 ret = &fs_info->data_alloc_cluster; in fetch_cluster_info()
2718 static int unpin_extent_range(struct btrfs_fs_info *fs_info, in unpin_extent_range() argument
2724 struct btrfs_block_rsv *global_rsv = &fs_info->global_block_rsv; in unpin_extent_range()
2738 cache = btrfs_lookup_block_group(fs_info, start); in unpin_extent_range()
2741 cluster = fetch_cluster_info(fs_info, in unpin_extent_range()
2776 btrfs_space_info_update_bytes_pinned(fs_info, space_info, -len); in unpin_extent_range()
2793 btrfs_space_info_update_bytes_may_use(fs_info, in unpin_extent_range()
2803 btrfs_try_granting_tickets(fs_info, space_info); in unpin_extent_range()
2814 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_finish_extent_commit() local
2827 mutex_lock(&fs_info->unused_bg_unpin_mutex); in btrfs_finish_extent_commit()
2831 mutex_unlock(&fs_info->unused_bg_unpin_mutex); in btrfs_finish_extent_commit()
2834 if (test_bit(BTRFS_FS_LOG_RECOVERING, &fs_info->flags)) in btrfs_finish_extent_commit()
2835 clear_extent_bits(&fs_info->excluded_extents, start, in btrfs_finish_extent_commit()
2838 if (btrfs_test_opt(fs_info, DISCARD_SYNC)) in btrfs_finish_extent_commit()
2839 ret = btrfs_discard_extent(fs_info, start, in btrfs_finish_extent_commit()
2843 unpin_extent_range(fs_info, start, end, true); in btrfs_finish_extent_commit()
2844 mutex_unlock(&fs_info->unused_bg_unpin_mutex); in btrfs_finish_extent_commit()
2849 if (btrfs_test_opt(fs_info, DISCARD_ASYNC)) { in btrfs_finish_extent_commit()
2850 btrfs_discard_calc_delay(&fs_info->discard_ctl); in btrfs_finish_extent_commit()
2851 btrfs_discard_schedule_work(&fs_info->discard_ctl, true); in btrfs_finish_extent_commit()
2865 ret = btrfs_discard_extent(fs_info, in btrfs_finish_extent_commit()
2876 btrfs_warn(fs_info, in btrfs_finish_extent_commit()
2950 struct btrfs_fs_info *info = trans->fs_info; in __btrfs_free_extent()
3298 btrfs_cleanup_ref_head_accounting(trans->fs_info, delayed_refs, head); in check_ref_cleanup()
3315 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_free_tree_block() local
3325 btrfs_ref_tree_mod(fs_info, &generic_ref); in btrfs_free_tree_block()
3339 cache = btrfs_lookup_block_group(fs_info, buf->start); in btrfs_free_tree_block()
3352 trace_btrfs_reserved_extent_free(fs_info, buf->start, buf->len); in btrfs_free_tree_block()
3367 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_free_extent() local
3370 if (btrfs_is_testing(fs_info)) in btrfs_free_extent()
3394 btrfs_ref_tree_mod(fs_info, ref); in btrfs_free_extent()
3798 static int find_free_extent_update_loop(struct btrfs_fs_info *fs_info, in find_free_extent_update_loop() argument
3803 struct btrfs_root *root = fs_info->extent_root; in find_free_extent_update_loop()
3896 static int prepare_allocation_clustered(struct btrfs_fs_info *fs_info, in prepare_allocation_clustered() argument
3924 ffe_ctl->last_ptr = fetch_cluster_info(fs_info, space_info, in prepare_allocation_clustered()
3947 static int prepare_allocation(struct btrfs_fs_info *fs_info, in prepare_allocation() argument
3954 return prepare_allocation_clustered(fs_info, ffe_ctl, in prepare_allocation()
3991 struct btrfs_fs_info *fs_info = root->fs_info; in find_free_extent() local
3999 WARN_ON(num_bytes < fs_info->sectorsize); in find_free_extent()
4025 space_info = btrfs_find_space_info(fs_info, flags); in find_free_extent()
4027 btrfs_err(fs_info, "No space info for %llu", flags); in find_free_extent()
4031 ret = prepare_allocation(fs_info, &ffe_ctl, space_info, ins); in find_free_extent()
4036 first_logical_byte(fs_info, 0)); in find_free_extent()
4039 block_group = btrfs_lookup_block_group(fs_info, in find_free_extent()
4156 fs_info->stripesize); in find_free_extent()
4193 ret = find_free_extent_update_loop(fs_info, ins, &ffe_ctl, full_search); in find_free_extent()
4264 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_reserve_extent() local
4271 WARN_ON(num_bytes < fs_info->sectorsize); in btrfs_reserve_extent()
4275 btrfs_dec_block_group_reservations(fs_info, ins->objectid); in btrfs_reserve_extent()
4280 fs_info->sectorsize); in btrfs_reserve_extent()
4286 } else if (btrfs_test_opt(fs_info, ENOSPC_DEBUG)) { in btrfs_reserve_extent()
4289 sinfo = btrfs_find_space_info(fs_info, flags); in btrfs_reserve_extent()
4290 btrfs_err(fs_info, in btrfs_reserve_extent()
4294 btrfs_dump_space_info(fs_info, sinfo, in btrfs_reserve_extent()
4302 int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info, in btrfs_free_reserved_extent() argument
4307 cache = btrfs_lookup_block_group(fs_info, start); in btrfs_free_reserved_extent()
4309 btrfs_err(fs_info, "Unable to find block group for %llu", in btrfs_free_reserved_extent()
4316 trace_btrfs_reserved_extent_free(fs_info, start, len); in btrfs_free_reserved_extent()
4328 cache = btrfs_lookup_block_group(trans->fs_info, start); in btrfs_pin_reserved_extent()
4330 btrfs_err(trans->fs_info, "unable to find block group for %llu", in btrfs_pin_reserved_extent()
4345 struct btrfs_fs_info *fs_info = trans->fs_info; in alloc_reserved_file_extent() local
4366 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, in alloc_reserved_file_extent()
4406 btrfs_err(fs_info, "update block group failed for %llu %llu", in alloc_reserved_file_extent()
4410 trace_btrfs_reserved_extent_alloc(fs_info, ins->objectid, ins->offset); in alloc_reserved_file_extent()
4418 struct btrfs_fs_info *fs_info = trans->fs_info; in alloc_reserved_tree_block() local
4430 bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); in alloc_reserved_tree_block()
4438 num_bytes = fs_info->nodesize; in alloc_reserved_tree_block()
4451 ret = btrfs_insert_empty_item(trans, fs_info->extent_root, path, in alloc_reserved_tree_block()
4495 fs_info->nodesize, 1); in alloc_reserved_tree_block()
4497 btrfs_err(fs_info, "update block group failed for %llu %llu", in alloc_reserved_tree_block()
4502 trace_btrfs_reserved_extent_alloc(fs_info, extent_key.objectid, in alloc_reserved_tree_block()
4503 fs_info->nodesize); in alloc_reserved_tree_block()
4519 btrfs_ref_tree_mod(root->fs_info, &generic_ref); in btrfs_alloc_reserved_file_extent()
4533 struct btrfs_fs_info *fs_info = trans->fs_info; in btrfs_alloc_logged_file_extent() local
4542 if (!btrfs_fs_incompat(fs_info, MIXED_GROUPS)) { in btrfs_alloc_logged_file_extent()
4543 ret = __exclude_logged_extent(fs_info, ins->objectid, in btrfs_alloc_logged_file_extent()
4549 block_group = btrfs_lookup_block_group(fs_info, ins->objectid); in btrfs_alloc_logged_file_extent()
4574 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_init_new_buffer() local
4577 buf = btrfs_find_create_tree_block(fs_info, bytenr); in btrfs_init_new_buffer()
4587 btrfs_err_rl(fs_info, in btrfs_init_new_buffer()
4608 write_extent_buffer_fsid(buf, fs_info->fs_devices->metadata_uuid); in btrfs_init_new_buffer()
4609 write_extent_buffer_chunk_tree_uuid(buf, fs_info->chunk_tree_uuid); in btrfs_init_new_buffer()
4644 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_alloc_tree_block() local
4652 u32 blocksize = fs_info->nodesize; in btrfs_alloc_tree_block()
4653 bool skinny_metadata = btrfs_fs_incompat(fs_info, SKINNY_METADATA); in btrfs_alloc_tree_block()
4656 if (btrfs_is_testing(fs_info)) { in btrfs_alloc_tree_block()
4708 btrfs_ref_tree_mod(fs_info, &generic_ref); in btrfs_alloc_tree_block()
4721 btrfs_free_reserved_extent(fs_info, ins.objectid, ins.offset, 0); in btrfs_alloc_tree_block()
4723 btrfs_unuse_block_rsv(fs_info, block_rsv, blocksize); in btrfs_alloc_tree_block()
4751 struct btrfs_fs_info *fs_info = root->fs_info; in reada_walk_down() local
4769 BTRFS_NODEPTRS_PER_BLOCK(fs_info)); in reada_walk_down()
4791 ret = btrfs_lookup_extent_info(trans, fs_info, bytenr, in reada_walk_down()
4820 readahead_tree_block(fs_info, bytenr); in reada_walk_down()
4839 struct btrfs_fs_info *fs_info = root->fs_info; in walk_down_proc() local
4857 ret = btrfs_lookup_extent_info(trans, fs_info, in walk_down_proc()
4919 root->fs_info->nodesize, parent, in check_ref_exists()
4947 struct btrfs_fs_info *fs_info = root->fs_info; in do_walk_down() local
4977 next = find_extent_buffer(fs_info, bytenr); in do_walk_down()
4979 next = btrfs_find_create_tree_block(fs_info, bytenr); in do_walk_down()
4990 ret = btrfs_lookup_extent_info(trans, fs_info, bytenr, level - 1, 1, in do_walk_down()
4997 btrfs_err(fs_info, "Missing references."); in do_walk_down()
5039 next = read_tree_block(fs_info, bytenr, generation, level - 1, in do_walk_down()
5054 btrfs_err(root->fs_info, "mismatched level"); in do_walk_down()
5076 btrfs_err(root->fs_info, in do_walk_down()
5111 btrfs_err_rl(fs_info, in do_walk_down()
5127 fs_info->nodesize, parent); in do_walk_down()
5161 struct btrfs_fs_info *fs_info = root->fs_info; in walk_up_proc() local
5191 ret = btrfs_lookup_extent_info(trans, fs_info, in walk_up_proc()
5222 btrfs_err_rl(fs_info, in walk_up_proc()
5258 btrfs_err_rl(fs_info, "unexpected tree owner, have %llu expect %llu", in walk_up_proc()
5345 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_drop_snapshot() local
5348 struct btrfs_root *tree_root = fs_info->tree_root; in btrfs_drop_snapshot()
5357 btrfs_debug(fs_info, "Drop subvolume %llu", root->root_key.objectid); in btrfs_drop_snapshot()
5434 ret = btrfs_lookup_extent_info(trans, fs_info, in btrfs_drop_snapshot()
5460 wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(fs_info); in btrfs_drop_snapshot()
5493 (!for_reloc && btrfs_need_cleaner_sleep(fs_info))) { in btrfs_drop_snapshot()
5504 if (!for_reloc && btrfs_need_cleaner_sleep(fs_info)) { in btrfs_drop_snapshot()
5505 btrfs_debug(fs_info, in btrfs_drop_snapshot()
5597 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_drop_subtree() local
5636 wc->reada_count = BTRFS_NODEPTRS_PER_BLOCK(fs_info); in btrfs_drop_subtree()
5691 int btrfs_error_unpin_extent_range(struct btrfs_fs_info *fs_info, in btrfs_error_unpin_extent_range() argument
5694 return unpin_extent_range(fs_info, start, end, false); in btrfs_error_unpin_extent_range()
5739 struct btrfs_fs_info *fs_info = device->fs_info; in btrfs_trim_free_extents() local
5742 ret = mutex_lock_interruptible(&fs_info->chunk_mutex); in btrfs_trim_free_extents()
5753 btrfs_warn_in_rcu(fs_info, in btrfs_trim_free_extents()
5758 mutex_unlock(&fs_info->chunk_mutex); in btrfs_trim_free_extents()
5777 mutex_unlock(&fs_info->chunk_mutex); in btrfs_trim_free_extents()
5788 mutex_unlock(&fs_info->chunk_mutex); in btrfs_trim_free_extents()
5816 int btrfs_trim_fs(struct btrfs_fs_info *fs_info, struct fstrim_range *range) in btrfs_trim_fs() argument
5840 cache = btrfs_lookup_first_block_group(fs_info, range->start); in btrfs_trim_fs()
5881 btrfs_warn(fs_info, in btrfs_trim_fs()
5884 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_trim_fs()
5885 devices = &fs_info->fs_devices->devices; in btrfs_trim_fs()
5899 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_trim_fs()
5902 btrfs_warn(fs_info, in btrfs_trim_fs()