summaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@cn.fujitsu.com>2011-04-20 10:08:16 +0000
committerChris Mason <chris.mason@oracle.com>2011-05-23 13:24:43 -0400
commit0c1daee085cff1395d1eba4ad6faff7810a594d8 (patch)
treea7c86b2b7aaed74e8a4daebc3f1d8da6875c1e1b /fs
parentc9513edb0079f97749c2ac00c887a22c4ba44792 (diff)
downloadlinux-stable-0c1daee085cff1395d1eba4ad6faff7810a594d8.tar.gz
linux-stable-0c1daee085cff1395d1eba4ad6faff7810a594d8.tar.bz2
linux-stable-0c1daee085cff1395d1eba4ad6faff7810a594d8.zip
Btrfs: fix the race between remove dev and alloc chunk
On remove device path, it updates device->dev_alloc_list but does not hold chunk lock Signed-off-by: Xiao Guangrong <xiaoguangrong@cn.fujitsu.com> Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/volumes.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 43c4f09e441c..ee197ec28547 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1291,7 +1291,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
}
if (device->writeable) {
+ lock_chunks(root);
list_del_init(&device->dev_alloc_list);
+ unlock_chunks(root);
root->fs_info->fs_devices->rw_devices--;
}
@@ -1345,7 +1347,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
}
fs_devices->seed = device->fs_devices->seed;
device->fs_devices->seed = NULL;
+ lock_chunks(root);
__btrfs_close_devices(device->fs_devices);
+ unlock_chunks(root);
free_fs_devices(device->fs_devices);
}
@@ -1377,8 +1381,10 @@ out:
return ret;
error_undo:
if (device->writeable) {
+ lock_chunks(root);
list_add(&device->dev_alloc_list,
&root->fs_info->fs_devices->alloc_list);
+ unlock_chunks(root);
root->fs_info->fs_devices->rw_devices++;
}
goto error_brelse;