• Home
  • Raw
  • Download

Lines Matching refs:root

122 				struct btrfs_root *root,
124 static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
1091 struct btrfs_root *root = device->dev_root; in btrfs_account_dev_extents_size() local
1113 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_account_dev_extents_size()
1117 ret = btrfs_previous_item(root, path, key.objectid, key.type); in btrfs_account_dev_extents_size()
1126 ret = btrfs_next_leaf(root, path); in btrfs_account_dev_extents_size()
1251 struct btrfs_root *root = device->dev_root; in find_free_dev_extent_start() local
1269 min_search_start = max(root->fs_info->alloc_start, 1024ull * 1024); in find_free_dev_extent_start()
1293 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in find_free_dev_extent_start()
1297 ret = btrfs_previous_item(root, path, key.objectid, key.type); in find_free_dev_extent_start()
1306 ret = btrfs_next_leaf(root, path); in find_free_dev_extent_start()
1422 struct btrfs_root *root = device->dev_root; in btrfs_free_dev_extent() local
1436 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_dev_extent()
1438 ret = btrfs_previous_item(root, path, key.objectid, in btrfs_free_dev_extent()
1456 btrfs_std_error(root->fs_info, ret, "Slot search failed"); in btrfs_free_dev_extent()
1462 ret = btrfs_del_item(trans, root, path); in btrfs_free_dev_extent()
1464 btrfs_std_error(root->fs_info, ret, in btrfs_free_dev_extent()
1481 struct btrfs_root *root = device->dev_root; in btrfs_alloc_dev_extent() local
1495 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_alloc_dev_extent()
1507 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, in btrfs_alloc_dev_extent()
1579 struct btrfs_root *root, in btrfs_add_device() argument
1589 root = root->fs_info->chunk_root; in btrfs_add_device()
1599 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_add_device()
1625 write_extent_buffer(leaf, root->fs_info->fsid, ptr, BTRFS_UUID_SIZE); in btrfs_add_device()
1650 static int btrfs_rm_dev_item(struct btrfs_root *root, in btrfs_rm_dev_item() argument
1658 root = root->fs_info->chunk_root; in btrfs_rm_dev_item()
1664 trans = btrfs_start_transaction(root, 0); in btrfs_rm_dev_item()
1673 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_rm_dev_item()
1682 ret = btrfs_del_item(trans, root, path); in btrfs_rm_dev_item()
1687 btrfs_commit_transaction(trans, root); in btrfs_rm_dev_item()
1691 int btrfs_rm_device(struct btrfs_root *root, char *device_path) in btrfs_rm_device() argument
1710 seq = read_seqbegin(&root->fs_info->profiles_lock); in btrfs_rm_device()
1712 all_avail = root->fs_info->avail_data_alloc_bits | in btrfs_rm_device()
1713 root->fs_info->avail_system_alloc_bits | in btrfs_rm_device()
1714 root->fs_info->avail_metadata_alloc_bits; in btrfs_rm_device()
1715 } while (read_seqretry(&root->fs_info->profiles_lock, seq)); in btrfs_rm_device()
1717 num_devices = root->fs_info->fs_devices->num_devices; in btrfs_rm_device()
1718 btrfs_dev_replace_lock(&root->fs_info->dev_replace); in btrfs_rm_device()
1719 if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) { in btrfs_rm_device()
1723 btrfs_dev_replace_unlock(&root->fs_info->dev_replace); in btrfs_rm_device()
1736 root->fs_info->fs_devices->rw_devices <= 2) { in btrfs_rm_device()
1741 root->fs_info->fs_devices->rw_devices <= 3) { in btrfs_rm_device()
1751 devices = &root->fs_info->fs_devices->devices; in btrfs_rm_device()
1774 root->fs_info->bdev_holder, 0, in btrfs_rm_device()
1781 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_rm_device()
1794 if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) { in btrfs_rm_device()
1800 lock_chunks(root); in btrfs_rm_device()
1803 unlock_chunks(root); in btrfs_rm_device()
1818 ret = btrfs_rm_dev_item(root->fs_info->chunk_root, device); in btrfs_rm_device()
1823 btrfs_scrub_cancel_dev(root->fs_info, device); in btrfs_rm_device()
1836 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1845 next_device = list_entry(root->fs_info->fs_devices->devices.next, in btrfs_rm_device()
1847 if (device->bdev == root->fs_info->sb->s_bdev) in btrfs_rm_device()
1848 root->fs_info->sb->s_bdev = next_device->bdev; in btrfs_rm_device()
1849 if (device->bdev == root->fs_info->fs_devices->latest_bdev) in btrfs_rm_device()
1850 root->fs_info->fs_devices->latest_bdev = next_device->bdev; in btrfs_rm_device()
1855 btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); in btrfs_rm_device()
1860 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; in btrfs_rm_device()
1861 btrfs_set_super_num_devices(root->fs_info->super_copy, num_devices); in btrfs_rm_device()
1862 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1866 fs_devices = root->fs_info->fs_devices; in btrfs_rm_device()
1879 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_rm_device()
1880 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_rm_device()
1945 lock_chunks(root); in btrfs_rm_device()
1947 &root->fs_info->fs_devices->alloc_list); in btrfs_rm_device()
1949 unlock_chunks(root); in btrfs_rm_device()
2047 static int btrfs_find_device_by_path(struct btrfs_root *root, char *device_path, in btrfs_find_device_by_path() argument
2059 root->fs_info->bdev_holder, 0, &bdev, &bh); in btrfs_find_device_by_path()
2065 *device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_find_device_by_path()
2074 int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, in btrfs_find_device_missing_or_by_path() argument
2083 devices = &root->fs_info->fs_devices->devices; in btrfs_find_device_missing_or_by_path()
2100 return btrfs_find_device_by_path(root, device_path, device); in btrfs_find_device_missing_or_by_path()
2107 static int btrfs_prepare_sprout(struct btrfs_root *root) in btrfs_prepare_sprout() argument
2109 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_prepare_sprout()
2112 struct btrfs_super_block *disk_super = root->fs_info->super_copy; in btrfs_prepare_sprout()
2138 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2144 lock_chunks(root); in btrfs_prepare_sprout()
2146 unlock_chunks(root); in btrfs_prepare_sprout()
2156 memcpy(root->fs_info->fsid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_prepare_sprout()
2158 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2171 struct btrfs_root *root) in btrfs_finish_sprout() argument
2187 root = root->fs_info->chunk_root; in btrfs_finish_sprout()
2193 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_finish_sprout()
2200 ret = btrfs_next_leaf(root, path); in btrfs_finish_sprout()
2223 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_finish_sprout()
2242 int btrfs_init_new_device(struct btrfs_root *root, char *device_path) in btrfs_init_new_device() argument
2249 struct super_block *sb = root->fs_info->sb; in btrfs_init_new_device()
2255 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) in btrfs_init_new_device()
2259 root->fs_info->bdev_holder); in btrfs_init_new_device()
2263 if (root->fs_info->fs_devices->seeding) { in btrfs_init_new_device()
2271 devices = &root->fs_info->fs_devices->devices; in btrfs_init_new_device()
2273 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2278 &root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2282 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2284 device = btrfs_alloc_device(root->fs_info, NULL, NULL); in btrfs_init_new_device()
2299 trans = btrfs_start_transaction(root, 0); in btrfs_init_new_device()
2312 device->io_width = root->sectorsize; in btrfs_init_new_device()
2313 device->io_align = root->sectorsize; in btrfs_init_new_device()
2314 device->sector_size = root->sectorsize; in btrfs_init_new_device()
2318 device->dev_root = root->fs_info->dev_root; in btrfs_init_new_device()
2328 ret = btrfs_prepare_sprout(root); in btrfs_init_new_device()
2332 device->fs_devices = root->fs_info->fs_devices; in btrfs_init_new_device()
2334 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2335 lock_chunks(root); in btrfs_init_new_device()
2336 list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices); in btrfs_init_new_device()
2338 &root->fs_info->fs_devices->alloc_list); in btrfs_init_new_device()
2339 root->fs_info->fs_devices->num_devices++; in btrfs_init_new_device()
2340 root->fs_info->fs_devices->open_devices++; in btrfs_init_new_device()
2341 root->fs_info->fs_devices->rw_devices++; in btrfs_init_new_device()
2342 root->fs_info->fs_devices->total_devices++; in btrfs_init_new_device()
2343 root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; in btrfs_init_new_device()
2345 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2346 root->fs_info->free_chunk_space += device->total_bytes; in btrfs_init_new_device()
2347 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2350 root->fs_info->fs_devices->rotating = 1; in btrfs_init_new_device()
2352 tmp = btrfs_super_total_bytes(root->fs_info->super_copy); in btrfs_init_new_device()
2353 btrfs_set_super_total_bytes(root->fs_info->super_copy, in btrfs_init_new_device()
2356 tmp = btrfs_super_num_devices(root->fs_info->super_copy); in btrfs_init_new_device()
2357 btrfs_set_super_num_devices(root->fs_info->super_copy, in btrfs_init_new_device()
2364 btrfs_clear_space_info_full(root->fs_info); in btrfs_init_new_device()
2366 unlock_chunks(root); in btrfs_init_new_device()
2369 btrfs_sysfs_add_device_link(root->fs_info->fs_devices, device); in btrfs_init_new_device()
2371 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2374 lock_chunks(root); in btrfs_init_new_device()
2375 ret = init_first_rw_device(trans, root, device); in btrfs_init_new_device()
2376 unlock_chunks(root); in btrfs_init_new_device()
2378 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2383 ret = btrfs_add_device(trans, root, device); in btrfs_init_new_device()
2385 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2392 ret = btrfs_finish_sprout(trans, root); in btrfs_init_new_device()
2394 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2402 root->fs_info->fsid); in btrfs_init_new_device()
2403 if (kobject_rename(&root->fs_info->fs_devices->fsid_kobj, in btrfs_init_new_device()
2405 btrfs_warn(root->fs_info, in btrfs_init_new_device()
2409 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_init_new_device()
2410 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_init_new_device()
2411 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2420 ret = btrfs_relocate_sys_chunks(root); in btrfs_init_new_device()
2422 btrfs_std_error(root->fs_info, ret, in btrfs_init_new_device()
2426 trans = btrfs_attach_transaction(root); in btrfs_init_new_device()
2432 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2440 btrfs_end_transaction(trans, root); in btrfs_init_new_device()
2442 btrfs_sysfs_rm_device_link(root->fs_info->fs_devices, device); in btrfs_init_new_device()
2453 int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path, in btrfs_init_dev_replace_tgtdev() argument
2460 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_init_dev_replace_tgtdev()
2516 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2519 device->io_width = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2520 device->io_align = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2521 device->sector_size = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2539 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2565 struct btrfs_root *root; in btrfs_update_device() local
2570 root = device->dev_root->fs_info->chunk_root; in btrfs_update_device()
2580 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_update_device()
2647 struct btrfs_root *root, u64 chunk_objectid, in btrfs_free_chunk() argument
2654 root = root->fs_info->chunk_root; in btrfs_free_chunk()
2663 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_chunk()
2667 btrfs_std_error(root->fs_info, -ENOENT, in btrfs_free_chunk()
2673 ret = btrfs_del_item(trans, root, path); in btrfs_free_chunk()
2675 btrfs_std_error(root->fs_info, ret, in btrfs_free_chunk()
2682 static int btrfs_del_sys_chunk(struct btrfs_root *root, u64 chunk_objectid, u64 in btrfs_del_sys_chunk() argument
2685 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_del_sys_chunk()
2696 lock_chunks(root); in btrfs_del_sys_chunk()
2726 unlock_chunks(root); in btrfs_del_sys_chunk()
2731 struct btrfs_root *root, u64 chunk_offset) in btrfs_remove_chunk() argument
2735 struct btrfs_root *extent_root = root->fs_info->extent_root; in btrfs_remove_chunk()
2742 root = root->fs_info->chunk_root; in btrfs_remove_chunk()
2743 em_tree = &root->fs_info->mapping_tree.map_tree; in btrfs_remove_chunk()
2762 lock_chunks(root->fs_info->chunk_root); in btrfs_remove_chunk()
2764 unlock_chunks(root->fs_info->chunk_root); in btrfs_remove_chunk()
2772 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2777 lock_chunks(root); in btrfs_remove_chunk()
2780 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2781 root->fs_info->free_chunk_space += dev_extent_len; in btrfs_remove_chunk()
2782 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2783 btrfs_clear_space_info_full(root->fs_info); in btrfs_remove_chunk()
2784 unlock_chunks(root); in btrfs_remove_chunk()
2790 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2795 ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2797 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2801 trace_btrfs_chunk_free(root, map, chunk_offset, em->len); in btrfs_remove_chunk()
2804 ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2806 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2823 static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset) in btrfs_relocate_chunk() argument
2829 root = root->fs_info->chunk_root; in btrfs_relocate_chunk()
2830 extent_root = root->fs_info->extent_root; in btrfs_relocate_chunk()
2844 ASSERT(mutex_is_locked(&root->fs_info->delete_unused_bgs_mutex)); in btrfs_relocate_chunk()
2851 btrfs_scrub_pause(root); in btrfs_relocate_chunk()
2853 btrfs_scrub_continue(root); in btrfs_relocate_chunk()
2857 trans = btrfs_start_trans_remove_block_group(root->fs_info, in btrfs_relocate_chunk()
2861 btrfs_std_error(root->fs_info, ret, NULL); in btrfs_relocate_chunk()
2869 ret = btrfs_remove_chunk(trans, root, chunk_offset); in btrfs_relocate_chunk()
2870 btrfs_end_transaction(trans, root); in btrfs_relocate_chunk()
2874 static int btrfs_relocate_sys_chunks(struct btrfs_root *root) in btrfs_relocate_sys_chunks() argument
2876 struct btrfs_root *chunk_root = root->fs_info->chunk_root; in btrfs_relocate_sys_chunks()
2897 mutex_lock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2900 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2908 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2930 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_relocate_sys_chunks()
2949 static int insert_balance_item(struct btrfs_root *root, in insert_balance_item() argument
2964 trans = btrfs_start_transaction(root, 0); in insert_balance_item()
2974 ret = btrfs_insert_empty_item(trans, root, path, &key, in insert_balance_item()
2996 err = btrfs_commit_transaction(trans, root); in insert_balance_item()
3002 static int del_balance_item(struct btrfs_root *root) in del_balance_item() argument
3013 trans = btrfs_start_transaction(root, 0); in del_balance_item()
3023 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in del_balance_item()
3031 ret = btrfs_del_item(trans, root, path); in del_balance_item()
3034 err = btrfs_commit_transaction(trans, root); in del_balance_item()
3289 static int should_balance_chunk(struct btrfs_root *root, in should_balance_chunk() argument
3293 struct btrfs_balance_control *bctl = root->fs_info->balance_ctl; in should_balance_chunk()
3998 struct btrfs_root *root = fs_info->tree_root; in btrfs_uuid_scan_kthread() local
4024 ret = btrfs_search_forward(root, &key, path, 0); in btrfs_uuid_scan_kthread()
4260 struct btrfs_root *root = device->dev_root; in btrfs_shrink_device() local
4272 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_shrink_device()
4286 lock_chunks(root); in btrfs_shrink_device()
4291 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4292 root->fs_info->free_chunk_space -= diff; in btrfs_shrink_device()
4293 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4295 unlock_chunks(root); in btrfs_shrink_device()
4303 mutex_lock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4304 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_shrink_device()
4306 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4310 ret = btrfs_previous_item(root, path, 0, key.type); in btrfs_shrink_device()
4312 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4326 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4335 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4343 ret = btrfs_relocate_chunk(root, chunk_offset); in btrfs_shrink_device()
4344 mutex_unlock(&root->fs_info->delete_unused_bgs_mutex); in btrfs_shrink_device()
4361 trans = btrfs_start_transaction(root, 0); in btrfs_shrink_device()
4367 lock_chunks(root); in btrfs_shrink_device()
4387 unlock_chunks(root); in btrfs_shrink_device()
4391 ret = btrfs_commit_transaction(trans, root); in btrfs_shrink_device()
4401 &root->fs_info->fs_devices->resized_devices); in btrfs_shrink_device()
4405 unlock_chunks(root); in btrfs_shrink_device()
4409 btrfs_end_transaction(trans, root); in btrfs_shrink_device()
4413 lock_chunks(root); in btrfs_shrink_device()
4417 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4418 root->fs_info->free_chunk_space += diff; in btrfs_shrink_device()
4419 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4420 unlock_chunks(root); in btrfs_shrink_device()
4425 static int btrfs_add_system_chunk(struct btrfs_root *root, in btrfs_add_system_chunk() argument
4429 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_add_system_chunk()
4434 lock_chunks(root); in btrfs_add_system_chunk()
4438 unlock_chunks(root); in btrfs_add_system_chunk()
4449 unlock_chunks(root); in btrfs_add_system_chunk()
4917 struct btrfs_root *root, in init_first_rw_device() argument
4923 struct btrfs_fs_info *fs_info = root->fs_info; in init_first_rw_device()
4934 sys_chunk_offset = find_next_chunk(root->fs_info); in init_first_rw_device()
4958 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) in btrfs_chunk_readonly() argument
4962 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in btrfs_chunk_readonly()
5081 unsigned long btrfs_full_stripe_len(struct btrfs_root *root, in btrfs_full_stripe_len() argument
5088 unsigned long len = root->sectorsize; in btrfs_full_stripe_len()
5950 static noinline void btrfs_schedule_bio(struct btrfs_root *root, in btrfs_schedule_bio() argument
5976 atomic_inc(&root->fs_info->nr_async_bios); in btrfs_schedule_bio()
5999 btrfs_queue_work(root->fs_info->submit_workers, in btrfs_schedule_bio()
6003 static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, in submit_stripe_bio() argument
6028 btrfs_bio_counter_inc_noblocked(root->fs_info); in submit_stripe_bio()
6031 btrfs_schedule_bio(root, dev, rw, bio); in submit_stripe_bio()
6050 int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, in btrfs_map_bio() argument
6066 btrfs_bio_counter_inc_blocked(root->fs_info); in btrfs_map_bio()
6067 ret = __btrfs_map_block(root->fs_info, rw, logical, &map_length, &bbio, in btrfs_map_bio()
6070 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6078 bbio->fs_info = root->fs_info; in btrfs_map_bio()
6085 ret = raid56_parity_write(root, bio, bbio, map_length); in btrfs_map_bio()
6087 ret = raid56_parity_recover(root, bio, bbio, map_length, in btrfs_map_bio()
6091 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6096 btrfs_crit(root->fs_info, "mapping failed logical %llu bio len %llu len %llu", in btrfs_map_bio()
6114 submit_stripe_bio(root, bbio, bio, in btrfs_map_bio()
6118 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
6142 static struct btrfs_device *add_missing_dev(struct btrfs_root *root, in add_missing_dev() argument
6214 static int btrfs_check_chunk_valid(struct btrfs_root *root, in btrfs_check_chunk_valid() argument
6233 btrfs_err(root->fs_info, "invalid chunk num_stripes: %u", in btrfs_check_chunk_valid()
6237 if (!IS_ALIGNED(logical, root->sectorsize)) { in btrfs_check_chunk_valid()
6238 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6242 if (btrfs_chunk_sector_size(leaf, chunk) != root->sectorsize) { in btrfs_check_chunk_valid()
6243 btrfs_err(root->fs_info, "invalid chunk sectorsize %u", in btrfs_check_chunk_valid()
6247 if (!length || !IS_ALIGNED(length, root->sectorsize)) { in btrfs_check_chunk_valid()
6248 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6253 btrfs_err(root->fs_info, "invalid chunk stripe length: %llu", in btrfs_check_chunk_valid()
6259 btrfs_err(root->fs_info, "unrecognized chunk type: %llu", in btrfs_check_chunk_valid()
6268 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6274 btrfs_err(root->fs_info, "missing chunk type flag: 0x%llx", type); in btrfs_check_chunk_valid()
6280 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6285 features = btrfs_super_incompat_flags(root->fs_info->super_copy); in btrfs_check_chunk_valid()
6292 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6305 btrfs_err(root->fs_info, in btrfs_check_chunk_valid()
6315 static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, in read_one_chunk() argument
6319 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in read_one_chunk()
6336 ret = btrfs_check_chunk_valid(root, leaf, chunk, logical); in read_one_chunk()
6383 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, in read_one_chunk()
6385 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { in read_one_chunk()
6391 add_missing_dev(root, root->fs_info->fs_devices, in read_one_chunk()
6397 btrfs_warn(root->fs_info, "devid %llu uuid %pU is missing", in read_one_chunk()
6435 static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root, in open_seed_devices() argument
6443 fs_devices = root->fs_info->fs_devices->seed; in open_seed_devices()
6453 if (!btrfs_test_opt(root, DEGRADED)) in open_seed_devices()
6470 root->fs_info->bdev_holder); in open_seed_devices()
6484 fs_devices->seed = root->fs_info->fs_devices->seed; in open_seed_devices()
6485 root->fs_info->fs_devices->seed = fs_devices; in open_seed_devices()
6490 static int read_one_dev(struct btrfs_root *root, in read_one_dev() argument
6494 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in read_one_dev()
6507 if (memcmp(fs_uuid, root->fs_info->fsid, BTRFS_UUID_SIZE)) { in read_one_dev()
6508 fs_devices = open_seed_devices(root, fs_uuid); in read_one_dev()
6513 device = btrfs_find_device(root->fs_info, devid, dev_uuid, fs_uuid); in read_one_dev()
6515 if (!btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6518 device = add_missing_dev(root, fs_devices, devid, dev_uuid); in read_one_dev()
6521 btrfs_warn(root->fs_info, "devid %llu uuid %pU missing", in read_one_dev()
6524 if (!device->bdev && !btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6553 if (device->fs_devices != root->fs_info->fs_devices) { in read_one_dev()
6564 spin_lock(&root->fs_info->free_chunk_lock); in read_one_dev()
6565 root->fs_info->free_chunk_space += device->total_bytes - in read_one_dev()
6567 spin_unlock(&root->fs_info->free_chunk_lock); in read_one_dev()
6573 int btrfs_read_sys_array(struct btrfs_root *root) in btrfs_read_sys_array() argument
6575 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_read_sys_array()
6589 ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize); in btrfs_read_sys_array()
6595 sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET); in btrfs_read_sys_array()
6599 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); in btrfs_read_sys_array()
6655 btrfs_err(root->fs_info, in btrfs_read_sys_array()
6666 ret = read_one_chunk(root, &key, sb, chunk); in btrfs_read_sys_array()
6687 int btrfs_read_chunk_tree(struct btrfs_root *root) in btrfs_read_chunk_tree() argument
6696 root = root->fs_info->chunk_root; in btrfs_read_chunk_tree()
6703 lock_chunks(root); in btrfs_read_chunk_tree()
6711 root->fs_info->fs_devices->total_rw_bytes = 0; in btrfs_read_chunk_tree()
6722 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_read_chunk_tree()
6729 ret = btrfs_next_leaf(root, path); in btrfs_read_chunk_tree()
6741 ret = read_one_dev(root, leaf, dev_item); in btrfs_read_chunk_tree()
6747 ret = read_one_chunk(root, &found_key, leaf, chunk); in btrfs_read_chunk_tree()
6755 unlock_chunks(root); in btrfs_read_chunk_tree()
6976 int btrfs_get_dev_stats(struct btrfs_root *root, in btrfs_get_dev_stats() argument
6980 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_get_dev_stats()
6984 dev = btrfs_find_device(root->fs_info, stats->devid, NULL, NULL); in btrfs_get_dev_stats()
6988 btrfs_warn(root->fs_info, "get dev_stats failed, device not found"); in btrfs_get_dev_stats()
6991 btrfs_warn(root->fs_info, "get dev_stats failed, not yet valid"); in btrfs_get_dev_stats()
7065 void btrfs_update_commit_device_bytes_used(struct btrfs_root *root, in btrfs_update_commit_device_bytes_used() argument
7077 lock_chunks(root); in btrfs_update_commit_device_bytes_used()
7087 unlock_chunks(root); in btrfs_update_commit_device_bytes_used()