Skip to content

Commit

Permalink
Btrfs: protect devices list with its mutex
Browse files Browse the repository at this point in the history
Since we've kill the bigger one volume_mutex, we need to add devices
list mutex back.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
  • Loading branch information
Liu Bo authored and Josef Bacik committed Dec 12, 2012
1 parent b53d3f5 commit d25628b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fs/btrfs/volumes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1681,16 +1681,17 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
filemap_write_and_wait(bdev->bd_inode->i_mapping);

devices = &root->fs_info->fs_devices->devices;
/*
* we have the volume lock, so we don't need the extra
* device list mutex while reading the list here.
*/

mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
list_for_each_entry(device, devices, dev_list) {
if (device->bdev == bdev) {
ret = -EEXIST;
mutex_unlock(
&root->fs_info->fs_devices->device_list_mutex);
goto error;
}
}
mutex_unlock(&root->fs_info->fs_devices->device_list_mutex);

device = kzalloc(sizeof(*device), GFP_NOFS);
if (!device) {
Expand Down

0 comments on commit d25628b

Please sign in to comment.