Lines Matching refs:fs_devices
408 static void free_fs_devices(struct btrfs_fs_devices *fs_devices) in free_fs_devices() argument
411 WARN_ON(fs_devices->opened); in free_fs_devices()
412 while (!list_empty(&fs_devices->devices)) { in free_fs_devices()
413 device = list_entry(fs_devices->devices.next, in free_fs_devices()
418 kfree(fs_devices); in free_fs_devices()
423 struct btrfs_fs_devices *fs_devices; in btrfs_cleanup_fs_uuids() local
426 fs_devices = list_entry(fs_uuids.next, in btrfs_cleanup_fs_uuids()
428 list_del(&fs_devices->fs_list); in btrfs_cleanup_fs_uuids()
429 free_fs_devices(fs_devices); in btrfs_cleanup_fs_uuids()
436 struct btrfs_fs_devices *fs_devices; in find_fsid() local
441 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid()
443 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0 in find_fsid()
444 && memcmp(metadata_fsid, fs_devices->metadata_uuid, in find_fsid()
446 return fs_devices; in find_fsid()
448 if (memcmp(fsid, fs_devices->fsid, BTRFS_FSID_SIZE) == 0) in find_fsid()
449 return fs_devices; in find_fsid()
459 struct btrfs_fs_devices *fs_devices; in find_fsid_with_metadata_uuid() local
467 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_with_metadata_uuid()
468 if (fs_devices->fsid_change && in find_fsid_with_metadata_uuid()
469 memcmp(disk_super->metadata_uuid, fs_devices->fsid, in find_fsid_with_metadata_uuid()
471 memcmp(fs_devices->fsid, fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
473 return fs_devices; in find_fsid_with_metadata_uuid()
482 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_with_metadata_uuid()
483 if (fs_devices->fsid_change && in find_fsid_with_metadata_uuid()
484 memcmp(fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
485 fs_devices->fsid, BTRFS_FSID_SIZE) != 0 && in find_fsid_with_metadata_uuid()
486 memcmp(disk_super->metadata_uuid, fs_devices->metadata_uuid, in find_fsid_with_metadata_uuid()
488 return fs_devices; in find_fsid_with_metadata_uuid()
547 struct btrfs_fs_devices *fs_devices, *tmp_fs_devices; in btrfs_free_stale_devices() local
556 list_for_each_entry_safe(fs_devices, tmp_fs_devices, &fs_uuids, fs_list) { in btrfs_free_stale_devices()
558 mutex_lock(&fs_devices->device_list_mutex); in btrfs_free_stale_devices()
560 &fs_devices->devices, dev_list) { in btrfs_free_stale_devices()
565 if (fs_devices->opened) { in btrfs_free_stale_devices()
573 fs_devices->num_devices--; in btrfs_free_stale_devices()
579 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_free_stale_devices()
581 if (fs_devices->num_devices == 0) { in btrfs_free_stale_devices()
582 btrfs_sysfs_remove_fsid(fs_devices); in btrfs_free_stale_devices()
583 list_del(&fs_devices->fs_list); in btrfs_free_stale_devices()
584 free_fs_devices(fs_devices); in btrfs_free_stale_devices()
596 static int btrfs_open_one_device(struct btrfs_fs_devices *fs_devices, in btrfs_open_one_device() argument
633 fs_devices->seeding = true; in btrfs_open_one_device()
642 fs_devices->rotating = true; in btrfs_open_one_device()
648 fs_devices->open_devices++; in btrfs_open_one_device()
651 fs_devices->rw_devices++; in btrfs_open_one_device()
652 list_add_tail(&device->dev_alloc_list, &fs_devices->alloc_list); in btrfs_open_one_device()
674 struct btrfs_fs_devices *fs_devices; in find_fsid_inprogress() local
676 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_inprogress()
677 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_inprogress()
679 memcmp(fs_devices->metadata_uuid, disk_super->fsid, in find_fsid_inprogress()
680 BTRFS_FSID_SIZE) == 0 && !fs_devices->fsid_change) { in find_fsid_inprogress()
681 return fs_devices; in find_fsid_inprogress()
692 struct btrfs_fs_devices *fs_devices; in find_fsid_changed() local
703 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_changed()
705 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_changed()
707 memcmp(fs_devices->metadata_uuid, disk_super->metadata_uuid, in find_fsid_changed()
709 memcmp(fs_devices->fsid, disk_super->fsid, in find_fsid_changed()
711 return fs_devices; in find_fsid_changed()
714 if (memcmp(fs_devices->metadata_uuid, fs_devices->fsid, in find_fsid_changed()
716 memcmp(fs_devices->fsid, disk_super->metadata_uuid, in find_fsid_changed()
718 return fs_devices; in find_fsid_changed()
727 struct btrfs_fs_devices *fs_devices; in find_fsid_reverted_metadata() local
738 list_for_each_entry(fs_devices, &fs_uuids, fs_list) { in find_fsid_reverted_metadata()
739 if (memcmp(fs_devices->fsid, fs_devices->metadata_uuid, in find_fsid_reverted_metadata()
741 memcmp(fs_devices->metadata_uuid, disk_super->fsid, in find_fsid_reverted_metadata()
743 fs_devices->fsid_change) in find_fsid_reverted_metadata()
744 return fs_devices; in find_fsid_reverted_metadata()
761 struct btrfs_fs_devices *fs_devices = NULL; in device_list_add() local
781 fs_devices = find_fsid_inprogress(disk_super); in device_list_add()
783 fs_devices = find_fsid_changed(disk_super); in device_list_add()
785 fs_devices = find_fsid_with_metadata_uuid(disk_super); in device_list_add()
787 fs_devices = find_fsid_reverted_metadata(disk_super); in device_list_add()
788 if (!fs_devices) in device_list_add()
789 fs_devices = find_fsid(disk_super->fsid, NULL); in device_list_add()
793 if (!fs_devices) { in device_list_add()
795 fs_devices = alloc_fs_devices(disk_super->fsid, in device_list_add()
798 fs_devices = alloc_fs_devices(disk_super->fsid, NULL); in device_list_add()
800 if (IS_ERR(fs_devices)) in device_list_add()
801 return ERR_CAST(fs_devices); in device_list_add()
803 fs_devices->fsid_change = fsid_change_in_progress; in device_list_add()
805 mutex_lock(&fs_devices->device_list_mutex); in device_list_add()
806 list_add(&fs_devices->fs_list, &fs_uuids); in device_list_add()
815 mutex_lock(&fs_devices->device_list_mutex); in device_list_add()
816 device = btrfs_find_device(fs_devices, &args); in device_list_add()
823 if (fs_devices->fsid_change && in device_list_add()
824 found_transid > fs_devices->latest_generation) { in device_list_add()
825 memcpy(fs_devices->fsid, disk_super->fsid, in device_list_add()
829 memcpy(fs_devices->metadata_uuid, in device_list_add()
833 memcpy(fs_devices->metadata_uuid, in device_list_add()
836 fs_devices->fsid_change = false; in device_list_add()
841 if (fs_devices->opened) { in device_list_add()
844 path, fs_devices->fsid); in device_list_add()
845 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
852 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
860 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
866 list_add_rcu(&device->dev_list, &fs_devices->devices); in device_list_add()
867 fs_devices->num_devices++; in device_list_add()
869 device->fs_devices = fs_devices; in device_list_add()
910 if (!fs_devices->opened && found_transid < device->generation) { in device_list_add()
918 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
936 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
953 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
959 fs_devices->missing_devices--; in device_list_add()
971 if (!fs_devices->opened) { in device_list_add()
973 fs_devices->latest_generation = max_t(u64, found_transid, in device_list_add()
974 fs_devices->latest_generation); in device_list_add()
977 fs_devices->total_devices = btrfs_super_num_devices(disk_super); in device_list_add()
979 mutex_unlock(&fs_devices->device_list_mutex); in device_list_add()
985 struct btrfs_fs_devices *fs_devices; in clone_fs_devices() local
992 fs_devices = alloc_fs_devices(orig->fsid, NULL); in clone_fs_devices()
993 if (IS_ERR(fs_devices)) in clone_fs_devices()
994 return fs_devices; in clone_fs_devices()
996 fs_devices->total_devices = orig->total_devices; in clone_fs_devices()
1035 list_add(&device->dev_list, &fs_devices->devices); in clone_fs_devices()
1036 device->fs_devices = fs_devices; in clone_fs_devices()
1037 fs_devices->num_devices++; in clone_fs_devices()
1039 return fs_devices; in clone_fs_devices()
1041 free_fs_devices(fs_devices); in clone_fs_devices()
1045 static void __btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices, in __btrfs_free_extra_devids() argument
1051 list_for_each_entry_safe(device, next, &fs_devices->devices, dev_list) { in __btrfs_free_extra_devids()
1074 fs_devices->open_devices--; in __btrfs_free_extra_devids()
1079 fs_devices->rw_devices--; in __btrfs_free_extra_devids()
1082 fs_devices->num_devices--; in __btrfs_free_extra_devids()
1092 void btrfs_free_extra_devids(struct btrfs_fs_devices *fs_devices) in btrfs_free_extra_devids() argument
1098 __btrfs_free_extra_devids(fs_devices, &latest_dev); in btrfs_free_extra_devids()
1100 list_for_each_entry(seed_dev, &fs_devices->seed_list, seed_list) in btrfs_free_extra_devids()
1103 fs_devices->latest_dev = latest_dev; in btrfs_free_extra_devids()
1123 struct btrfs_fs_devices *fs_devices = device->fs_devices; in btrfs_close_one_device() local
1128 fs_devices->rw_devices--; in btrfs_close_one_device()
1136 fs_devices->missing_devices--; in btrfs_close_one_device()
1141 fs_devices->open_devices--; in btrfs_close_one_device()
1171 static void close_fs_devices(struct btrfs_fs_devices *fs_devices) in close_fs_devices() argument
1177 if (--fs_devices->opened > 0) in close_fs_devices()
1180 list_for_each_entry_safe(device, tmp, &fs_devices->devices, dev_list) in close_fs_devices()
1183 WARN_ON(fs_devices->open_devices); in close_fs_devices()
1184 WARN_ON(fs_devices->rw_devices); in close_fs_devices()
1185 fs_devices->opened = 0; in close_fs_devices()
1186 fs_devices->seeding = false; in close_fs_devices()
1187 fs_devices->fs_info = NULL; in close_fs_devices()
1190 void btrfs_close_devices(struct btrfs_fs_devices *fs_devices) in btrfs_close_devices() argument
1196 close_fs_devices(fs_devices); in btrfs_close_devices()
1197 if (!fs_devices->opened) in btrfs_close_devices()
1198 list_splice_init(&fs_devices->seed_list, &list); in btrfs_close_devices()
1200 list_for_each_entry_safe(fs_devices, tmp, &list, seed_list) { in btrfs_close_devices()
1201 close_fs_devices(fs_devices); in btrfs_close_devices()
1202 list_del(&fs_devices->seed_list); in btrfs_close_devices()
1203 free_fs_devices(fs_devices); in btrfs_close_devices()
1208 static int open_fs_devices(struct btrfs_fs_devices *fs_devices, in open_fs_devices() argument
1217 list_for_each_entry_safe(device, tmp_device, &fs_devices->devices, in open_fs_devices()
1221 ret = btrfs_open_one_device(fs_devices, device, flags, holder); in open_fs_devices()
1226 fs_devices->num_devices--; in open_fs_devices()
1231 if (fs_devices->open_devices == 0) in open_fs_devices()
1234 fs_devices->opened = 1; in open_fs_devices()
1235 fs_devices->latest_dev = latest_dev; in open_fs_devices()
1236 fs_devices->total_rw_bytes = 0; in open_fs_devices()
1237 fs_devices->chunk_alloc_policy = BTRFS_CHUNK_ALLOC_REGULAR; in open_fs_devices()
1238 fs_devices->read_policy = BTRFS_READ_POLICY_PID; in open_fs_devices()
1258 int btrfs_open_devices(struct btrfs_fs_devices *fs_devices, in btrfs_open_devices() argument
1272 if (fs_devices->opened) { in btrfs_open_devices()
1273 fs_devices->opened++; in btrfs_open_devices()
1276 list_sort(NULL, &fs_devices->devices, devid_cmp); in btrfs_open_devices()
1277 ret = open_fs_devices(fs_devices, flags, holder); in btrfs_open_devices()
1426 switch (device->fs_devices->chunk_alloc_policy) { in dev_extent_search_start()
1514 switch (device->fs_devices->chunk_alloc_policy) { in dev_extent_hole_check()
1879 write_extent_buffer(leaf, trans->fs_info->fs_devices->metadata_uuid, in btrfs_add_dev_item()
1999 next_device = btrfs_find_next_active_device(fs_info->fs_devices, in btrfs_assign_next_active_device()
2007 if (fs_info->fs_devices->latest_dev->bdev == device->bdev) in btrfs_assign_next_active_device()
2008 fs_info->fs_devices->latest_dev = next_device; in btrfs_assign_next_active_device()
2017 u64 num_devices = fs_info->fs_devices->num_devices; in btrfs_num_devices()
2081 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_rm_device() local
2101 device = btrfs_find_device(fs_info->fs_devices, args); in btrfs_rm_device()
2121 fs_info->fs_devices->rw_devices == 1) in btrfs_rm_device()
2127 device->fs_devices->rw_devices--; in btrfs_rm_device()
2170 cur_devices = device->fs_devices; in btrfs_rm_device()
2171 mutex_lock(&fs_devices->device_list_mutex); in btrfs_rm_device()
2177 if (cur_devices != fs_devices) in btrfs_rm_device()
2178 fs_devices->total_devices--; in btrfs_rm_device()
2193 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_rm_device()
2241 &fs_devices->alloc_list); in btrfs_rm_device()
2242 device->fs_devices->rw_devices++; in btrfs_rm_device()
2250 struct btrfs_fs_devices *fs_devices; in btrfs_rm_dev_replace_remove_srcdev() local
2252 lockdep_assert_held(&srcdev->fs_info->fs_devices->device_list_mutex); in btrfs_rm_dev_replace_remove_srcdev()
2260 fs_devices = srcdev->fs_devices; in btrfs_rm_dev_replace_remove_srcdev()
2264 fs_devices->num_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2266 fs_devices->missing_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2269 fs_devices->rw_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2272 fs_devices->open_devices--; in btrfs_rm_dev_replace_remove_srcdev()
2277 struct btrfs_fs_devices *fs_devices = srcdev->fs_devices; in btrfs_rm_dev_replace_free_srcdev() local
2286 if (!fs_devices->num_devices) { in btrfs_rm_dev_replace_free_srcdev()
2293 ASSERT(fs_devices->seeding); in btrfs_rm_dev_replace_free_srcdev()
2295 list_del_init(&fs_devices->seed_list); in btrfs_rm_dev_replace_free_srcdev()
2296 close_fs_devices(fs_devices); in btrfs_rm_dev_replace_free_srcdev()
2297 free_fs_devices(fs_devices); in btrfs_rm_dev_replace_free_srcdev()
2304 struct btrfs_fs_devices *fs_devices = tgtdev->fs_info->fs_devices; in btrfs_destroy_dev_replace_tgtdev() local
2306 mutex_lock(&fs_devices->device_list_mutex); in btrfs_destroy_dev_replace_tgtdev()
2311 fs_devices->open_devices--; in btrfs_destroy_dev_replace_tgtdev()
2313 fs_devices->num_devices--; in btrfs_destroy_dev_replace_tgtdev()
2319 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_destroy_dev_replace_tgtdev()
2410 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_find_device_by_devspec()
2419 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_find_device_by_devspec()
2428 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_init_sprout() local
2433 if (!fs_devices->seeding) in btrfs_init_sprout()
2450 old_devices = clone_fs_devices(fs_devices); in btrfs_init_sprout()
2458 memcpy(seed_devices, fs_devices, sizeof(*seed_devices)); in btrfs_init_sprout()
2474 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_setup_sprout() local
2497 lockdep_assert_held(&fs_devices->device_list_mutex); in btrfs_setup_sprout()
2499 list_splice_init_rcu(&fs_devices->devices, &seed_devices->devices, in btrfs_setup_sprout()
2502 device->fs_devices = seed_devices; in btrfs_setup_sprout()
2504 fs_devices->seeding = false; in btrfs_setup_sprout()
2505 fs_devices->num_devices = 0; in btrfs_setup_sprout()
2506 fs_devices->open_devices = 0; in btrfs_setup_sprout()
2507 fs_devices->missing_devices = 0; in btrfs_setup_sprout()
2508 fs_devices->rotating = false; in btrfs_setup_sprout()
2509 list_add(&seed_devices->seed_list, &fs_devices->seed_list); in btrfs_setup_sprout()
2511 generate_random_uuid(fs_devices->fsid); in btrfs_setup_sprout()
2512 memcpy(fs_devices->metadata_uuid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_setup_sprout()
2513 memcpy(disk_super->fsid, fs_devices->fsid, BTRFS_FSID_SIZE); in btrfs_setup_sprout()
2580 device = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_finish_sprout()
2583 if (device->fs_devices->seeding) { in btrfs_finish_sprout()
2606 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_init_new_device() local
2614 if (sb_rdonly(sb) && !fs_devices->seeding) in btrfs_init_new_device()
2627 if (fs_devices->seeding) { in btrfs_init_new_device()
2637 list_for_each_entry_rcu(device, &fs_devices->devices, dev_list) { in btrfs_init_new_device()
2703 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_new_device()
2706 btrfs_assign_next_active_device(fs_info->fs_devices->latest_dev, in btrfs_init_new_device()
2710 device->fs_devices = fs_devices; in btrfs_init_new_device()
2713 list_add_rcu(&device->dev_list, &fs_devices->devices); in btrfs_init_new_device()
2714 list_add(&device->dev_alloc_list, &fs_devices->alloc_list); in btrfs_init_new_device()
2715 fs_devices->num_devices++; in btrfs_init_new_device()
2716 fs_devices->open_devices++; in btrfs_init_new_device()
2717 fs_devices->rw_devices++; in btrfs_init_new_device()
2718 fs_devices->total_devices++; in btrfs_init_new_device()
2719 fs_devices->total_rw_bytes += device->total_bytes; in btrfs_init_new_device()
2724 fs_devices->rotating = true; in btrfs_init_new_device()
2746 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_new_device()
2775 btrfs_sysfs_update_sprout_fsid(fs_devices); in btrfs_init_new_device()
2819 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2823 fs_info->fs_devices->num_devices--; in btrfs_init_new_device()
2824 fs_info->fs_devices->open_devices--; in btrfs_init_new_device()
2825 fs_info->fs_devices->rw_devices--; in btrfs_init_new_device()
2826 fs_info->fs_devices->total_devices--; in btrfs_init_new_device()
2827 fs_info->fs_devices->total_rw_bytes -= device->total_bytes; in btrfs_init_new_device()
2834 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_new_device()
2925 device->fs_devices->total_rw_bytes += diff; in btrfs_grow_device()
3089 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_remove_chunk() local
3113 mutex_lock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
3120 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
3134 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_remove_chunk()
4291 num_devices = fs_info->fs_devices->rw_devices; in btrfs_balance()
4860 device->fs_devices->total_rw_bytes -= diff; in btrfs_shrink_device()
4997 device->fs_devices->total_rw_bytes += diff; in btrfs_shrink_device()
5098 struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl_policy_regular() argument
5103 space_info = btrfs_find_space_info(fs_devices->fs_info, ctl->type); in init_alloc_chunk_ctl_policy_regular()
5113 ctl->max_chunk_size = min(div_factor(fs_devices->total_rw_bytes, 1), in init_alloc_chunk_ctl_policy_regular()
5119 struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl_policy_zoned() argument
5122 u64 zone_size = fs_devices->fs_info->zone_size; in init_alloc_chunk_ctl_policy_zoned()
5144 limit = max(round_down(div_factor(fs_devices->total_rw_bytes, 1), in init_alloc_chunk_ctl_policy_zoned()
5151 static void init_alloc_chunk_ctl(struct btrfs_fs_devices *fs_devices, in init_alloc_chunk_ctl() argument
5160 ctl->devs_max = BTRFS_MAX_DEVS(fs_devices->fs_info); in init_alloc_chunk_ctl()
5167 switch (fs_devices->chunk_alloc_policy) { in init_alloc_chunk_ctl()
5169 init_alloc_chunk_ctl_policy_regular(fs_devices, ctl); in init_alloc_chunk_ctl()
5172 init_alloc_chunk_ctl_policy_zoned(fs_devices, ctl); in init_alloc_chunk_ctl()
5179 static int gather_device_info(struct btrfs_fs_devices *fs_devices, in gather_device_info() argument
5183 struct btrfs_fs_info *info = fs_devices->fs_info; in gather_device_info()
5196 list_for_each_entry(device, &fs_devices->alloc_list, dev_alloc_list) { in gather_device_info()
5234 if (ndevs == fs_devices->rw_devices) { in gather_device_info()
5236 __func__, fs_devices->rw_devices); in gather_device_info()
5335 static int decide_stripe_size(struct btrfs_fs_devices *fs_devices, in decide_stripe_size() argument
5339 struct btrfs_fs_info *info = fs_devices->fs_info; in decide_stripe_size()
5359 switch (fs_devices->chunk_alloc_policy) { in decide_stripe_size()
5468 struct btrfs_fs_devices *fs_devices = info->fs_devices; in btrfs_create_chunk() local
5481 if (list_empty(&fs_devices->alloc_list)) { in btrfs_create_chunk()
5495 init_alloc_chunk_ctl(fs_devices, &ctl); in btrfs_create_chunk()
5497 devices_info = kcalloc(fs_devices->rw_devices, sizeof(*devices_info), in btrfs_create_chunk()
5502 ret = gather_device_info(fs_devices, &ctl, devices_info); in btrfs_create_chunk()
5508 ret = decide_stripe_size(fs_devices, &ctl, devices_info); in btrfs_create_chunk()
5843 switch (fs_info->fs_devices->read_policy) { in find_live_mirror()
5848 fs_info->fs_devices->read_policy); in find_live_mirror()
5849 fs_info->fs_devices->read_policy = BTRFS_READ_POLICY_PID; in find_live_mirror()
6930 const struct btrfs_fs_devices *fs_devices) in dev_args_match_fs_devices() argument
6934 if (memcmp(fs_devices->metadata_uuid, args->fsid, BTRFS_FSID_SIZE) == 0) in dev_args_match_fs_devices()
6963 struct btrfs_device *btrfs_find_device(const struct btrfs_fs_devices *fs_devices, in btrfs_find_device() argument
6969 if (dev_args_match_fs_devices(args, fs_devices)) { in btrfs_find_device()
6970 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_find_device()
6976 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_find_device()
6988 static struct btrfs_device *add_missing_dev(struct btrfs_fs_devices *fs_devices, in add_missing_dev() argument
7006 list_add(&device->dev_list, &fs_devices->devices); in add_missing_dev()
7007 device->fs_devices = fs_devices; in add_missing_dev()
7008 fs_devices->num_devices++; in add_missing_dev()
7011 fs_devices->missing_devices++; in add_missing_dev()
7142 dev = add_missing_dev(fs_info->fs_devices, devid, uuid); in handle_missing_device()
7248 map->stripes[i].dev = btrfs_find_device(fs_info->fs_devices, &args); in read_one_chunk()
7302 struct btrfs_fs_devices *fs_devices; in open_seed_devices() local
7309 list_for_each_entry(fs_devices, &fs_info->fs_devices->seed_list, seed_list) in open_seed_devices()
7310 if (!memcmp(fs_devices->fsid, fsid, BTRFS_FSID_SIZE)) in open_seed_devices()
7311 return fs_devices; in open_seed_devices()
7314 fs_devices = find_fsid(fsid, NULL); in open_seed_devices()
7315 if (!fs_devices) { in open_seed_devices()
7319 fs_devices = alloc_fs_devices(fsid, NULL); in open_seed_devices()
7320 if (IS_ERR(fs_devices)) in open_seed_devices()
7321 return fs_devices; in open_seed_devices()
7323 fs_devices->seeding = true; in open_seed_devices()
7324 fs_devices->opened = 1; in open_seed_devices()
7325 return fs_devices; in open_seed_devices()
7332 fs_devices = clone_fs_devices(fs_devices); in open_seed_devices()
7333 if (IS_ERR(fs_devices)) in open_seed_devices()
7334 return fs_devices; in open_seed_devices()
7336 ret = open_fs_devices(fs_devices, FMODE_READ, fs_info->bdev_holder); in open_seed_devices()
7338 free_fs_devices(fs_devices); in open_seed_devices()
7342 if (!fs_devices->seeding) { in open_seed_devices()
7343 close_fs_devices(fs_devices); in open_seed_devices()
7344 free_fs_devices(fs_devices); in open_seed_devices()
7348 list_add(&fs_devices->seed_list, &fs_info->fs_devices->seed_list); in open_seed_devices()
7350 return fs_devices; in open_seed_devices()
7358 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in read_one_dev() local
7374 if (memcmp(fs_uuid, fs_devices->metadata_uuid, BTRFS_FSID_SIZE)) { in read_one_dev()
7375 fs_devices = open_seed_devices(fs_info, fs_uuid); in read_one_dev()
7376 if (IS_ERR(fs_devices)) in read_one_dev()
7377 return PTR_ERR(fs_devices); in read_one_dev()
7380 device = btrfs_find_device(fs_info->fs_devices, &args); in read_one_dev()
7388 device = add_missing_dev(fs_devices, devid, dev_uuid); in read_one_dev()
7415 device->fs_devices->missing_devices++; in read_one_dev()
7420 if (device->fs_devices != fs_devices) { in read_one_dev()
7424 list_move(&device->dev_list, &fs_devices->devices); in read_one_dev()
7425 device->fs_devices->num_devices--; in read_one_dev()
7426 fs_devices->num_devices++; in read_one_dev()
7428 device->fs_devices->missing_devices--; in read_one_dev()
7429 fs_devices->missing_devices++; in read_one_dev()
7431 device->fs_devices = fs_devices; in read_one_dev()
7435 if (device->fs_devices != fs_info->fs_devices) { in read_one_dev()
7456 device->fs_devices->total_rw_bytes += device->total_bytes; in read_one_dev()
7673 fs_info->fs_devices->total_rw_bytes = 0; in btrfs_read_chunk_tree()
7744 if (total_dev != fs_info->fs_devices->total_devices) { in btrfs_read_chunk_tree()
7749 fs_info->fs_devices->total_devices = total_dev; in btrfs_read_chunk_tree()
7753 fs_info->fs_devices->total_rw_bytes) { in btrfs_read_chunk_tree()
7757 fs_info->fs_devices->total_rw_bytes); in btrfs_read_chunk_tree()
7771 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs; in btrfs_init_devices_late() local
7775 fs_devices->fs_info = fs_info; in btrfs_init_devices_late()
7777 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_devices_late()
7778 list_for_each_entry(device, &fs_devices->devices, dev_list) in btrfs_init_devices_late()
7781 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_init_devices_late()
7791 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_devices_late()
7865 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices, *seed_devs; in btrfs_init_dev_stats() local
7874 mutex_lock(&fs_devices->device_list_mutex); in btrfs_init_dev_stats()
7875 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_init_dev_stats()
7880 list_for_each_entry(seed_devs, &fs_devices->seed_list, seed_list) { in btrfs_init_dev_stats()
7888 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_init_dev_stats()
7965 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_run_dev_stats() local
7970 mutex_lock(&fs_devices->device_list_mutex); in btrfs_run_dev_stats()
7971 list_for_each_entry(device, &fs_devices->devices, dev_list) { in btrfs_run_dev_stats()
7994 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_run_dev_stats()
8040 struct btrfs_fs_devices *fs_devices = fs_info->fs_devices; in btrfs_get_dev_stats() local
8043 mutex_lock(&fs_devices->device_list_mutex); in btrfs_get_dev_stats()
8045 dev = btrfs_find_device(fs_info->fs_devices, &args); in btrfs_get_dev_stats()
8046 mutex_unlock(&fs_devices->device_list_mutex); in btrfs_get_dev_stats()
8187 dev = btrfs_find_device(fs_info->fs_devices, &args); in verify_one_dev_extent()