Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 311660
b: refs/heads/master
c: 2b6ba62
h: refs/heads/master
v: v3
  • Loading branch information
Ilya Dryomov authored and Chris Mason committed Jul 2, 2012
1 parent 42b5f47 commit 8c37c81
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 19 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 68310a5e42f93c2242ec1836c3b18d531e0065e2
refs/heads/master: 2b6ba629b5aac51e7099efbb43e2b403213aa7fb
24 changes: 15 additions & 9 deletions trunk/fs/btrfs/disk-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -2490,17 +2490,23 @@ int open_ctree(struct super_block *sb,
goto fail_trans_kthread;
}

if (!(sb->s_flags & MS_RDONLY)) {
down_read(&fs_info->cleanup_work_sem);
err = btrfs_orphan_cleanup(fs_info->fs_root);
if (!err)
err = btrfs_orphan_cleanup(fs_info->tree_root);
if (sb->s_flags & MS_RDONLY)
return 0;

down_read(&fs_info->cleanup_work_sem);
if ((ret = btrfs_orphan_cleanup(fs_info->fs_root)) ||
(ret = btrfs_orphan_cleanup(fs_info->tree_root))) {
up_read(&fs_info->cleanup_work_sem);
close_ctree(tree_root);
return ret;
}
up_read(&fs_info->cleanup_work_sem);

if (err) {
close_ctree(tree_root);
return err;
}
ret = btrfs_resume_balance_async(fs_info);
if (ret) {
printk(KERN_WARNING "btrfs: failed to resume balance\n");
close_ctree(tree_root);
return ret;
}

return 0;
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/btrfs/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,10 @@ static int btrfs_remount(struct super_block *sb, int *flags, char *data)
if (ret)
goto restore;

ret = btrfs_resume_balance_async(fs_info);
if (ret)
goto restore;

sb->s_flags &= ~MS_RDONLY;
}

Expand Down
36 changes: 27 additions & 9 deletions trunk/fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -2845,28 +2845,46 @@ int btrfs_balance(struct btrfs_balance_control *bctl,

static int balance_kthread(void *data)
{
struct btrfs_balance_control *bctl =
(struct btrfs_balance_control *)data;
struct btrfs_fs_info *fs_info = bctl->fs_info;
struct btrfs_fs_info *fs_info = data;
int ret = 0;

mutex_lock(&fs_info->volume_mutex);
mutex_lock(&fs_info->balance_mutex);

set_balance_control(bctl);

if (btrfs_test_opt(fs_info->tree_root, SKIP_BALANCE)) {
printk(KERN_INFO "btrfs: force skipping balance\n");
} else {
if (fs_info->balance_ctl) {
printk(KERN_INFO "btrfs: continuing balance\n");
ret = btrfs_balance(bctl, NULL);
ret = btrfs_balance(fs_info->balance_ctl, NULL);
}

mutex_unlock(&fs_info->balance_mutex);
mutex_unlock(&fs_info->volume_mutex);

return ret;
}

int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info)
{
struct task_struct *tsk;

spin_lock(&fs_info->balance_lock);
if (!fs_info->balance_ctl) {
spin_unlock(&fs_info->balance_lock);
return 0;
}
spin_unlock(&fs_info->balance_lock);

if (btrfs_test_opt(fs_info->tree_root, SKIP_BALANCE)) {
printk(KERN_INFO "btrfs: force skipping balance\n");
return 0;
}

tsk = kthread_run(balance_kthread, fs_info, "btrfs-balance");
if (IS_ERR(tsk))
return PTR_ERR(tsk);

return 0;
}

int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
{
struct btrfs_balance_control *bctl;
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/btrfs/volumes.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,7 @@ int btrfs_shrink_device(struct btrfs_device *device, u64 new_size);
int btrfs_init_new_device(struct btrfs_root *root, char *path);
int btrfs_balance(struct btrfs_balance_control *bctl,
struct btrfs_ioctl_balance_args *bargs);
int btrfs_resume_balance_async(struct btrfs_fs_info *fs_info);
int btrfs_recover_balance(struct btrfs_fs_info *fs_info);
int btrfs_pause_balance(struct btrfs_fs_info *fs_info);
int btrfs_cancel_balance(struct btrfs_fs_info *fs_info);
Expand Down

0 comments on commit 8c37c81

Please sign in to comment.