• Home
  • Raw
  • Download

Lines Matching refs:fs_devices

409 static void free_fs_devices(struct btrfs_fs_devices *fs_devices)  in free_fs_devices()  argument
413 WARN_ON(fs_devices->opened); in free_fs_devices()
414 while (!list_empty(&fs_devices->devices)) { in free_fs_devices()
415 device = list_entry(fs_devices->devices.next, in free_fs_devices()
420 kfree(fs_devices); in free_fs_devices()
425 struct btrfs_fs_devices *fs_devices; in btrfs_cleanup_fs_uuids() local
428 fs_devices = list_entry(fs_uuids.next, in btrfs_cleanup_fs_uuids()
430 list_del(&fs_devices->fs_list); in btrfs_cleanup_fs_uuids()
431 free_fs_devices(fs_devices); in btrfs_cleanup_fs_uuids()
438 struct btrfs_fs_devices *fs_devices; in find_fsid() local
443 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid()
445 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0 in find_fsid()
446 && memcmp(metadata_fsid, fs_devices->metadata_uuid, in find_fsid()
448 return fs_devices; in find_fsid()
450 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0) in find_fsid()
451 return fs_devices; in find_fsid()
461 struct btrfs_fs_devices *fs_devices; in find_fsid_with_metadata_uuid() local
469 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_with_metadata_uuid()
470 if (fs_devices->fsid_change && in find_fsid_with_metadata_uuid()
471 memcmp(disk_super->metadata_uuid, fs_devices->fsid, in find_fsid_with_metadata_uuid()
473 memcmp(fs_devices->fsid, fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
475 return fs_devices; in find_fsid_with_metadata_uuid()
484 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_with_metadata_uuid()
485 if (fs_devices->fsid_change && in find_fsid_with_metadata_uuid()
486 memcmp(fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
487 fs_devices->fsid, BTRFS_FSID_SIZE) != 0 && in find_fsid_with_metadata_uuid()
488 memcmp(disk_super->metadata_uuid, fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
490 return fs_devices; in find_fsid_with_metadata_uuid()
592 struct btrfs_fs_devices *fs_devices, *tmp_fs_devices; in btrfs_free_stale_devices() local
601 list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) { in btrfs_free_stale_devices()
603 mutex_lock(&fs_devices->device_list_mutex); in btrfs_free_stale_devices()
605 &fs_devices->devices, dev_list) { in btrfs_free_stale_devices()
610 if (fs_devices->opened) { in btrfs_free_stale_devices()
618 fs_devices->num_devices--; in btrfs_free_stale_devices()
624 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_free_stale_devices()
626 if (fs_devices->num_devices == 0) { in btrfs_free_stale_devices()
627 btrfs_sysfs_remove_fsid(fs_devices); in btrfs_free_stale_devices()
628 list_del(&fs_devices->fs_list); in btrfs_free_stale_devices()
629 free_fs_devices(fs_devices); in btrfs_free_stale_devices()
641 static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, in btrfs_open_one_device() argument
679 fs_devices->seeding = true; in btrfs_open_one_device()
689 fs_devices->rotating = true; in btrfs_open_one_device()
695 fs_devices->open_devices++; in btrfs_open_one_device()
698 fs_devices->rw_devices++; in btrfs_open_one_device()
699 list_add_tail(&device->dev_alloc_list, &fs_devices->alloc_list); in btrfs_open_one_device()
729 struct btrfs_fs_devices *fs_devices; in find_fsid_inprogress() local
731 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_inprogress()
732 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_inprogress()
734 memcmp(fs_devices->metadata_uuid, disk_super->fsid, in find_fsid_inprogress()
735 BTRFS_FSID_SIZE) == 0 && !fs_devices->fsid_change) { in find_fsid_inprogress()
736 return fs_devices; in find_fsid_inprogress()
747 struct btrfs_fs_devices *fs_devices; in find_fsid_changed() local
758 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_changed()
760 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_changed()
762 memcmp(fs_devices->metadata_uuid, disk_super->metadata_uuid, in find_fsid_changed()
764 memcmp(fs_devices->fsid, disk_super->fsid, in find_fsid_changed()
766 return fs_devices; in find_fsid_changed()
769 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_changed()
771 memcmp(fs_devices->fsid, disk_super->metadata_uuid, in find_fsid_changed()
773 return fs_devices; in find_fsid_changed()
782 struct btrfs_fs_devices *fs_devices; in find_fsid_reverted_metadata() local
793 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_reverted_metadata()
794 if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid, in find_fsid_reverted_metadata()
796 memcmp(fs_devices->metadata_uuid, disk_super->fsid, in find_fsid_reverted_metadata()
798 fs_devices->fsid_change) in find_fsid_reverted_metadata()
799 return fs_devices; in find_fsid_reverted_metadata()
816 struct btrfs_fs_devices *fs_devices = NULL; in device_list_add() local
827 fs_devices = find_fsid_inprogress(disk_super); in device_list_add()
829 fs_devices = find_fsid_changed(disk_super); in device_list_add()
831 fs_devices = find_fsid_with_metadata_uuid(disk_super); in device_list_add()
833 fs_devices = find_fsid_reverted_metadata(disk_super); in device_list_add()
834 if (!fs_devices) in device_list_add()
835 fs_devices = find_fsid(disk_super->fsid, NULL); in device_list_add()
839 if (!fs_devices) { in device_list_add()
841 fs_devices = alloc_fs_devices(disk_super->fsid, in device_list_add()
844 fs_devices = alloc_fs_devices(disk_super->fsid, NULL); in device_list_add()
846 if (IS_ERR(fs_devices)) in device_list_add()
847 return ERR_CAST(fs_devices); in device_list_add()
849 fs_devices->fsid_change = fsid_change_in_progress; in device_list_add()
851 mutex_lock(&fs_devices->device_list_mutex); in device_list_add()
852 list_add(&fs_devices->fs_list, &fs_uuids); in device_list_add()
861 mutex_lock(&fs_devices->device_list_mutex); in device_list_add()
862 device = btrfs_find_device(fs_devices, &args); in device_list_add()
869 if (fs_devices->fsid_change && in device_list_add()
870 found_transid > fs_devices->latest_generation) { in device_list_add()
871 memcpy(fs_devices->fsid, disk_super->fsid, in device_list_add()
875 memcpy(fs_devices->metadata_uuid, in device_list_add()
879 memcpy(fs_devices->metadata_uuid, in device_list_add()
882 fs_devices->fsid_change = false; in device_list_add()
887 if (fs_devices->opened) { in device_list_add()
888 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
895 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
903 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
908 list_add_rcu(&device->dev_list, &fs_devices->devices); in device_list_add()
909 fs_devices->num_devices++; in device_list_add()
911 device->fs_devices = fs_devices; in device_list_add()
952 if (!fs_devices->opened && found_transid < device->generation) { in device_list_add()
960 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
979 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
984 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
1001 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
1007 fs_devices->missing_devices--; in device_list_add()
1018 if (!fs_devices->opened) { in device_list_add()
1020 fs_devices->latest_generation = max_t(u64, found_transid, in device_list_add()
1021 fs_devices->latest_generation); in device_list_add()
1024 fs_devices->total_devices = btrfs_super_num_devices(disk_super); in device_list_add()
1026 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
1032 struct btrfs_fs_devices *fs_devices; in clone_fs_devices() local
1039 fs_devices = alloc_fs_devices(orig->fsid, NULL); in clone_fs_devices()
1040 if (IS_ERR(fs_devices)) in clone_fs_devices()
1041 return fs_devices; in clone_fs_devices()
1043 fs_devices->total_devices = orig->total_devices; in clone_fs_devices()
1070 list_add(&device->dev_list, &fs_devices->devices); in clone_fs_devices()
1071 device->fs_devices = fs_devices; in clone_fs_devices()
1072 fs_devices->num_devices++; in clone_fs_devices()
1074 return fs_devices; in clone_fs_devices()
1076 free_fs_devices(fs_devices); in clone_fs_devices()
1080 static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, in __btrfs_free_extra_devids() argument
1086 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) { in __btrfs_free_extra_devids()
1109 fs_devices->open_devices--; in __btrfs_free_extra_devids()
1114 fs_devices->rw_devices--; in __btrfs_free_extra_devids()
1117 fs_devices->num_devices--; in __btrfs_free_extra_devids()
1127 void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices) in btrfs_free_extra_devids() argument
1133 __btrfs_free_extra_devids(fs_devices, &latest_dev); in btrfs_free_extra_devids()
1135 list_for_each_entry(seed_dev, &fs_devices->seed_list, seed_list) in btrfs_free_extra_devids()
1138 fs_devices->latest_dev = latest_dev; in btrfs_free_extra_devids()
1158 struct btrfs_fs_devices *fs_devices = device->fs_devices; in btrfs_close_one_device() local
1163 fs_devices->rw_devices--; in btrfs_close_one_device()
1171 fs_devices->missing_devices--; in btrfs_close_one_device()
1176 fs_devices->open_devices--; in btrfs_close_one_device()
1207 static void close_fs_devices(struct btrfs_fs_devices *fs_devices) in close_fs_devices() argument
1213 if (--fs_devices->opened > 0) in close_fs_devices()
1216 list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) in close_fs_devices()
1219 WARN_ON(fs_devices->open_devices); in close_fs_devices()
1220 WARN_ON(fs_devices->rw_devices); in close_fs_devices()
1221 fs_devices->opened = 0; in close_fs_devices()
1222 fs_devices->seeding = false; in close_fs_devices()
1223 fs_devices->fs_info = NULL; in close_fs_devices()
1226 void btrfs_close_devices(struct btrfs_fs_devices *fs_devices) in btrfs_close_devices() argument
1232 close_fs_devices(fs_devices); in btrfs_close_devices()
1233 if (!fs_devices->opened) { in btrfs_close_devices()
1234 list_splice_init(&fs_devices->seed_list, &list); in btrfs_close_devices()
1242 if (fs_devices->num_devices == 1) { in btrfs_close_devices()
1243 list_del(&fs_devices->fs_list); in btrfs_close_devices()
1244 free_fs_devices(fs_devices); in btrfs_close_devices()
1249 list_for_each_entry_safe(fs_devices, tmp, &list, seed_list) { in btrfs_close_devices()
1250 close_fs_devices(fs_devices); in btrfs_close_devices()
1251 list_del(&fs_devices->seed_list); in btrfs_close_devices()
1252 free_fs_devices(fs_devices); in btrfs_close_devices()
1257 static int open_fs_devices(struct btrfs_fs_devices *fs_devices, in open_fs_devices() argument
1266 list_for_each_entry_safe(device, tmp_device, &fs_devices->devices, in open_fs_devices()
1270 ret = btrfs_open_one_device(fs_devices, device, flags, holder); in open_fs_devices()
1275 fs_devices->num_devices--; in open_fs_devices()
1280 if (fs_devices->open_devices == 0) in open_fs_devices()
1283 fs_devices->opened = 1; in open_fs_devices()
1284 fs_devices->latest_dev = latest_dev; in open_fs_devices()
1285 fs_devices->total_rw_bytes = 0; in open_fs_devices()
1286 fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; in open_fs_devices()
1287 fs_devices->read_policy = BTRFS_READ_POLICY_PID; in open_fs_devices()
1307 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, in btrfs_open_devices() argument
1321 if (fs_devices->opened) { in btrfs_open_devices()
1322 fs_devices->opened++; in btrfs_open_devices()
1325 list_sort(NULL, &fs_devices->devices, devid_cmp); in btrfs_open_devices()
1326 ret = open_fs_devices(fs_devices, flags, holder); in btrfs_open_devices()
1486 switch (device->fs_devices->chunk_alloc_policy) { in dev_extent_search_start()
1579 switch (device->fs_devices->chunk_alloc_policy) { in dev_extent_hole_check()
1948 write_extent_buffer(leaf, trans->fs_info->fs_devices->metadata_uuid, in btrfs_add_dev_item()
2068 next_device = btrfs_find_next_active_device(fs_info->fs_devices, in btrfs_assign_next_active_device()
2076 if (fs_info->fs_devices->latest_dev->bdev == device->bdev) in btrfs_assign_next_active_device()
2077 fs_info->fs_devices->latest_dev = next_device; in btrfs_assign_next_active_device()
2086 u64 num_devices = fs_info->fs_devices->num_devices; in btrfs_num_devices()
2150 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_rm_device() local
2165 device = btrfs_find_device(fs_info->fs_devices, args); in btrfs_rm_device()
2185 fs_info->fs_devices->rw_devices == 1) in btrfs_rm_device()
2191 device->fs_devices->rw_devices--; in btrfs_rm_device()
2236 cur_devices = device->fs_devices; in btrfs_rm_device()
2237 mutex_lock(&fs_devices->device_list_mutex); in btrfs_rm_device()
2243 if (cur_devices != fs_devices) in btrfs_rm_device()
2244 fs_devices->total_devices--; in btrfs_rm_device()
2259 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_rm_device()
2300 &fs_devices->alloc_list); in btrfs_rm_device()
2301 device->fs_devices->rw_devices++; in btrfs_rm_device()
2309 struct btrfs_fs_devices *fs_devices; in btrfs_rm_dev_replace_remove_srcdev() local
2311 lockdep_assert_held(&srcdev->fs_info->fs_devices->device_list_mutex); in btrfs_rm_dev_replace_remove_srcdev()
2319 fs_devices = srcdev->fs_devices; in btrfs_rm_dev_replace_remove_srcdev()
2323 fs_devices->num_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2325 fs_devices->missing_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2328 fs_devices->rw_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2331 fs_devices->open_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2336 struct btrfs_fs_devices *fs_devices = srcdev->fs_devices; in btrfs_rm_dev_replace_free_srcdev() local
2345 if (!fs_devices->num_devices) { in btrfs_rm_dev_replace_free_srcdev()
2352 ASSERT(fs_devices->seeding); in btrfs_rm_dev_replace_free_srcdev()
2354 list_del_init(&fs_devices->seed_list); in btrfs_rm_dev_replace_free_srcdev()
2355 close_fs_devices(fs_devices); in btrfs_rm_dev_replace_free_srcdev()
2356 free_fs_devices(fs_devices); in btrfs_rm_dev_replace_free_srcdev()
2363 struct btrfs_fs_devices *fs_devices = tgtdev->fs_info->fs_devices; in btrfs_destroy_dev_replace_tgtdev() local
2365 mutex_lock(&fs_devices->device_list_mutex); in btrfs_destroy_dev_replace_tgtdev()
2370 fs_devices->open_devices--; in btrfs_destroy_dev_replace_tgtdev()
2372 fs_devices->num_devices--; in btrfs_destroy_dev_replace_tgtdev()
2378 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_destroy_dev_replace_tgtdev()
2469 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_find_device_by_devspec()
2478 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_find_device_by_devspec()
2490 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_prepare_sprout() local
2498 if (!fs_devices->seeding) in btrfs_prepare_sprout()
2515 old_devices = clone_fs_devices(fs_devices); in btrfs_prepare_sprout()
2523 memcpy(seed_devices, fs_devices, sizeof(*seed_devices)); in btrfs_prepare_sprout()
2529 mutex_lock(&fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2530 list_splice_init_rcu(&fs_devices->devices, &seed_devices->devices, in btrfs_prepare_sprout()
2533 device->fs_devices = seed_devices; in btrfs_prepare_sprout()
2535 fs_devices->seeding = false; in btrfs_prepare_sprout()
2536 fs_devices->num_devices = 0; in btrfs_prepare_sprout()
2537 fs_devices->open_devices = 0; in btrfs_prepare_sprout()
2538 fs_devices->missing_devices = 0; in btrfs_prepare_sprout()
2539 fs_devices->rotating = false; in btrfs_prepare_sprout()
2540 list_add(&seed_devices->seed_list, &fs_devices->seed_list); in btrfs_prepare_sprout()
2542 generate_random_uuid(fs_devices->fsid); in btrfs_prepare_sprout()
2543 memcpy(fs_devices->metadata_uuid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_prepare_sprout()
2544 memcpy(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_prepare_sprout()
2545 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_prepare_sprout()
2614 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_finish_sprout()
2617 if (device->fs_devices->seeding) { in btrfs_finish_sprout()
2641 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_init_new_device() local
2648 if (sb_rdonly(sb) && !fs_devices->seeding) in btrfs_init_new_device()
2661 if (fs_devices->seeding) { in btrfs_init_new_device()
2671 list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) { in btrfs_init_new_device()
2730 btrfs_assign_next_active_device(fs_info->fs_devices->latest_dev, in btrfs_init_new_device()
2734 device->fs_devices = fs_devices; in btrfs_init_new_device()
2736 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_new_device()
2738 list_add_rcu(&device->dev_list, &fs_devices->devices); in btrfs_init_new_device()
2739 list_add(&device->dev_alloc_list, &fs_devices->alloc_list); in btrfs_init_new_device()
2740 fs_devices->num_devices++; in btrfs_init_new_device()
2741 fs_devices->open_devices++; in btrfs_init_new_device()
2742 fs_devices->rw_devices++; in btrfs_init_new_device()
2743 fs_devices->total_devices++; in btrfs_init_new_device()
2744 fs_devices->total_rw_bytes += device->total_bytes; in btrfs_init_new_device()
2749 fs_devices->rotating = true; in btrfs_init_new_device()
2771 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_new_device()
2800 btrfs_sysfs_update_sprout_fsid(fs_devices); in btrfs_init_new_device()
2844 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2848 fs_info->fs_devices->num_devices--; in btrfs_init_new_device()
2849 fs_info->fs_devices->open_devices--; in btrfs_init_new_device()
2850 fs_info->fs_devices->rw_devices--; in btrfs_init_new_device()
2851 fs_info->fs_devices->total_devices--; in btrfs_init_new_device()
2852 fs_info->fs_devices->total_rw_bytes -= device->total_bytes; in btrfs_init_new_device()
2859 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2950 device->fs_devices->total_rw_bytes += diff; in btrfs_grow_device()
3115 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_remove_chunk() local
3139 mutex_lock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
3146 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
3160 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
4318 num_devices = fs_info->fs_devices->rw_devices; in btrfs_balance()
4880 device->fs_devices->total_rw_bytes -= diff; in btrfs_shrink_device()
5017 device->fs_devices->total_rw_bytes += diff; in btrfs_shrink_device()
5118 struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl_policy_regular() argument
5128 if (fs_devices->total_rw_bytes > 50ULL * SZ_1G) in init_alloc_chunk_ctl_policy_regular()
5143 ctl->max_chunk_size = min(div_factor(fs_devices->total_rw_bytes, 1), in init_alloc_chunk_ctl_policy_regular()
5149 struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl_policy_zoned() argument
5152 u64 zone_size = fs_devices->fs_info->zone_size; in init_alloc_chunk_ctl_policy_zoned()
5174 limit = max(round_down(div_factor(fs_devices->total_rw_bytes, 1), in init_alloc_chunk_ctl_policy_zoned()
5181 static void init_alloc_chunk_ctl(struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl() argument
5190 ctl->devs_max = BTRFS_MAX_DEVS(fs_devices->fs_info); in init_alloc_chunk_ctl()
5197 switch (fs_devices->chunk_alloc_policy) { in init_alloc_chunk_ctl()
5199 init_alloc_chunk_ctl_policy_regular(fs_devices, ctl); in init_alloc_chunk_ctl()
5202 init_alloc_chunk_ctl_policy_zoned(fs_devices, ctl); in init_alloc_chunk_ctl()
5209 static int gather_device_info(struct btrfs_fs_devices *fs_devices, in gather_device_info() argument
5213 struct btrfs_fs_info *info = fs_devices->fs_info; in gather_device_info()
5226 list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) { in gather_device_info()
5264 if (ndevs == fs_devices->rw_devices) { in gather_device_info()
5266 __func__, fs_devices->rw_devices); in gather_device_info()
5362 static int decide_stripe_size(struct btrfs_fs_devices *fs_devices, in decide_stripe_size() argument
5366 struct btrfs_fs_info *info = fs_devices->fs_info; in decide_stripe_size()
5386 switch (fs_devices->chunk_alloc_policy) { in decide_stripe_size()
5495 struct btrfs_fs_devices *fs_devices = info->fs_devices; in btrfs_create_chunk() local
5508 if (list_empty(&fs_devices->alloc_list)) { in btrfs_create_chunk()
5522 init_alloc_chunk_ctl(fs_devices, &ctl); in btrfs_create_chunk()
5524 devices_info = kcalloc(fs_devices->rw_devices, sizeof(*devices_info), in btrfs_create_chunk()
5529 ret = gather_device_info(fs_devices, &ctl, devices_info); in btrfs_create_chunk()
5535 ret = decide_stripe_size(fs_devices, &ctl, devices_info); in btrfs_create_chunk()
5866 switch (fs_info->fs_devices->read_policy) { in find_live_mirror()
5871 fs_info->fs_devices->read_policy); in find_live_mirror()
5872 fs_info->fs_devices->read_policy = BTRFS_READ_POLICY_PID; in find_live_mirror()
6867 const struct btrfs_fs_devices *fs_devices) in dev_args_match_fs_devices() argument
6871 if (memcmp(fs_devices->metadata_uuid, args->fsid, BTRFS_FSID_SIZE) == 0) in dev_args_match_fs_devices()
6900 struct btrfs_device *btrfs_find_device(const struct btrfs_fs_devices *fs_devices, in btrfs_find_device() argument
6906 if (dev_args_match_fs_devices(args, fs_devices)) { in btrfs_find_device()
6907 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_find_device()
6913 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_find_device()
6925 static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices, in add_missing_dev() argument
6943 list_add(&device->dev_list, &fs_devices->devices); in add_missing_dev()
6944 device->fs_devices = fs_devices; in add_missing_dev()
6945 fs_devices->num_devices++; in add_missing_dev()
6948 fs_devices->missing_devices++; in add_missing_dev()
7091 dev = add_missing_dev(fs_info->fs_devices, devid, uuid); in handle_missing_device()
7188 map->stripes[i].dev = btrfs_find_device(fs_info->fs_devices, &args); in read_one_chunk()
7242 struct btrfs_fs_devices *fs_devices; in open_seed_devices() local
7249 list_for_each_entry(fs_devices, &fs_info->fs_devices->seed_list, seed_list) in open_seed_devices()
7250 if (!memcmp(fs_devices->fsid, fsid, BTRFS_FSID_SIZE)) in open_seed_devices()
7251 return fs_devices; in open_seed_devices()
7254 fs_devices = find_fsid(fsid, NULL); in open_seed_devices()
7255 if (!fs_devices) { in open_seed_devices()
7259 fs_devices = alloc_fs_devices(fsid, NULL); in open_seed_devices()
7260 if (IS_ERR(fs_devices)) in open_seed_devices()
7261 return fs_devices; in open_seed_devices()
7263 fs_devices->seeding = true; in open_seed_devices()
7264 fs_devices->opened = 1; in open_seed_devices()
7265 return fs_devices; in open_seed_devices()
7272 fs_devices = clone_fs_devices(fs_devices); in open_seed_devices()
7273 if (IS_ERR(fs_devices)) in open_seed_devices()
7274 return fs_devices; in open_seed_devices()
7276 ret = open_fs_devices(fs_devices, FMODE_READ, fs_info->bdev_holder); in open_seed_devices()
7278 free_fs_devices(fs_devices); in open_seed_devices()
7282 if (!fs_devices->seeding) { in open_seed_devices()
7283 close_fs_devices(fs_devices); in open_seed_devices()
7284 free_fs_devices(fs_devices); in open_seed_devices()
7288 list_add(&fs_devices->seed_list, &fs_info->fs_devices->seed_list); in open_seed_devices()
7290 return fs_devices; in open_seed_devices()
7298 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in read_one_dev() local
7313 if (memcmp(fs_uuid, fs_devices->metadata_uuid, BTRFS_FSID_SIZE)) { in read_one_dev()
7314 fs_devices = open_seed_devices(fs_info, fs_uuid); in read_one_dev()
7315 if (IS_ERR(fs_devices)) in read_one_dev()
7316 return PTR_ERR(fs_devices); in read_one_dev()
7319 device = btrfs_find_device(fs_info->fs_devices, &args); in read_one_dev()
7327 device = add_missing_dev(fs_devices, devid, dev_uuid); in read_one_dev()
7354 device->fs_devices->missing_devices++; in read_one_dev()
7359 if (device->fs_devices != fs_devices) { in read_one_dev()
7363 list_move(&device->dev_list, &fs_devices->devices); in read_one_dev()
7364 device->fs_devices->num_devices--; in read_one_dev()
7365 fs_devices->num_devices++; in read_one_dev()
7367 device->fs_devices->missing_devices--; in read_one_dev()
7368 fs_devices->missing_devices++; in read_one_dev()
7370 device->fs_devices = fs_devices; in read_one_dev()
7374 if (device->fs_devices != fs_info->fs_devices) { in read_one_dev()
7395 device->fs_devices->total_rw_bytes += device->total_bytes; in read_one_dev()
7626 fs_info->fs_devices->total_rw_bytes = 0; in btrfs_read_chunk_tree()
7705 if (total_dev != fs_info->fs_devices->total_devices) { in btrfs_read_chunk_tree()
7710 fs_info->fs_devices->total_devices = total_dev; in btrfs_read_chunk_tree()
7714 fs_info->fs_devices->total_rw_bytes) { in btrfs_read_chunk_tree()
7718 fs_info->fs_devices->total_rw_bytes); in btrfs_read_chunk_tree()
7732 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs; in btrfs_init_devices_late() local
7736 fs_devices->fs_info = fs_info; in btrfs_init_devices_late()
7738 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_devices_late()
7739 list_for_each_entry(device, &fs_devices->devices, dev_list) in btrfs_init_devices_late()
7742 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_init_devices_late()
7752 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_devices_late()
7826 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs; in btrfs_init_dev_stats() local
7835 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_dev_stats()
7836 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_init_dev_stats()
7841 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_init_dev_stats()
7849 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_dev_stats()
7926 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_run_dev_stats() local
7931 mutex_lock(&fs_devices->device_list_mutex); in btrfs_run_dev_stats()
7932 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_run_dev_stats()
7955 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_run_dev_stats()
8005 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_get_dev_stats() local
8008 mutex_lock(&fs_devices->device_list_mutex); in btrfs_get_dev_stats()
8010 dev = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_get_dev_stats()
8011 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_get_dev_stats()
8142 dev = btrfs_find_device(fs_info->fs_devices, &args); in verify_one_dev_extent()