diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 48943d0f861a..ecaad40e7ef4 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
@@ -2845,28 +2845,46 @@ out: | |||
2845 | 2845 | ||
2846 | static int balance_kthread(void *data) | 2846 | static int balance_kthread(void *data) |
2847 | { | 2847 | { |
2848 | struct btrfs_balance_control *bctl = | 2848 | struct btrfs_fs_info *fs_info = data; |
2849 | (struct btrfs_balance_control *)data; | ||
2850 | struct btrfs_fs_info *fs_info = bctl->fs_info; | ||
2851 | int ret = 0; | 2849 | int ret = 0; |
2852 | 2850 | ||
2853 | mutex_lock(&fs_info->volume_mutex); | 2851 | mutex_lock(&fs_info->volume_mutex); |
2854 | mutex_lock(&fs_info->balance_mutex); | 2852 | mutex_lock(&fs_info->balance_mutex); |
2855 | 2853 | ||
2856 | set_balance_control(bctl); | 2854 | if (fs_info->balance_ctl) { |
2857 | |||
2858 | if (btrfs_test_opt(fs_info->tree_root, SKIP_BALANCE)) { | ||
2859 | printk(KERN_INFO "btrfs: force skipping balance\n"); | ||
2860 | } else { | ||
2861 | printk(KERN_INFO "btrfs: continuing balance\n"); | 2855 | printk(KERN_INFO "btrfs: continuing balance\n"); |
2862 | ret = btrfs_balance(bctl, NULL); | 2856 | ret = btrfs_balance(fs_info->balance_ctl, NULL); |
2863 | } | 2857 | } |
2864 | 2858 | ||
2865 | mutex_unlock(&fs_info->balance_mutex); | 2859 | mutex_unlock(&fs_info->balance_mutex); |
2866 | mutex_unlock(&fs_info->volume_mutex); | 2860 | mutex_unlock(&fs_info->volume_mutex); |
2861 | |||
2867 | return ret; | 2862 | return ret; |
2868 | } | 2863 | } |
2869 | 2864 | ||
2865 | int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info) | ||
2866 | { | ||
2867 | struct task_struct *tsk; | ||
2868 | |||
2869 | spin_lock(&fs_info->balance_lock); | ||
2870 | if (!fs_info->balance_ctl) { | ||
2871 | spin_unlock(&fs_info->balance_lock); | ||
2872 | return 0; | ||
2873 | } | ||
2874 | spin_unlock(&fs_info->balance_lock); | ||
2875 | |||
2876 | if (btrfs_test_opt(fs_info->tree_root, SKIP_BALANCE)) { | ||
2877 | printk(KERN_INFO "btrfs: force skipping balance\n"); | ||
2878 | return 0; | ||
2879 | } | ||
2880 | |||
2881 | tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance"); | ||
2882 | if (IS_ERR(tsk)) | ||
2883 | return PTR_ERR(tsk); | ||
2884 | |||
2885 | return 0; | ||
2886 | } | ||
2887 | |||
2870 | int btrfs_recover_balance(struct btrfs_fs_info *fs_info) | 2888 | int btrfs_recover_balance(struct btrfs_fs_info *fs_info) |
2871 | { | 2889 | { |
2872 | struct btrfs_balance_control *bctl; | 2890 | struct btrfs_balance_control *bctl; |