Lines Matching refs:fs_info

65 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
69 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info)
72 struct btrfs_root *dev_root = fs_info->dev_root;
73 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
98 if (btrfs_find_device(fs_info->fs_devices,
100 btrfs_err(fs_info,
130 btrfs_warn(fs_info,
161 if (btrfs_find_device(fs_info->fs_devices,
163 btrfs_err(fs_info,
173 dev_replace->srcdev = btrfs_find_device(fs_info->fs_devices,
175 dev_replace->tgtdev = btrfs_find_device(fs_info->fs_devices,
183 !btrfs_test_opt(fs_info, DEGRADED)) {
185 btrfs_warn(fs_info,
187 btrfs_warn(fs_info,
192 !btrfs_test_opt(fs_info, DEGRADED)) {
194 btrfs_warn(fs_info,
196 btrfs_warn(fs_info,
216 WARN_ON(fs_info->fs_devices->rw_devices == 0);
217 dev_replace->tgtdev->io_width = fs_info->sectorsize;
218 dev_replace->tgtdev->io_align = fs_info->sectorsize;
219 dev_replace->tgtdev->sector_size = fs_info->sectorsize;
220 dev_replace->tgtdev->fs_info = fs_info;
238 static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
251 btrfs_err(fs_info, "the filesystem is a seed filesystem!");
256 fs_info->bdev_holder);
258 btrfs_err(fs_info, "target device %s is invalid!", device_path);
264 list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) {
266 btrfs_err(fs_info,
276 btrfs_err(fs_info,
299 device->io_width = fs_info->sectorsize;
300 device->io_align = fs_info->sectorsize;
301 device->sector_size = fs_info->sectorsize;
307 device->fs_info = fs_info;
314 device->fs_devices = fs_info->fs_devices;
316 mutex_lock(&fs_info->fs_devices->device_list_mutex);
317 list_add(&device->dev_list, &fs_info->fs_devices->devices);
318 fs_info->fs_devices->num_devices++;
319 fs_info->fs_devices->open_devices++;
320 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
336 struct btrfs_fs_info *fs_info = trans->fs_info;
338 struct btrfs_root *dev_root = fs_info->dev_root;
343 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
364 btrfs_warn(fs_info,
385 btrfs_warn(fs_info,
399 btrfs_warn(fs_info,
450 static int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info,
454 struct btrfs_root *root = fs_info->dev_root;
456 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
461 src_device = btrfs_find_device_by_devspec(fs_info, srcdevid,
466 if (btrfs_pinned_by_swapfile(fs_info, src_device)) {
467 btrfs_warn_in_rcu(fs_info,
486 ret = btrfs_init_dev_replace_tgtdev(fs_info, tgtdev_name,
509 btrfs_info_in_rcu(fs_info,
533 btrfs_err(fs_info, "kobj add dev failed %d", ret);
535 btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);
554 ret = btrfs_scrub_dev(fs_info, src_device->devid, 0,
558 ret = btrfs_dev_replace_finishing(fs_info, ret);
569 int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info,
586 ret = btrfs_dev_replace_start(fs_info, args->start.tgtdev_name,
602 static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info)
604 set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state);
605 wait_event(fs_info->dev_replace.replace_wait, !percpu_counter_sum(
606 &fs_info->dev_replace.bio_counter));
612 static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info)
614 clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state);
615 wake_up(&fs_info->dev_replace.replace_wait);
633 lockdep_assert_held(&srcdev->fs_info->chunk_mutex);
650 struct btrfs_fs_info *fs_info,
654 struct extent_map_tree *em_tree = &fs_info->mapping_tree;
675 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
678 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
681 struct btrfs_root *root = fs_info->tree_root;
706 ret = btrfs_start_delalloc_roots(fs_info, U64_MAX, false);
711 btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1);
732 mutex_lock(&fs_info->fs_devices->device_list_mutex);
734 mutex_lock(&fs_info->chunk_mutex);
737 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
738 mutex_unlock(&fs_info->chunk_mutex);
761 btrfs_dev_replace_update_device_in_mapping_tree(fs_info,
766 btrfs_err_in_rcu(fs_info,
773 mutex_unlock(&fs_info->chunk_mutex);
774 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
776 btrfs_rm_dev_replace_blocked(fs_info);
779 btrfs_rm_dev_replace_unblocked(fs_info);
785 btrfs_info_in_rcu(fs_info,
804 list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list);
805 fs_info->fs_devices->rw_devices++;
808 btrfs_rm_dev_replace_blocked(fs_info);
812 btrfs_rm_dev_replace_unblocked(fs_info);
827 mutex_unlock(&fs_info->chunk_mutex);
828 mutex_unlock(&fs_info->fs_devices->device_list_mutex);
834 btrfs_scratch_superblocks(fs_info, src_device->bdev,
854 static u64 btrfs_dev_replace_progress(struct btrfs_fs_info *fs_info)
856 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
878 void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info,
881 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
894 args->status.progress_1000 = btrfs_dev_replace_progress(fs_info);
898 int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info)
900 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
904 struct btrfs_root *root = fs_info->tree_root;
908 if (sb_rdonly(fs_info->sb))
924 ret = btrfs_scrub_cancel(fs_info);
933 btrfs_info_in_rcu(fs_info,
957 btrfs_scrub_cancel(fs_info);
967 btrfs_info_in_rcu(fs_info,
984 void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info)
986 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
1002 btrfs_info(fs_info, "suspending dev_replace for unmount");
1011 int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info)
1014 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
1032 btrfs_info(fs_info,
1034 btrfs_info(fs_info,
1048 if (!btrfs_exclop_start(fs_info, BTRFS_EXCLOP_DEV_REPLACE)) {
1053 btrfs_info(fs_info,
1058 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl");
1064 struct btrfs_fs_info *fs_info = data;
1065 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace;
1069 progress = btrfs_dev_replace_progress(fs_info);
1071 btrfs_info_in_rcu(fs_info,
1078 ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid,
1082 ret = btrfs_dev_replace_finishing(fs_info, ret);
1085 btrfs_exclop_finish(fs_info);
1116 void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info)
1118 percpu_counter_inc(&fs_info->dev_replace.bio_counter);
1121 void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount)
1123 percpu_counter_sub(&fs_info->dev_replace.bio_counter, amount);
1124 cond_wake_up_nomb(&fs_info->dev_replace.replace_wait);
1127 void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info)
1130 percpu_counter_inc(&fs_info->dev_replace.bio_counter);
1132 &fs_info->fs_state)))
1135 btrfs_bio_counter_dec(fs_info);
1136 wait_event(fs_info->dev_replace.replace_wait,
1138 &fs_info->fs_state));