Lines Matching refs:fs_info

24 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
27 struct btrfs_fs_info *fs_info,
32 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info) in btrfs_init_dev_replace() argument
35 struct btrfs_root *dev_root = fs_info->dev_root; in btrfs_init_dev_replace()
36 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_init_dev_replace()
83 btrfs_warn(fs_info, in btrfs_init_dev_replace()
115 dev_replace->srcdev = btrfs_find_device(fs_info, src_devid, in btrfs_init_dev_replace()
117 dev_replace->tgtdev = btrfs_find_device(fs_info, in btrfs_init_dev_replace()
125 !btrfs_test_opt(fs_info, DEGRADED)) { in btrfs_init_dev_replace()
127 btrfs_warn(fs_info, in btrfs_init_dev_replace()
129 btrfs_warn(fs_info, in btrfs_init_dev_replace()
134 !btrfs_test_opt(fs_info, DEGRADED)) { in btrfs_init_dev_replace()
136 btrfs_warn(fs_info, in btrfs_init_dev_replace()
138 btrfs_warn(fs_info, in btrfs_init_dev_replace()
158 WARN_ON(fs_info->fs_devices->rw_devices == 0); in btrfs_init_dev_replace()
159 dev_replace->tgtdev->io_width = fs_info->sectorsize; in btrfs_init_dev_replace()
160 dev_replace->tgtdev->io_align = fs_info->sectorsize; in btrfs_init_dev_replace()
161 dev_replace->tgtdev->sector_size = fs_info->sectorsize; in btrfs_init_dev_replace()
162 dev_replace->tgtdev->fs_info = fs_info; in btrfs_init_dev_replace()
180 static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info, in btrfs_init_dev_replace_tgtdev() argument
193 if (fs_info->fs_devices->seeding) { in btrfs_init_dev_replace_tgtdev()
194 btrfs_err(fs_info, "the filesystem is a seed filesystem!"); in btrfs_init_dev_replace_tgtdev()
199 fs_info->bdev_holder); in btrfs_init_dev_replace_tgtdev()
201 btrfs_err(fs_info, "target device %s is invalid!", device_path); in btrfs_init_dev_replace_tgtdev()
207 devices = &fs_info->fs_devices->devices; in btrfs_init_dev_replace_tgtdev()
210 btrfs_err(fs_info, in btrfs_init_dev_replace_tgtdev()
220 btrfs_err(fs_info, in btrfs_init_dev_replace_tgtdev()
241 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
244 device->io_width = fs_info->sectorsize; in btrfs_init_dev_replace_tgtdev()
245 device->io_align = fs_info->sectorsize; in btrfs_init_dev_replace_tgtdev()
246 device->sector_size = fs_info->sectorsize; in btrfs_init_dev_replace_tgtdev()
252 device->fs_info = fs_info; in btrfs_init_dev_replace_tgtdev()
259 device->fs_devices = fs_info->fs_devices; in btrfs_init_dev_replace_tgtdev()
260 list_add(&device->dev_list, &fs_info->fs_devices->devices); in btrfs_init_dev_replace_tgtdev()
261 fs_info->fs_devices->num_devices++; in btrfs_init_dev_replace_tgtdev()
262 fs_info->fs_devices->open_devices++; in btrfs_init_dev_replace_tgtdev()
263 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_init_dev_replace_tgtdev()
278 struct btrfs_fs_info *fs_info) in btrfs_run_dev_replace() argument
281 struct btrfs_root *dev_root = fs_info->dev_root; in btrfs_run_dev_replace()
286 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_run_dev_replace()
307 btrfs_warn(fs_info, in btrfs_run_dev_replace()
328 btrfs_warn(fs_info, in btrfs_run_dev_replace()
342 btrfs_warn(fs_info, in btrfs_run_dev_replace()
385 void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info) in btrfs_after_dev_replace_commit() argument
387 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_after_dev_replace_commit()
401 int btrfs_dev_replace_start(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_start() argument
405 struct btrfs_root *root = fs_info->dev_root; in btrfs_dev_replace_start()
407 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_start()
412 ret = btrfs_find_device_by_devspec(fs_info, srcdevid, in btrfs_dev_replace_start()
417 ret = btrfs_init_dev_replace_tgtdev(fs_info, tgtdev_name, in btrfs_dev_replace_start()
452 btrfs_info_in_rcu(fs_info, in btrfs_dev_replace_start()
476 btrfs_err(fs_info, "kobj add dev failed %d", ret); in btrfs_dev_replace_start()
478 btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); in btrfs_dev_replace_start()
492 ret = btrfs_scrub_dev(fs_info, src_device->devid, 0, in btrfs_dev_replace_start()
496 ret = btrfs_dev_replace_finishing(fs_info, ret); in btrfs_dev_replace_start()
513 int btrfs_dev_replace_by_ioctl(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_by_ioctl() argument
530 ret = btrfs_dev_replace_start(fs_info, args->start.tgtdev_name, in btrfs_dev_replace_by_ioctl()
545 static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) in btrfs_rm_dev_replace_blocked() argument
547 set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); in btrfs_rm_dev_replace_blocked()
548 wait_event(fs_info->replace_wait, !percpu_counter_sum( in btrfs_rm_dev_replace_blocked()
549 &fs_info->bio_counter)); in btrfs_rm_dev_replace_blocked()
555 static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info) in btrfs_rm_dev_replace_unblocked() argument
557 clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); in btrfs_rm_dev_replace_unblocked()
558 wake_up(&fs_info->replace_wait); in btrfs_rm_dev_replace_unblocked()
561 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_finishing() argument
564 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_finishing()
567 struct btrfs_root *root = fs_info->tree_root; in btrfs_dev_replace_finishing()
592 ret = btrfs_start_delalloc_roots(fs_info, -1); in btrfs_dev_replace_finishing()
597 btrfs_wait_ordered_roots(fs_info, U64_MAX, 0, (u64)-1); in btrfs_dev_replace_finishing()
608 mutex_lock(&fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
609 mutex_lock(&fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
621 btrfs_dev_replace_update_device_in_mapping_tree(fs_info, in btrfs_dev_replace_finishing()
625 btrfs_err_in_rcu(fs_info, in btrfs_dev_replace_finishing()
631 mutex_unlock(&fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
632 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
633 btrfs_rm_dev_replace_blocked(fs_info); in btrfs_dev_replace_finishing()
636 btrfs_rm_dev_replace_unblocked(fs_info); in btrfs_dev_replace_finishing()
642 btrfs_info_in_rcu(fs_info, in btrfs_dev_replace_finishing()
663 list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); in btrfs_dev_replace_finishing()
664 fs_info->fs_devices->rw_devices++; in btrfs_dev_replace_finishing()
668 btrfs_rm_dev_replace_blocked(fs_info); in btrfs_dev_replace_finishing()
672 btrfs_rm_dev_replace_unblocked(fs_info); in btrfs_dev_replace_finishing()
687 mutex_unlock(&fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
688 mutex_unlock(&fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
691 btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device); in btrfs_dev_replace_finishing()
692 btrfs_rm_dev_replace_free_srcdev(fs_info, src_device); in btrfs_dev_replace_finishing()
705 struct btrfs_fs_info *fs_info, in btrfs_dev_replace_update_device_in_mapping_tree() argument
709 struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree; in btrfs_dev_replace_update_device_in_mapping_tree()
735 static u64 btrfs_dev_replace_progress(struct btrfs_fs_info *fs_info) in btrfs_dev_replace_progress() argument
737 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_progress()
759 void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_status() argument
762 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_status()
775 args->status.progress_1000 = btrfs_dev_replace_progress(fs_info); in btrfs_dev_replace_status()
779 int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) in btrfs_dev_replace_cancel() argument
781 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_cancel()
785 struct btrfs_root *root = fs_info->tree_root; in btrfs_dev_replace_cancel()
789 if (sb_rdonly(fs_info->sb)) in btrfs_dev_replace_cancel()
814 btrfs_scrub_cancel(fs_info); in btrfs_dev_replace_cancel()
824 btrfs_info_in_rcu(fs_info, in btrfs_dev_replace_cancel()
837 void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info) in btrfs_dev_replace_suspend_for_unmount() argument
839 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_suspend_for_unmount()
854 btrfs_info(fs_info, "suspending dev_replace for unmount"); in btrfs_dev_replace_suspend_for_unmount()
863 int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info) in btrfs_resume_dev_replace_async() argument
866 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_resume_dev_replace_async()
883 btrfs_info(fs_info, in btrfs_resume_dev_replace_async()
885 btrfs_info(fs_info, in btrfs_resume_dev_replace_async()
897 if (test_and_set_bit(BTRFS_FS_EXCL_OP, &fs_info->flags)) { in btrfs_resume_dev_replace_async()
898 btrfs_info(fs_info, in btrfs_resume_dev_replace_async()
903 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl"); in btrfs_resume_dev_replace_async()
909 struct btrfs_fs_info *fs_info = data; in btrfs_dev_replace_kthread() local
910 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_kthread()
914 progress = btrfs_dev_replace_progress(fs_info); in btrfs_dev_replace_kthread()
916 btrfs_info_in_rcu(fs_info, in btrfs_dev_replace_kthread()
923 ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid, in btrfs_dev_replace_kthread()
927 ret = btrfs_dev_replace_finishing(fs_info, ret); in btrfs_dev_replace_kthread()
930 clear_bit(BTRFS_FS_EXCL_OP, &fs_info->flags); in btrfs_dev_replace_kthread()
1015 void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info) in btrfs_bio_counter_inc_noblocked() argument
1017 percpu_counter_inc(&fs_info->bio_counter); in btrfs_bio_counter_inc_noblocked()
1020 void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount) in btrfs_bio_counter_sub() argument
1022 percpu_counter_sub(&fs_info->bio_counter, amount); in btrfs_bio_counter_sub()
1023 cond_wake_up_nomb(&fs_info->replace_wait); in btrfs_bio_counter_sub()
1026 void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) in btrfs_bio_counter_inc_blocked() argument
1029 percpu_counter_inc(&fs_info->bio_counter); in btrfs_bio_counter_inc_blocked()
1031 &fs_info->fs_state))) in btrfs_bio_counter_inc_blocked()
1034 btrfs_bio_counter_dec(fs_info); in btrfs_bio_counter_inc_blocked()
1035 wait_event(fs_info->replace_wait, in btrfs_bio_counter_inc_blocked()
1037 &fs_info->fs_state)); in btrfs_bio_counter_inc_blocked()