aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-06-25 16:01:30 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:03 -0400
commita213501153fd66e2359e091b1612841305ba6551 (patch)
tree1f4c316c9d3cad0eb6d9be14cb0e67e46e815dce /fs/btrfs/volumes.c
parent925baeddc5b0764a53f2214a1253251bab0e0324 (diff)
Btrfs: Replace the big fs_mutex with a collection of other locks
Extent alloctions are still protected by a large alloc_mutex. Objectid allocations are covered by a objectid mutex Other btree operations are protected by a lock on individual btree nodes Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index ba3968571024..869864ddcc29 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -866,7 +866,8 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path)
866 u64 devid; 866 u64 devid;
867 int ret = 0; 867 int ret = 0;
868 868
869 mutex_lock(&root->fs_info->fs_mutex); 869 mutex_lock(&root->fs_info->alloc_mutex);
870 mutex_lock(&root->fs_info->chunk_mutex);
870 mutex_lock(&uuid_mutex); 871 mutex_lock(&uuid_mutex);
871 872
872 all_avail = root->fs_info->avail_data_alloc_bits | 873 all_avail = root->fs_info->avail_data_alloc_bits |
@@ -984,7 +985,8 @@ error_close:
984 close_bdev_excl(bdev); 985 close_bdev_excl(bdev);
985out: 986out:
986 mutex_unlock(&uuid_mutex); 987 mutex_unlock(&uuid_mutex);
987 mutex_unlock(&root->fs_info->fs_mutex); 988 mutex_unlock(&root->fs_info->chunk_mutex);
989 mutex_unlock(&root->fs_info->alloc_mutex);
988 return ret; 990 return ret;
989} 991}
990 992
@@ -1003,7 +1005,10 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1003 if (!bdev) { 1005 if (!bdev) {
1004 return -EIO; 1006 return -EIO;
1005 } 1007 }
1006 mutex_lock(&root->fs_info->fs_mutex); 1008
1009 mutex_lock(&root->fs_info->alloc_mutex);
1010 mutex_lock(&root->fs_info->chunk_mutex);
1011
1007 trans = btrfs_start_transaction(root, 1); 1012 trans = btrfs_start_transaction(root, 1);
1008 devices = &root->fs_info->fs_devices->devices; 1013 devices = &root->fs_info->fs_devices->devices;
1009 list_for_each(cur, devices) { 1014 list_for_each(cur, devices) {
@@ -1057,7 +1062,9 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
1057 root->fs_info->fs_devices->open_devices++; 1062 root->fs_info->fs_devices->open_devices++;
1058out: 1063out:
1059 btrfs_end_transaction(trans, root); 1064 btrfs_end_transaction(trans, root);
1060 mutex_unlock(&root->fs_info->fs_mutex); 1065 mutex_unlock(&root->fs_info->chunk_mutex);
1066 mutex_unlock(&root->fs_info->alloc_mutex);
1067
1061 return ret; 1068 return ret;
1062 1069
1063out_close_bdev: 1070out_close_bdev:
@@ -1297,9 +1304,10 @@ int btrfs_balance(struct btrfs_root *dev_root)
1297 struct btrfs_key found_key; 1304 struct btrfs_key found_key;
1298 1305
1299 1306
1307 BUG(); /* FIXME, needs locking */
1308
1300 dev_root = dev_root->fs_info->dev_root; 1309 dev_root = dev_root->fs_info->dev_root;
1301 1310
1302 mutex_lock(&dev_root->fs_info->fs_mutex);
1303 /* step one make some room on all the devices */ 1311 /* step one make some room on all the devices */
1304 list_for_each(cur, devices) { 1312 list_for_each(cur, devices) {
1305 device = list_entry(cur, struct btrfs_device, dev_list); 1313 device = list_entry(cur, struct btrfs_device, dev_list);
@@ -1368,7 +1376,6 @@ int btrfs_balance(struct btrfs_root *dev_root)
1368 ret = 0; 1376 ret = 0;
1369error: 1377error:
1370 btrfs_free_path(path); 1378 btrfs_free_path(path);
1371 mutex_unlock(&dev_root->fs_info->fs_mutex);
1372 return ret; 1379 return ret;
1373} 1380}
1374 1381