Btrfs: restore restriper state on all mounts
Fix a bug that triggered asserts in btrfs_balance() in both normal and resume modes -- restriper state was not properly restored on read-only mounts. This factors out resuming code from btrfs_restore_balance(), which is now also called earlier in the mount sequence to avoid the problem of some early writes getting the old profile. Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
这个提交包含在:
@@ -2867,9 +2867,8 @@ static int balance_kthread(void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
int btrfs_recover_balance(struct btrfs_root *tree_root)
|
||||
int btrfs_recover_balance(struct btrfs_fs_info *fs_info)
|
||||
{
|
||||
struct task_struct *tsk;
|
||||
struct btrfs_balance_control *bctl;
|
||||
struct btrfs_balance_item *item;
|
||||
struct btrfs_disk_balance_args disk_bargs;
|
||||
@@ -2882,29 +2881,30 @@ int btrfs_recover_balance(struct btrfs_root *tree_root)
|
||||
if (!path)
|
||||
return -ENOMEM;
|
||||
|
||||
key.objectid = BTRFS_BALANCE_OBJECTID;
|
||||
key.type = BTRFS_BALANCE_ITEM_KEY;
|
||||
key.offset = 0;
|
||||
|
||||
ret = btrfs_search_slot(NULL, fs_info->tree_root, &key, path, 0, 0);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
if (ret > 0) { /* ret = -ENOENT; */
|
||||
ret = 0;
|
||||
goto out;
|
||||
}
|
||||
|
||||
bctl = kzalloc(sizeof(*bctl), GFP_NOFS);
|
||||
if (!bctl) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
key.objectid = BTRFS_BALANCE_OBJECTID;
|
||||
key.type = BTRFS_BALANCE_ITEM_KEY;
|
||||
key.offset = 0;
|
||||
|
||||
ret = btrfs_search_slot(NULL, tree_root, &key, path, 0, 0);
|
||||
if (ret < 0)
|
||||
goto out_bctl;
|
||||
if (ret > 0) { /* ret = -ENOENT; */
|
||||
ret = 0;
|
||||
goto out_bctl;
|
||||
}
|
||||
|
||||
leaf = path->nodes[0];
|
||||
item = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_balance_item);
|
||||
|
||||
bctl->fs_info = tree_root->fs_info;
|
||||
bctl->flags = btrfs_balance_flags(leaf, item) | BTRFS_BALANCE_RESUME;
|
||||
bctl->fs_info = fs_info;
|
||||
bctl->flags = btrfs_balance_flags(leaf, item);
|
||||
bctl->flags |= BTRFS_BALANCE_RESUME;
|
||||
|
||||
btrfs_balance_data(leaf, item, &disk_bargs);
|
||||
btrfs_disk_balance_args_to_cpu(&bctl->data, &disk_bargs);
|
||||
@@ -2913,14 +2913,13 @@ int btrfs_recover_balance(struct btrfs_root *tree_root)
|
||||
btrfs_balance_sys(leaf, item, &disk_bargs);
|
||||
btrfs_disk_balance_args_to_cpu(&bctl->sys, &disk_bargs);
|
||||
|
||||
tsk = kthread_run(balance_kthread, bctl, "btrfs-balance");
|
||||
if (IS_ERR(tsk))
|
||||
ret = PTR_ERR(tsk);
|
||||
else
|
||||
goto out;
|
||||
mutex_lock(&fs_info->volume_mutex);
|
||||
mutex_lock(&fs_info->balance_mutex);
|
||||
|
||||
out_bctl:
|
||||
kfree(bctl);
|
||||
set_balance_control(bctl);
|
||||
|
||||
mutex_unlock(&fs_info->balance_mutex);
|
||||
mutex_unlock(&fs_info->volume_mutex);
|
||||
out:
|
||||
btrfs_free_path(path);
|
||||
return ret;
|
||||
|
在新工单中引用
屏蔽一个用户