• Home
  • Raw
  • Download

Lines Matching refs:fs_info

41 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info,
44 struct btrfs_fs_info *fs_info,
50 static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info);
52 static int btrfs_dev_replace_continue_on_mount(struct btrfs_fs_info *fs_info);
55 int btrfs_init_dev_replace(struct btrfs_fs_info *fs_info) in btrfs_init_dev_replace() argument
58 struct btrfs_root *dev_root = fs_info->dev_root; in btrfs_init_dev_replace()
59 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_init_dev_replace()
106 btrfs_warn(fs_info, in btrfs_init_dev_replace()
138 dev_replace->srcdev = btrfs_find_device(fs_info, src_devid, in btrfs_init_dev_replace()
140 dev_replace->tgtdev = btrfs_find_device(fs_info, in btrfs_init_dev_replace()
150 btrfs_warn(fs_info, in btrfs_init_dev_replace()
152 btrfs_warn(fs_info, in btrfs_init_dev_replace()
159 btrfs_warn(fs_info, in btrfs_init_dev_replace()
161 btrfs_warn(fs_info, in btrfs_init_dev_replace()
179 btrfs_init_dev_replace_tgtdev_for_resume(fs_info, in btrfs_init_dev_replace()
195 struct btrfs_fs_info *fs_info) in btrfs_run_dev_replace() argument
198 struct btrfs_root *dev_root = fs_info->dev_root; in btrfs_run_dev_replace()
203 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_run_dev_replace()
224 btrfs_warn(fs_info, "error %d while searching for dev_replace item!", in btrfs_run_dev_replace()
244 btrfs_warn(fs_info, "delete too small dev_replace item failed %d!", in btrfs_run_dev_replace()
257 btrfs_warn(fs_info, "insert dev_replace item failed %d!", in btrfs_run_dev_replace()
300 void btrfs_after_dev_replace_commit(struct btrfs_fs_info *fs_info) in btrfs_after_dev_replace_commit() argument
302 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_after_dev_replace_commit()
312 struct btrfs_fs_info *fs_info = root->fs_info; in btrfs_dev_replace_start() local
313 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_start()
331 mutex_lock(&fs_info->volume_mutex); in btrfs_dev_replace_start()
336 mutex_unlock(&fs_info->volume_mutex); in btrfs_dev_replace_start()
342 mutex_unlock(&fs_info->volume_mutex); in btrfs_dev_replace_start()
378 btrfs_info_in_rcu(root->fs_info, in btrfs_dev_replace_start()
402 btrfs_err(root->fs_info, "kobj add dev failed %d\n", ret); in btrfs_dev_replace_start()
404 btrfs_wait_ordered_roots(root->fs_info, -1); in btrfs_dev_replace_start()
418 ret = btrfs_scrub_dev(fs_info, src_device->devid, 0, in btrfs_dev_replace_start()
422 ret = btrfs_dev_replace_finishing(root->fs_info, ret); in btrfs_dev_replace_start()
437 btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); in btrfs_dev_replace_start()
444 static void btrfs_rm_dev_replace_blocked(struct btrfs_fs_info *fs_info) in btrfs_rm_dev_replace_blocked() argument
446 set_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); in btrfs_rm_dev_replace_blocked()
447 wait_event(fs_info->replace_wait, !percpu_counter_sum( in btrfs_rm_dev_replace_blocked()
448 &fs_info->bio_counter)); in btrfs_rm_dev_replace_blocked()
454 static void btrfs_rm_dev_replace_unblocked(struct btrfs_fs_info *fs_info) in btrfs_rm_dev_replace_unblocked() argument
456 clear_bit(BTRFS_FS_STATE_DEV_REPLACING, &fs_info->fs_state); in btrfs_rm_dev_replace_unblocked()
457 wake_up(&fs_info->replace_wait); in btrfs_rm_dev_replace_unblocked()
460 static int btrfs_dev_replace_finishing(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_finishing() argument
463 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_finishing()
466 struct btrfs_root *root = fs_info->tree_root; in btrfs_dev_replace_finishing()
491 ret = btrfs_start_delalloc_roots(root->fs_info, 0, -1); in btrfs_dev_replace_finishing()
496 btrfs_wait_ordered_roots(root->fs_info, -1); in btrfs_dev_replace_finishing()
508 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
509 mutex_lock(&root->fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
511 mutex_unlock(&root->fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
512 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
530 btrfs_dev_replace_update_device_in_mapping_tree(fs_info, in btrfs_dev_replace_finishing()
534 btrfs_err_in_rcu(root->fs_info, in btrfs_dev_replace_finishing()
541 mutex_unlock(&root->fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
542 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
545 btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); in btrfs_dev_replace_finishing()
551 btrfs_info_in_rcu(root->fs_info, in btrfs_dev_replace_finishing()
570 if (fs_info->sb->s_bdev == src_device->bdev) in btrfs_dev_replace_finishing()
571 fs_info->sb->s_bdev = tgt_device->bdev; in btrfs_dev_replace_finishing()
572 if (fs_info->fs_devices->latest_bdev == src_device->bdev) in btrfs_dev_replace_finishing()
573 fs_info->fs_devices->latest_bdev = tgt_device->bdev; in btrfs_dev_replace_finishing()
574 list_add(&tgt_device->dev_alloc_list, &fs_info->fs_devices->alloc_list); in btrfs_dev_replace_finishing()
575 fs_info->fs_devices->rw_devices++; in btrfs_dev_replace_finishing()
579 btrfs_rm_dev_replace_blocked(fs_info); in btrfs_dev_replace_finishing()
581 btrfs_rm_dev_replace_remove_srcdev(fs_info, src_device); in btrfs_dev_replace_finishing()
583 btrfs_rm_dev_replace_unblocked(fs_info); in btrfs_dev_replace_finishing()
598 mutex_unlock(&root->fs_info->chunk_mutex); in btrfs_dev_replace_finishing()
599 mutex_unlock(&root->fs_info->fs_devices->device_list_mutex); in btrfs_dev_replace_finishing()
603 btrfs_sysfs_rm_device_link(fs_info->fs_devices, src_device); in btrfs_dev_replace_finishing()
604 btrfs_rm_dev_replace_free_srcdev(fs_info, src_device); in btrfs_dev_replace_finishing()
617 struct btrfs_fs_info *fs_info, in btrfs_dev_replace_update_device_in_mapping_tree() argument
621 struct extent_map_tree *em_tree = &fs_info->mapping_tree.map_tree; in btrfs_dev_replace_update_device_in_mapping_tree()
650 *device = btrfs_find_device(root->fs_info, srcdevid, NULL, in btrfs_dev_replace_find_srcdev()
661 void btrfs_dev_replace_status(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_status() argument
664 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_status()
696 int btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info, in btrfs_dev_replace_cancel() argument
699 args->result = __btrfs_dev_replace_cancel(fs_info); in btrfs_dev_replace_cancel()
703 static u64 __btrfs_dev_replace_cancel(struct btrfs_fs_info *fs_info) in __btrfs_dev_replace_cancel() argument
705 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in __btrfs_dev_replace_cancel()
708 struct btrfs_root *root = fs_info->tree_root; in __btrfs_dev_replace_cancel()
712 if (fs_info->sb->s_flags & MS_RDONLY) in __btrfs_dev_replace_cancel()
736 btrfs_scrub_cancel(fs_info); in __btrfs_dev_replace_cancel()
746 btrfs_destroy_dev_replace_tgtdev(fs_info, tgt_device); in __btrfs_dev_replace_cancel()
753 void btrfs_dev_replace_suspend_for_unmount(struct btrfs_fs_info *fs_info) in btrfs_dev_replace_suspend_for_unmount() argument
755 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_suspend_for_unmount()
770 btrfs_info(fs_info, "suspending dev_replace for unmount"); in btrfs_dev_replace_suspend_for_unmount()
779 int btrfs_resume_dev_replace_async(struct btrfs_fs_info *fs_info) in btrfs_resume_dev_replace_async() argument
782 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_resume_dev_replace_async()
799 btrfs_info(fs_info, "cannot continue dev_replace, tgtdev is missing"); in btrfs_resume_dev_replace_async()
800 btrfs_info(fs_info, in btrfs_resume_dev_replace_async()
808 &fs_info->mutually_exclusive_operation_running, 1)); in btrfs_resume_dev_replace_async()
809 task = kthread_run(btrfs_dev_replace_kthread, fs_info, "btrfs-devrepl"); in btrfs_resume_dev_replace_async()
815 struct btrfs_fs_info *fs_info = data; in btrfs_dev_replace_kthread() local
816 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_kthread()
822 btrfs_dev_replace_status(fs_info, status_args); in btrfs_dev_replace_kthread()
826 btrfs_info_in_rcu(fs_info, in btrfs_dev_replace_kthread()
836 btrfs_dev_replace_continue_on_mount(fs_info); in btrfs_dev_replace_kthread()
837 atomic_set(&fs_info->mutually_exclusive_operation_running, 0); in btrfs_dev_replace_kthread()
842 static int btrfs_dev_replace_continue_on_mount(struct btrfs_fs_info *fs_info) in btrfs_dev_replace_continue_on_mount() argument
844 struct btrfs_dev_replace *dev_replace = &fs_info->dev_replace; in btrfs_dev_replace_continue_on_mount()
847 ret = btrfs_scrub_dev(fs_info, dev_replace->srcdev->devid, in btrfs_dev_replace_continue_on_mount()
851 ret = btrfs_dev_replace_finishing(fs_info, ret); in btrfs_dev_replace_continue_on_mount()
927 void btrfs_bio_counter_inc_noblocked(struct btrfs_fs_info *fs_info) in btrfs_bio_counter_inc_noblocked() argument
929 percpu_counter_inc(&fs_info->bio_counter); in btrfs_bio_counter_inc_noblocked()
932 void btrfs_bio_counter_sub(struct btrfs_fs_info *fs_info, s64 amount) in btrfs_bio_counter_sub() argument
934 percpu_counter_sub(&fs_info->bio_counter, amount); in btrfs_bio_counter_sub()
936 if (waitqueue_active(&fs_info->replace_wait)) in btrfs_bio_counter_sub()
937 wake_up(&fs_info->replace_wait); in btrfs_bio_counter_sub()
940 void btrfs_bio_counter_inc_blocked(struct btrfs_fs_info *fs_info) in btrfs_bio_counter_inc_blocked() argument
943 percpu_counter_inc(&fs_info->bio_counter); in btrfs_bio_counter_inc_blocked()
945 &fs_info->fs_state))) in btrfs_bio_counter_inc_blocked()
948 btrfs_bio_counter_dec(fs_info); in btrfs_bio_counter_inc_blocked()
949 wait_event(fs_info->replace_wait, in btrfs_bio_counter_inc_blocked()
951 &fs_info->fs_state)); in btrfs_bio_counter_inc_blocked()