Lines Matching refs:root

122 				struct btrfs_root *root,
124 static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
1090 struct btrfs_root *root = device->dev_root; in btrfs_account_dev_extents_size() local
1112 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_account_dev_extents_size()
1116 ret = btrfs_previous_item(root, path, key.objectid, key.type); in btrfs_account_dev_extents_size()
1125 ret = btrfs_next_leaf(root, path); in btrfs_account_dev_extents_size()
1250 struct btrfs_root *root = device->dev_root; in find_free_dev_extent_start() local
1268 min_search_start = max(root->fs_info->alloc_start, 1024ull * 1024); in find_free_dev_extent_start()
1292 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in find_free_dev_extent_start()
1296 ret = btrfs_previous_item(root, path, key.objectid, key.type); in find_free_dev_extent_start()
1305 ret = btrfs_next_leaf(root, path); in find_free_dev_extent_start()
1421 struct btrfs_root *root = device->dev_root; in btrfs_free_dev_extent() local
1435 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_dev_extent()
1437 ret = btrfs_previous_item(root, path, key.objectid, in btrfs_free_dev_extent()
1455 btrfs_std_error(root->fs_info, ret, "Slot search failed"); in btrfs_free_dev_extent()
1461 ret = btrfs_del_item(trans, root, path); in btrfs_free_dev_extent()
1463 btrfs_std_error(root->fs_info, ret, in btrfs_free_dev_extent()
1480 struct btrfs_root *root = device->dev_root; in btrfs_alloc_dev_extent() local
1494 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_alloc_dev_extent()
1506 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, in btrfs_alloc_dev_extent()
1578 struct btrfs_root *root, in btrfs_add_device() argument
1588 root = root->fs_info->chunk_root; in btrfs_add_device()
1598 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_add_device()
1624 write_extent_buffer(leaf, root->fs_info->fsid, ptr, BTRFS_UUID_SIZE); in btrfs_add_device()
1649 static int btrfs_rm_dev_item(struct btrfs_root *root, in btrfs_rm_dev_item() argument
1657 root = root->fs_info->chunk_root; in btrfs_rm_dev_item()
1663 trans = btrfs_start_transaction(root, 0); 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()
1690 int btrfs_rm_device(struct btrfs_root *root, char *device_path) in btrfs_rm_device() argument
1709 seq = read_seqbegin(&root->fs_info->profiles_lock); in btrfs_rm_device()
1711 all_avail = root->fs_info->avail_data_alloc_bits | in btrfs_rm_device()
1712 root->fs_info->avail_system_alloc_bits | in btrfs_rm_device()
1713 root->fs_info->avail_metadata_alloc_bits; in btrfs_rm_device()
1714 } while (read_seqretry(&root->fs_info->profiles_lock, seq)); in btrfs_rm_device()
1716 num_devices = root->fs_info->fs_devices->num_devices; in btrfs_rm_device()
1717 btrfs_dev_replace_lock(&root->fs_info->dev_replace); in btrfs_rm_device()
1718 if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) { in btrfs_rm_device()
1722 btrfs_dev_replace_unlock(&root->fs_info->dev_replace); in btrfs_rm_device()
1735 root->fs_info->fs_devices->rw_devices <= 2) { in btrfs_rm_device()
1740 root->fs_info->fs_devices->rw_devices <= 3) { in btrfs_rm_device()
1750 devices = &root->fs_info->fs_devices->devices; in btrfs_rm_device()
1773 root->fs_info->bdev_holder, 0, in btrfs_rm_device()
1780 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_rm_device()
1793 if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) { in btrfs_rm_device()
1799 lock_chunks(root); in btrfs_rm_device()
1802 unlock_chunks(root); in btrfs_rm_device()
1817 ret = btrfs_rm_dev_item(root->fs_info->chunk_root, device); in btrfs_rm_device()
1822 btrfs_scrub_cancel_dev(root->fs_info, device); in btrfs_rm_device()
1835 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1844 next_device = list_entry(root->fs_info->fs_devices->devices.next, in btrfs_rm_device()
1846 if (device->bdev == root->fs_info->sb->s_bdev) in btrfs_rm_device()
1847 root->fs_info->sb->s_bdev = next_device->bdev; in btrfs_rm_device()
1848 if (device->bdev == root->fs_info->fs_devices->latest_bdev) in btrfs_rm_device()
1849 root->fs_info->fs_devices->latest_bdev = next_device->bdev; in btrfs_rm_device()
1854 btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); in btrfs_rm_device()
1859 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; in btrfs_rm_device()
1860 btrfs_set_super_num_devices(root->fs_info->super_copy, num_devices); in btrfs_rm_device()
1861 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1865 fs_devices = root->fs_info->fs_devices; in btrfs_rm_device()
1878 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_rm_device()
1879 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_rm_device()
1944 lock_chunks(root); in btrfs_rm_device()
1946 &root->fs_info->fs_devices->alloc_list); in btrfs_rm_device()
1948 unlock_chunks(root); in btrfs_rm_device()
2046 static int btrfs_find_device_by_path(struct btrfs_root *root, char *device_path, in btrfs_find_device_by_path() argument
2058 root->fs_info->bdev_holder, 0, &bdev, &bh); in btrfs_find_device_by_path()
2064 *device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_find_device_by_path()
2073 int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, in btrfs_find_device_missing_or_by_path() argument
2082 devices = &root->fs_info->fs_devices->devices; in btrfs_find_device_missing_or_by_path()
2099 return btrfs_find_device_by_path(root, device_path, device); in btrfs_find_device_missing_or_by_path()
2106 static int btrfs_prepare_sprout(struct btrfs_root *root) in btrfs_prepare_sprout() argument
2108 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_prepare_sprout()
2111 struct btrfs_super_block *disk_super = root->fs_info->super_copy; in btrfs_prepare_sprout()
2137 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2143 lock_chunks(root); in btrfs_prepare_sprout()
2145 unlock_chunks(root); in btrfs_prepare_sprout()
2155 memcpy(root->fs_info->fsid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_prepare_sprout()
2157 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2170 struct btrfs_root *root) in btrfs_finish_sprout() argument
2186 root = root->fs_info->chunk_root; in btrfs_finish_sprout()
2192 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_finish_sprout()
2199 ret = btrfs_next_leaf(root, path); in btrfs_finish_sprout()
2222 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_finish_sprout()
2241 int btrfs_init_new_device(struct btrfs_root *root, char *device_path) in btrfs_init_new_device() argument
2248 struct super_block *sb = root->fs_info->sb; in btrfs_init_new_device()
2254 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) in btrfs_init_new_device()
2258 root->fs_info->bdev_holder); in btrfs_init_new_device()
2262 if (root->fs_info->fs_devices->seeding) { in btrfs_init_new_device()
2270 devices = &root->fs_info->fs_devices->devices; in btrfs_init_new_device()
2272 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2277 &root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2281 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2283 device = btrfs_alloc_device(root->fs_info, NULL, NULL); in btrfs_init_new_device()
2298 trans = btrfs_start_transaction(root, 0); in btrfs_init_new_device()
2311 device->io_width = root->sectorsize; in btrfs_init_new_device()
2312 device->io_align = root->sectorsize; in btrfs_init_new_device()
2313 device->sector_size = root->sectorsize; in btrfs_init_new_device()
2317 device->dev_root = root->fs_info->dev_root; in btrfs_init_new_device()
2327 ret = btrfs_prepare_sprout(root); in btrfs_init_new_device()
2331 device->fs_devices = root->fs_info->fs_devices; in btrfs_init_new_device()
2333 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2334 lock_chunks(root); in btrfs_init_new_device()
2335 list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices); in btrfs_init_new_device()
2337 &root->fs_info->fs_devices->alloc_list); in btrfs_init_new_device()
2338 root->fs_info->fs_devices->num_devices++; in btrfs_init_new_device()
2339 root->fs_info->fs_devices->open_devices++; in btrfs_init_new_device()
2340 root->fs_info->fs_devices->rw_devices++; in btrfs_init_new_device()
2341 root->fs_info->fs_devices->total_devices++; in btrfs_init_new_device()
2342 root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; in btrfs_init_new_device()
2344 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2345 root->fs_info->free_chunk_space += device->total_bytes; in btrfs_init_new_device()
2346 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2349 root->fs_info->fs_devices->rotating = 1; in btrfs_init_new_device()
2351 tmp = btrfs_super_total_bytes(root->fs_info->super_copy); in btrfs_init_new_device()
2352 btrfs_set_super_total_bytes(root->fs_info->super_copy, in btrfs_init_new_device()
2355 tmp = btrfs_super_num_devices(root->fs_info->super_copy); in btrfs_init_new_device()
2356 btrfs_set_super_num_devices(root->fs_info->super_copy, in btrfs_init_new_device()
2360 btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device); in btrfs_init_new_device()
2366 btrfs_clear_space_info_full(root->fs_info); in btrfs_init_new_device()
2368 unlock_chunks(root); in btrfs_init_new_device()
2369 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2372 lock_chunks(root); in btrfs_init_new_device()
2373 ret = init_first_rw_device(trans, root, device); in btrfs_init_new_device()
2374 unlock_chunks(root); 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()
2400 root->fs_info->fsid); in btrfs_init_new_device()
2401 if (kobject_rename(&root->fs_info->fs_devices->fsid_kobj, in btrfs_init_new_device()
2403 btrfs_warn(root->fs_info, in btrfs_init_new_device()
2407 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_init_new_device()
2408 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_init_new_device()
2409 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2418 ret = btrfs_relocate_sys_chunks(root); in btrfs_init_new_device()
2420 btrfs_std_error(root->fs_info, ret, in btrfs_init_new_device()
2424 trans = btrfs_attach_transaction(root); 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()
2440 btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); in btrfs_init_new_device()
2451 int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path, in btrfs_init_dev_replace_tgtdev() argument
2458 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_init_dev_replace_tgtdev()
2514 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2517 device->io_width = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2518 device->io_align = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2519 device->sector_size = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2537 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2563 struct btrfs_root *root; in btrfs_update_device() local
2568 root = device->dev_root->fs_info->chunk_root; in btrfs_update_device()
2578 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_update_device()
2645 struct btrfs_root *root, u64 chunk_objectid, in btrfs_free_chunk() argument
2652 root = root->fs_info->chunk_root; in btrfs_free_chunk()
2661 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_chunk()
2665 btrfs_std_error(root->fs_info, -ENOENT, in btrfs_free_chunk()
2671 ret = btrfs_del_item(trans, root, path); in btrfs_free_chunk()
2673 btrfs_std_error(root->fs_info, ret, in btrfs_free_chunk()
2680 static int btrfs_del_sys_chunk(struct btrfs_root *root, u64 chunk_objectid, u64 in btrfs_del_sys_chunk() argument
2683 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_del_sys_chunk()
2694 lock_chunks(root); in btrfs_del_sys_chunk()
2724 unlock_chunks(root); in btrfs_del_sys_chunk()
2729 struct btrfs_root *root, u64 chunk_offset) in btrfs_remove_chunk() argument
2733 struct btrfs_root *extent_root = root->fs_info->extent_root; in btrfs_remove_chunk()
2740 root = root->fs_info->chunk_root; in btrfs_remove_chunk()
2741 em_tree = &root->fs_info->mapping_tree.map_tree; in btrfs_remove_chunk()
2760 lock_chunks(root->fs_info->chunk_root); in btrfs_remove_chunk()
2762 unlock_chunks(root->fs_info->chunk_root); in btrfs_remove_chunk()
2770 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2775 lock_chunks(root); in btrfs_remove_chunk()
2778 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2779 root->fs_info->free_chunk_space += dev_extent_len; in btrfs_remove_chunk()
2780 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2781 btrfs_clear_space_info_full(root->fs_info); in btrfs_remove_chunk()
2782 unlock_chunks(root); 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()
2799 trace_btrfs_chunk_free(root, map, chunk_offset, em->len); in btrfs_remove_chunk()
2802 ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2804 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2821 static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset) in btrfs_relocate_chunk() argument
2827 root = root->fs_info->chunk_root; in btrfs_relocate_chunk()
2828 extent_root = root->fs_info->extent_root; in btrfs_relocate_chunk()
2842 ASSERT(mutex_is_locked(&root->fs_info->delete_unused_bgs_mutex)); in btrfs_relocate_chunk()
2849 btrfs_scrub_pause(root); in btrfs_relocate_chunk()
2851 btrfs_scrub_continue(root); in btrfs_relocate_chunk()
2855 trans = btrfs_start_trans_remove_block_group(root->fs_info, in btrfs_relocate_chunk()
2859 btrfs_std_error(root->fs_info, ret, NULL); 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()
2872 static int btrfs_relocate_sys_chunks(struct btrfs_root *root) in btrfs_relocate_sys_chunks() argument
2874 struct btrfs_root *chunk_root = root->fs_info->chunk_root; in btrfs_relocate_sys_chunks()
2895 mutex_lock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2898 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2906 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2928 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2947 static int insert_balance_item(struct btrfs_root *root, in insert_balance_item() argument
2962 trans = btrfs_start_transaction(root, 0); 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()
3000 static int del_balance_item(struct btrfs_root *root) in del_balance_item() argument
3011 trans = btrfs_start_transaction(root, 0); 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()
3287 static int should_balance_chunk(struct btrfs_root *root, in should_balance_chunk() argument
3291 struct btrfs_balance_control *bctl = root->fs_info->balance_ctl; in should_balance_chunk()
3987 struct btrfs_root *root = fs_info->tree_root; in btrfs_uuid_scan_kthread() local
4013 ret = btrfs_search_forward(root, &key, path, 0); in btrfs_uuid_scan_kthread()
4248 struct btrfs_root *root = device->dev_root; in btrfs_shrink_device() local
4260 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_shrink_device()
4274 lock_chunks(root); in btrfs_shrink_device()
4279 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4280 root->fs_info->free_chunk_space -= diff; in btrfs_shrink_device()
4281 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4283 unlock_chunks(root); in btrfs_shrink_device()
4291 mutex_lock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4292 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_shrink_device()
4294 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4298 ret = btrfs_previous_item(root, path, 0, key.type); in btrfs_shrink_device()
4300 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4314 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4323 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4331 ret = btrfs_relocate_chunk(root, chunk_offset); in btrfs_shrink_device()
4332 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4349 trans = btrfs_start_transaction(root, 0); in btrfs_shrink_device()
4355 lock_chunks(root); in btrfs_shrink_device()
4375 unlock_chunks(root); in btrfs_shrink_device()
4379 ret = btrfs_commit_transaction(trans, root); in btrfs_shrink_device()
4389 &root->fs_info->fs_devices->resized_devices); in btrfs_shrink_device()
4393 unlock_chunks(root); in btrfs_shrink_device()
4397 btrfs_end_transaction(trans, root); in btrfs_shrink_device()
4401 lock_chunks(root); in btrfs_shrink_device()
4405 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4406 root->fs_info->free_chunk_space += diff; in btrfs_shrink_device()
4407 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4408 unlock_chunks(root); in btrfs_shrink_device()
4413 static int btrfs_add_system_chunk(struct btrfs_root *root, in btrfs_add_system_chunk() argument
4417 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_add_system_chunk()
4422 lock_chunks(root); in btrfs_add_system_chunk()
4426 unlock_chunks(root); in btrfs_add_system_chunk()
4437 unlock_chunks(root); in btrfs_add_system_chunk()
4903 struct btrfs_root *root, in init_first_rw_device() argument
4909 struct btrfs_fs_info *fs_info = root->fs_info; in init_first_rw_device()
4920 sys_chunk_offset = find_next_chunk(root->fs_info); in init_first_rw_device()
4945 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) in btrfs_chunk_readonly() argument
4949 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in btrfs_chunk_readonly()
5061 unsigned long btrfs_full_stripe_len(struct btrfs_root *root, in btrfs_full_stripe_len() argument
5068 unsigned long len = root->sectorsize; in btrfs_full_stripe_len()
5930 static noinline void btrfs_schedule_bio(struct btrfs_root *root, in btrfs_schedule_bio() argument
5956 atomic_inc(&root->fs_info->nr_async_bios); in btrfs_schedule_bio()
5979 btrfs_queue_work(root->fs_info->submit_workers, in btrfs_schedule_bio()
5983 static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, in submit_stripe_bio() argument
6008 btrfs_bio_counter_inc_noblocked(root->fs_info); in submit_stripe_bio()
6011 btrfs_schedule_bio(root, dev, rw, bio); in submit_stripe_bio()
6030 int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, in btrfs_map_bio() argument
6046 btrfs_bio_counter_inc_blocked(root->fs_info); in btrfs_map_bio()
6047 ret = __btrfs_map_block(root->fs_info, rw, logical, &map_length, &bbio, in btrfs_map_bio()
6050 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6058 bbio->fs_info = root->fs_info; in btrfs_map_bio()
6065 ret = raid56_parity_write(root, bio, bbio, map_length); in btrfs_map_bio()
6067 ret = raid56_parity_recover(root, bio, bbio, map_length, in btrfs_map_bio()
6071 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6076 btrfs_crit(root->fs_info, "mapping failed logical %llu bio len %llu len %llu", in btrfs_map_bio()
6094 submit_stripe_bio(root, bbio, bio, in btrfs_map_bio()
6098 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6122 static struct btrfs_device *add_missing_dev(struct btrfs_root *root, in add_missing_dev() argument
6193 static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, in read_one_chunk() argument
6197 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in read_one_chunk()
6255 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, in read_one_chunk()
6257 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { in read_one_chunk()
6263 add_missing_dev(root, root->fs_info->fs_devices, in read_one_chunk()
6269 btrfs_warn(root->fs_info, "devid %llu uuid %pU is missing", in read_one_chunk()
6307 static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root, in open_seed_devices() argument
6315 fs_devices = root->fs_info->fs_devices->seed; in open_seed_devices()
6325 if (!btrfs_test_opt(root, DEGRADED)) in open_seed_devices()
6342 root->fs_info->bdev_holder); in open_seed_devices()
6356 fs_devices->seed = root->fs_info->fs_devices->seed; in open_seed_devices()
6357 root->fs_info->fs_devices->seed = fs_devices; in open_seed_devices()
6362 static int read_one_dev(struct btrfs_root *root, in read_one_dev() argument
6366 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in read_one_dev()
6379 if (memcmp(fs_uuid, root->fs_info->fsid, BTRFS_UUID_SIZE)) { in read_one_dev()
6380 fs_devices = open_seed_devices(root, fs_uuid); in read_one_dev()
6385 device = btrfs_find_device(root->fs_info, devid, dev_uuid, fs_uuid); in read_one_dev()
6387 if (!btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6390 device = add_missing_dev(root, fs_devices, devid, dev_uuid); in read_one_dev()
6393 btrfs_warn(root->fs_info, "devid %llu uuid %pU missing", in read_one_dev()
6396 if (!device->bdev && !btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6425 if (device->fs_devices != root->fs_info->fs_devices) { in read_one_dev()
6436 spin_lock(&root->fs_info->free_chunk_lock); in read_one_dev()
6437 root->fs_info->free_chunk_space += device->total_bytes - in read_one_dev()
6439 spin_unlock(&root->fs_info->free_chunk_lock); in read_one_dev()
6445 int btrfs_read_sys_array(struct btrfs_root *root) in btrfs_read_sys_array() argument
6447 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_read_sys_array()
6460 ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize); in btrfs_read_sys_array()
6466 sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET); in btrfs_read_sys_array()
6470 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); in btrfs_read_sys_array()
6528 ret = read_one_chunk(root, &key, sb, chunk); in btrfs_read_sys_array()
6549 int btrfs_read_chunk_tree(struct btrfs_root *root) in btrfs_read_chunk_tree() argument
6558 root = root->fs_info->chunk_root; in btrfs_read_chunk_tree()
6565 lock_chunks(root); in btrfs_read_chunk_tree()
6576 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_read_chunk_tree()
6583 ret = btrfs_next_leaf(root, path); in btrfs_read_chunk_tree()
6595 ret = read_one_dev(root, leaf, dev_item); in btrfs_read_chunk_tree()
6601 ret = read_one_chunk(root, &found_key, leaf, chunk); in btrfs_read_chunk_tree()
6609 unlock_chunks(root); in btrfs_read_chunk_tree()
6830 int btrfs_get_dev_stats(struct btrfs_root *root, in btrfs_get_dev_stats() argument
6834 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_get_dev_stats()
6838 dev = btrfs_find_device(root->fs_info, stats->devid, NULL, NULL); in btrfs_get_dev_stats()
6842 btrfs_warn(root->fs_info, "get dev_stats failed, device not found"); in btrfs_get_dev_stats()
6845 btrfs_warn(root->fs_info, "get dev_stats failed, not yet valid"); in btrfs_get_dev_stats()
6919 void btrfs_update_commit_device_bytes_used(struct btrfs_root *root, in btrfs_update_commit_device_bytes_used() argument
6931 lock_chunks(root); in btrfs_update_commit_device_bytes_used()
6940 unlock_chunks(root); in btrfs_update_commit_device_bytes_used()