Commit c3929c36 authored by Miao Xie's avatar Miao Xie Committed by Chris Mason

Btrfs: modify rw_devices counter under chunk_mutex context

rw_devices counter is often used to tune the profile when doing chunk allocation,
so we should modify it under the chunk_mutex context to avoid getting wrong
chunk profile.
Signed-off-by: default avatarMiao Xie <miaox@cn.fujitsu.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 5f375835
...@@ -1649,8 +1649,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1649,8 +1649,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
if (device->writeable) { if (device->writeable) {
lock_chunks(root); lock_chunks(root);
list_del_init(&device->dev_alloc_list); list_del_init(&device->dev_alloc_list);
device->fs_devices->rw_devices--;
unlock_chunks(root); unlock_chunks(root);
root->fs_info->fs_devices->rw_devices--;
clear_super = true; clear_super = true;
} }
...@@ -1795,8 +1795,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) ...@@ -1795,8 +1795,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
lock_chunks(root); lock_chunks(root);
list_add(&device->dev_alloc_list, list_add(&device->dev_alloc_list,
&root->fs_info->fs_devices->alloc_list); &root->fs_info->fs_devices->alloc_list);
device->fs_devices->rw_devices++;
unlock_chunks(root); unlock_chunks(root);
root->fs_info->fs_devices->rw_devices++;
} }
goto error_brelse; goto error_brelse;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment