Lines Matching refs:root

46 				struct btrfs_root *root,
48 static int btrfs_relocate_sys_chunks(struct btrfs_root *root);
976 struct btrfs_root *root = device->dev_root; in btrfs_account_dev_extents_size() local
998 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_account_dev_extents_size()
1002 ret = btrfs_previous_item(root, path, key.objectid, key.type); in btrfs_account_dev_extents_size()
1011 ret = btrfs_next_leaf(root, path); in btrfs_account_dev_extents_size()
1083 search_list = &trans->root->fs_info->pinned_chunks; in contains_pending_extent()
1116 struct btrfs_root *root = device->dev_root; in find_free_dev_extent() local
1134 search_start = max(root->fs_info->alloc_start, 1024ull * 1024); in find_free_dev_extent()
1157 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in find_free_dev_extent()
1161 ret = btrfs_previous_item(root, path, key.objectid, key.type); in find_free_dev_extent()
1170 ret = btrfs_next_leaf(root, path); in find_free_dev_extent()
1277 struct btrfs_root *root = device->dev_root; in btrfs_free_dev_extent() local
1291 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_dev_extent()
1293 ret = btrfs_previous_item(root, path, key.objectid, in btrfs_free_dev_extent()
1311 btrfs_error(root->fs_info, ret, "Slot search failed"); in btrfs_free_dev_extent()
1317 ret = btrfs_del_item(trans, root, path); in btrfs_free_dev_extent()
1319 btrfs_error(root->fs_info, ret, in btrfs_free_dev_extent()
1336 struct btrfs_root *root = device->dev_root; in btrfs_alloc_dev_extent() local
1350 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_alloc_dev_extent()
1362 write_extent_buffer(leaf, root->fs_info->chunk_tree_uuid, in btrfs_alloc_dev_extent()
1434 struct btrfs_root *root, in btrfs_add_device() argument
1444 root = root->fs_info->chunk_root; in btrfs_add_device()
1454 ret = btrfs_insert_empty_item(trans, root, path, &key, in btrfs_add_device()
1480 write_extent_buffer(leaf, root->fs_info->fsid, ptr, BTRFS_UUID_SIZE); in btrfs_add_device()
1505 static int btrfs_rm_dev_item(struct btrfs_root *root, in btrfs_rm_dev_item() argument
1513 root = root->fs_info->chunk_root; in btrfs_rm_dev_item()
1519 trans = btrfs_start_transaction(root, 0); in btrfs_rm_dev_item()
1528 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_rm_dev_item()
1537 ret = btrfs_del_item(trans, root, path); in btrfs_rm_dev_item()
1542 btrfs_commit_transaction(trans, root); in btrfs_rm_dev_item()
1546 int btrfs_rm_device(struct btrfs_root *root, char *device_path) in btrfs_rm_device() argument
1565 seq = read_seqbegin(&root->fs_info->profiles_lock); in btrfs_rm_device()
1567 all_avail = root->fs_info->avail_data_alloc_bits | in btrfs_rm_device()
1568 root->fs_info->avail_system_alloc_bits | in btrfs_rm_device()
1569 root->fs_info->avail_metadata_alloc_bits; in btrfs_rm_device()
1570 } while (read_seqretry(&root->fs_info->profiles_lock, seq)); in btrfs_rm_device()
1572 num_devices = root->fs_info->fs_devices->num_devices; in btrfs_rm_device()
1573 btrfs_dev_replace_lock(&root->fs_info->dev_replace); in btrfs_rm_device()
1574 if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) { in btrfs_rm_device()
1578 btrfs_dev_replace_unlock(&root->fs_info->dev_replace); in btrfs_rm_device()
1591 root->fs_info->fs_devices->rw_devices <= 2) { in btrfs_rm_device()
1596 root->fs_info->fs_devices->rw_devices <= 3) { in btrfs_rm_device()
1606 devices = &root->fs_info->fs_devices->devices; in btrfs_rm_device()
1629 root->fs_info->bdev_holder, 0, in btrfs_rm_device()
1636 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_rm_device()
1649 if (device->writeable && root->fs_info->fs_devices->rw_devices == 1) { in btrfs_rm_device()
1655 lock_chunks(root); in btrfs_rm_device()
1658 unlock_chunks(root); in btrfs_rm_device()
1673 ret = btrfs_rm_dev_item(root->fs_info->chunk_root, device); in btrfs_rm_device()
1678 btrfs_scrub_cancel_dev(root->fs_info, device); in btrfs_rm_device()
1691 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1700 next_device = list_entry(root->fs_info->fs_devices->devices.next, in btrfs_rm_device()
1702 if (device->bdev == root->fs_info->sb->s_bdev) in btrfs_rm_device()
1703 root->fs_info->sb->s_bdev = next_device->bdev; in btrfs_rm_device()
1704 if (device->bdev == root->fs_info->fs_devices->latest_bdev) in btrfs_rm_device()
1705 root->fs_info->fs_devices->latest_bdev = next_device->bdev; in btrfs_rm_device()
1710 btrfs_kobj_rm_device(root->fs_info, device); in btrfs_rm_device()
1715 num_devices = btrfs_super_num_devices(root->fs_info->super_copy) - 1; in btrfs_rm_device()
1716 btrfs_set_super_num_devices(root->fs_info->super_copy, num_devices); in btrfs_rm_device()
1717 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_rm_device()
1721 fs_devices = root->fs_info->fs_devices; in btrfs_rm_device()
1734 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_rm_device()
1735 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_rm_device()
1800 lock_chunks(root); in btrfs_rm_device()
1802 &root->fs_info->fs_devices->alloc_list); in btrfs_rm_device()
1804 unlock_chunks(root); in btrfs_rm_device()
1899 static int btrfs_find_device_by_path(struct btrfs_root *root, char *device_path, in btrfs_find_device_by_path() argument
1911 root->fs_info->bdev_holder, 0, &bdev, &bh); in btrfs_find_device_by_path()
1917 *device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_find_device_by_path()
1926 int btrfs_find_device_missing_or_by_path(struct btrfs_root *root, in btrfs_find_device_missing_or_by_path() argument
1935 devices = &root->fs_info->fs_devices->devices; in btrfs_find_device_missing_or_by_path()
1948 btrfs_err(root->fs_info, "no missing device found"); in btrfs_find_device_missing_or_by_path()
1954 return btrfs_find_device_by_path(root, device_path, device); in btrfs_find_device_missing_or_by_path()
1961 static int btrfs_prepare_sprout(struct btrfs_root *root) in btrfs_prepare_sprout() argument
1963 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_prepare_sprout()
1966 struct btrfs_super_block *disk_super = root->fs_info->super_copy; in btrfs_prepare_sprout()
1992 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
1998 lock_chunks(root); in btrfs_prepare_sprout()
2000 unlock_chunks(root); in btrfs_prepare_sprout()
2010 memcpy(root->fs_info->fsid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_prepare_sprout()
2012 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2025 struct btrfs_root *root) in btrfs_finish_sprout() argument
2041 root = root->fs_info->chunk_root; in btrfs_finish_sprout()
2047 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_finish_sprout()
2054 ret = btrfs_next_leaf(root, path); in btrfs_finish_sprout()
2077 device = btrfs_find_device(root->fs_info, devid, dev_uuid, in btrfs_finish_sprout()
2096 int btrfs_init_new_device(struct btrfs_root *root, char *device_path) in btrfs_init_new_device() argument
2103 struct super_block *sb = root->fs_info->sb; in btrfs_init_new_device()
2109 if ((sb->s_flags & MS_RDONLY) && !root->fs_info->fs_devices->seeding) in btrfs_init_new_device()
2113 root->fs_info->bdev_holder); in btrfs_init_new_device()
2117 if (root->fs_info->fs_devices->seeding) { in btrfs_init_new_device()
2125 devices = &root->fs_info->fs_devices->devices; in btrfs_init_new_device()
2127 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2132 &root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2136 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2138 device = btrfs_alloc_device(root->fs_info, NULL, NULL); in btrfs_init_new_device()
2153 trans = btrfs_start_transaction(root, 0); in btrfs_init_new_device()
2166 device->io_width = root->sectorsize; in btrfs_init_new_device()
2167 device->io_align = root->sectorsize; in btrfs_init_new_device()
2168 device->sector_size = root->sectorsize; in btrfs_init_new_device()
2172 device->dev_root = root->fs_info->dev_root; in btrfs_init_new_device()
2182 ret = btrfs_prepare_sprout(root); in btrfs_init_new_device()
2186 device->fs_devices = root->fs_info->fs_devices; in btrfs_init_new_device()
2188 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2189 lock_chunks(root); in btrfs_init_new_device()
2190 list_add_rcu(&device->dev_list, &root->fs_info->fs_devices->devices); in btrfs_init_new_device()
2192 &root->fs_info->fs_devices->alloc_list); in btrfs_init_new_device()
2193 root->fs_info->fs_devices->num_devices++; in btrfs_init_new_device()
2194 root->fs_info->fs_devices->open_devices++; in btrfs_init_new_device()
2195 root->fs_info->fs_devices->rw_devices++; in btrfs_init_new_device()
2196 root->fs_info->fs_devices->total_devices++; in btrfs_init_new_device()
2197 root->fs_info->fs_devices->total_rw_bytes += device->total_bytes; in btrfs_init_new_device()
2199 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2200 root->fs_info->free_chunk_space += device->total_bytes; in btrfs_init_new_device()
2201 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_init_new_device()
2204 root->fs_info->fs_devices->rotating = 1; in btrfs_init_new_device()
2206 tmp = btrfs_super_total_bytes(root->fs_info->super_copy); in btrfs_init_new_device()
2207 btrfs_set_super_total_bytes(root->fs_info->super_copy, in btrfs_init_new_device()
2210 tmp = btrfs_super_num_devices(root->fs_info->super_copy); in btrfs_init_new_device()
2211 btrfs_set_super_num_devices(root->fs_info->super_copy, in btrfs_init_new_device()
2215 btrfs_kobj_add_device(root->fs_info, device); in btrfs_init_new_device()
2221 btrfs_clear_space_info_full(root->fs_info); in btrfs_init_new_device()
2223 unlock_chunks(root); in btrfs_init_new_device()
2224 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2227 lock_chunks(root); in btrfs_init_new_device()
2228 ret = init_first_rw_device(trans, root, device); in btrfs_init_new_device()
2229 unlock_chunks(root); in btrfs_init_new_device()
2231 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2236 ret = btrfs_add_device(trans, root, device); in btrfs_init_new_device()
2238 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2245 ret = btrfs_finish_sprout(trans, root); in btrfs_init_new_device()
2247 btrfs_abort_transaction(trans, root, ret); in btrfs_init_new_device()
2255 root->fs_info->fsid); in btrfs_init_new_device()
2256 if (kobject_rename(&root->fs_info->super_kobj, fsid_buf)) in btrfs_init_new_device()
2260 root->fs_info->num_tolerated_disk_barrier_failures = in btrfs_init_new_device()
2261 btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); in btrfs_init_new_device()
2262 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2271 ret = btrfs_relocate_sys_chunks(root); in btrfs_init_new_device()
2273 btrfs_error(root->fs_info, ret, in btrfs_init_new_device()
2277 trans = btrfs_attach_transaction(root); in btrfs_init_new_device()
2283 ret = btrfs_commit_transaction(trans, root); in btrfs_init_new_device()
2291 btrfs_end_transaction(trans, root); in btrfs_init_new_device()
2293 btrfs_kobj_rm_device(root->fs_info, device); in btrfs_init_new_device()
2304 int btrfs_init_dev_replace_tgtdev(struct btrfs_root *root, char *device_path, in btrfs_init_dev_replace_tgtdev() argument
2311 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_init_dev_replace_tgtdev()
2367 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2370 device->io_width = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2371 device->io_align = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2372 device->sector_size = root->sectorsize; in btrfs_init_dev_replace_tgtdev()
2390 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
2416 struct btrfs_root *root; in btrfs_update_device() local
2421 root = device->dev_root->fs_info->chunk_root; in btrfs_update_device()
2431 ret = btrfs_search_slot(trans, root, &key, path, 0, 1); in btrfs_update_device()
2498 struct btrfs_root *root, u64 chunk_objectid, in btrfs_free_chunk() argument
2505 root = root->fs_info->chunk_root; in btrfs_free_chunk()
2514 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in btrfs_free_chunk()
2518 btrfs_error(root->fs_info, -ENOENT, in btrfs_free_chunk()
2524 ret = btrfs_del_item(trans, root, path); in btrfs_free_chunk()
2526 btrfs_error(root->fs_info, ret, in btrfs_free_chunk()
2533 static int btrfs_del_sys_chunk(struct btrfs_root *root, u64 chunk_objectid, u64 in btrfs_del_sys_chunk() argument
2536 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_del_sys_chunk()
2547 lock_chunks(root); in btrfs_del_sys_chunk()
2577 unlock_chunks(root); in btrfs_del_sys_chunk()
2582 struct btrfs_root *root, u64 chunk_offset) in btrfs_remove_chunk() argument
2586 struct btrfs_root *extent_root = root->fs_info->extent_root; in btrfs_remove_chunk()
2593 root = root->fs_info->chunk_root; in btrfs_remove_chunk()
2594 em_tree = &root->fs_info->mapping_tree.map_tree; in btrfs_remove_chunk()
2620 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2625 lock_chunks(root); in btrfs_remove_chunk()
2628 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2629 root->fs_info->free_chunk_space += dev_extent_len; in btrfs_remove_chunk()
2630 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_remove_chunk()
2631 btrfs_clear_space_info_full(root->fs_info); in btrfs_remove_chunk()
2632 unlock_chunks(root); in btrfs_remove_chunk()
2638 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2643 ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2645 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2649 trace_btrfs_chunk_free(root, map, chunk_offset, em->len); in btrfs_remove_chunk()
2652 ret = btrfs_del_sys_chunk(root, chunk_objectid, chunk_offset); in btrfs_remove_chunk()
2654 btrfs_abort_transaction(trans, root, ret); in btrfs_remove_chunk()
2671 static int btrfs_relocate_chunk(struct btrfs_root *root, in btrfs_relocate_chunk() argument
2679 root = root->fs_info->chunk_root; in btrfs_relocate_chunk()
2680 extent_root = root->fs_info->extent_root; in btrfs_relocate_chunk()
2691 trans = btrfs_start_transaction(root, 0); in btrfs_relocate_chunk()
2694 btrfs_std_error(root->fs_info, ret); in btrfs_relocate_chunk()
2702 ret = btrfs_remove_chunk(trans, root, chunk_offset); in btrfs_relocate_chunk()
2703 btrfs_end_transaction(trans, root); in btrfs_relocate_chunk()
2707 static int btrfs_relocate_sys_chunks(struct btrfs_root *root) in btrfs_relocate_sys_chunks() argument
2709 struct btrfs_root *chunk_root = root->fs_info->chunk_root; in btrfs_relocate_sys_chunks()
2777 static int insert_balance_item(struct btrfs_root *root, in insert_balance_item() argument
2792 trans = btrfs_start_transaction(root, 0); in insert_balance_item()
2802 ret = btrfs_insert_empty_item(trans, root, path, &key, in insert_balance_item()
2824 err = btrfs_commit_transaction(trans, root); in insert_balance_item()
2830 static int del_balance_item(struct btrfs_root *root) in del_balance_item() argument
2841 trans = btrfs_start_transaction(root, 0); in del_balance_item()
2851 ret = btrfs_search_slot(trans, root, &key, path, -1, 1); in del_balance_item()
2859 ret = btrfs_del_item(trans, root, path); in del_balance_item()
2862 err = btrfs_commit_transaction(trans, root); in del_balance_item()
3068 static int should_balance_chunk(struct btrfs_root *root, in should_balance_chunk() argument
3072 struct btrfs_balance_control *bctl = root->fs_info->balance_ctl; in should_balance_chunk()
3698 struct btrfs_root *root = fs_info->tree_root; in btrfs_uuid_scan_kthread() local
3724 ret = btrfs_search_forward(root, &key, path, 0); in btrfs_uuid_scan_kthread()
3959 struct btrfs_root *root = device->dev_root; in btrfs_shrink_device() local
3971 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_shrink_device()
3985 lock_chunks(root); in btrfs_shrink_device()
3990 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
3991 root->fs_info->free_chunk_space -= diff; in btrfs_shrink_device()
3992 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
3994 unlock_chunks(root); in btrfs_shrink_device()
4002 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_shrink_device()
4006 ret = btrfs_previous_item(root, path, 0, key.type); in btrfs_shrink_device()
4036 ret = btrfs_relocate_chunk(root, chunk_objectid, chunk_offset); in btrfs_shrink_device()
4049 lock_chunks(root); in btrfs_shrink_device()
4054 spin_lock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4055 root->fs_info->free_chunk_space += diff; in btrfs_shrink_device()
4056 spin_unlock(&root->fs_info->free_chunk_lock); in btrfs_shrink_device()
4057 unlock_chunks(root); in btrfs_shrink_device()
4062 trans = btrfs_start_transaction(root, 0); in btrfs_shrink_device()
4068 lock_chunks(root); in btrfs_shrink_device()
4072 &root->fs_info->fs_devices->resized_devices); in btrfs_shrink_device()
4076 unlock_chunks(root); in btrfs_shrink_device()
4080 btrfs_end_transaction(trans, root); in btrfs_shrink_device()
4086 static int btrfs_add_system_chunk(struct btrfs_root *root, in btrfs_add_system_chunk() argument
4090 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_add_system_chunk()
4095 lock_chunks(root); in btrfs_add_system_chunk()
4099 unlock_chunks(root); in btrfs_add_system_chunk()
4110 unlock_chunks(root); in btrfs_add_system_chunk()
4635 struct btrfs_root *root, in init_first_rw_device() argument
4641 struct btrfs_fs_info *fs_info = root->fs_info; in init_first_rw_device()
4652 sys_chunk_offset = find_next_chunk(root->fs_info); in init_first_rw_device()
4677 int btrfs_chunk_readonly(struct btrfs_root *root, u64 chunk_offset) in btrfs_chunk_readonly() argument
4681 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in btrfs_chunk_readonly()
4793 unsigned long btrfs_full_stripe_len(struct btrfs_root *root, in btrfs_full_stripe_len() argument
4800 unsigned long len = root->sectorsize; in btrfs_full_stripe_len()
5667 static noinline void btrfs_schedule_bio(struct btrfs_root *root, in btrfs_schedule_bio() argument
5693 atomic_inc(&root->fs_info->nr_async_bios); in btrfs_schedule_bio()
5716 btrfs_queue_work(root->fs_info->submit_workers, in btrfs_schedule_bio()
5748 static void submit_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, in submit_stripe_bio() argument
5773 btrfs_bio_counter_inc_noblocked(root->fs_info); in submit_stripe_bio()
5776 btrfs_schedule_bio(root, dev, rw, bio); in submit_stripe_bio()
5781 static int breakup_stripe_bio(struct btrfs_root *root, struct btrfs_bio *bbio, in breakup_stripe_bio() argument
5801 submit_stripe_bio(root, bbio, bio, physical, dev_nr, in breakup_stripe_bio()
5809 submit_stripe_bio(root, bbio, bio, physical, dev_nr, rw, async); in breakup_stripe_bio()
5829 int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, in btrfs_map_bio() argument
5845 btrfs_bio_counter_inc_blocked(root->fs_info); in btrfs_map_bio()
5846 ret = __btrfs_map_block(root->fs_info, rw, logical, &map_length, &bbio, in btrfs_map_bio()
5849 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
5857 bbio->fs_info = root->fs_info; in btrfs_map_bio()
5864 ret = raid56_parity_write(root, bio, bbio, map_length); in btrfs_map_bio()
5866 ret = raid56_parity_recover(root, bio, bbio, map_length, in btrfs_map_bio()
5870 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
5875 btrfs_crit(root->fs_info, "mapping failed logical %llu bio len %llu len %llu", in btrfs_map_bio()
5893 ret = breakup_stripe_bio(root, bbio, first_bio, dev, in btrfs_map_bio()
5907 submit_stripe_bio(root, bbio, bio, in btrfs_map_bio()
5911 btrfs_bio_counter_dec(root->fs_info); in btrfs_map_bio()
5935 static struct btrfs_device *add_missing_dev(struct btrfs_root *root, in add_missing_dev() argument
6006 static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, in read_one_chunk() argument
6010 struct btrfs_mapping_tree *map_tree = &root->fs_info->mapping_tree; in read_one_chunk()
6068 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, in read_one_chunk()
6070 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { in read_one_chunk()
6076 add_missing_dev(root, root->fs_info->fs_devices, in read_one_chunk()
6118 static struct btrfs_fs_devices *open_seed_devices(struct btrfs_root *root, in open_seed_devices() argument
6126 fs_devices = root->fs_info->fs_devices->seed; in open_seed_devices()
6136 if (!btrfs_test_opt(root, DEGRADED)) in open_seed_devices()
6153 root->fs_info->bdev_holder); in open_seed_devices()
6167 fs_devices->seed = root->fs_info->fs_devices->seed; in open_seed_devices()
6168 root->fs_info->fs_devices->seed = fs_devices; in open_seed_devices()
6173 static int read_one_dev(struct btrfs_root *root, in read_one_dev() argument
6177 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in read_one_dev()
6190 if (memcmp(fs_uuid, root->fs_info->fsid, BTRFS_UUID_SIZE)) { in read_one_dev()
6191 fs_devices = open_seed_devices(root, fs_uuid); in read_one_dev()
6196 device = btrfs_find_device(root->fs_info, devid, dev_uuid, fs_uuid); in read_one_dev()
6198 if (!btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6201 btrfs_warn(root->fs_info, "devid %llu missing", devid); in read_one_dev()
6202 device = add_missing_dev(root, fs_devices, devid, dev_uuid); in read_one_dev()
6206 if (!device->bdev && !btrfs_test_opt(root, DEGRADED)) in read_one_dev()
6235 if (device->fs_devices != root->fs_info->fs_devices) { in read_one_dev()
6246 spin_lock(&root->fs_info->free_chunk_lock); in read_one_dev()
6247 root->fs_info->free_chunk_space += device->total_bytes - in read_one_dev()
6249 spin_unlock(&root->fs_info->free_chunk_lock); in read_one_dev()
6255 int btrfs_read_sys_array(struct btrfs_root *root) in btrfs_read_sys_array() argument
6257 struct btrfs_super_block *super_copy = root->fs_info->super_copy; in btrfs_read_sys_array()
6270 ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize); in btrfs_read_sys_array()
6276 sb = btrfs_find_create_tree_block(root, BTRFS_SUPER_INFO_OFFSET); in btrfs_read_sys_array()
6280 btrfs_set_buffer_lockdep_class(root->root_key.objectid, sb, 0); in btrfs_read_sys_array()
6338 ret = read_one_chunk(root, &key, sb, chunk); in btrfs_read_sys_array()
6359 int btrfs_read_chunk_tree(struct btrfs_root *root) in btrfs_read_chunk_tree() argument
6368 root = root->fs_info->chunk_root; in btrfs_read_chunk_tree()
6375 lock_chunks(root); in btrfs_read_chunk_tree()
6386 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); in btrfs_read_chunk_tree()
6393 ret = btrfs_next_leaf(root, path); in btrfs_read_chunk_tree()
6405 ret = read_one_dev(root, leaf, dev_item); in btrfs_read_chunk_tree()
6411 ret = read_one_chunk(root, &found_key, leaf, chunk); in btrfs_read_chunk_tree()
6419 unlock_chunks(root); in btrfs_read_chunk_tree()
6640 int btrfs_get_dev_stats(struct btrfs_root *root, in btrfs_get_dev_stats() argument
6644 struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices; in btrfs_get_dev_stats()
6648 dev = btrfs_find_device(root->fs_info, stats->devid, NULL, NULL); in btrfs_get_dev_stats()
6652 btrfs_warn(root->fs_info, "get dev_stats failed, device not found"); in btrfs_get_dev_stats()
6655 btrfs_warn(root->fs_info, "get dev_stats failed, not yet valid"); in btrfs_get_dev_stats()
6717 void btrfs_update_commit_device_bytes_used(struct btrfs_root *root, in btrfs_update_commit_device_bytes_used() argument
6729 lock_chunks(root); in btrfs_update_commit_device_bytes_used()
6738 unlock_chunks(root); in btrfs_update_commit_device_bytes_used()