diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-06-25 16:01:30 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:03 -0400 |
commit | a213501153fd66e2359e091b1612841305ba6551 (patch) | |
tree | 1f4c316c9d3cad0eb6d9be14cb0e67e46e815dce /fs/btrfs/disk-io.c | |
parent | 925baeddc5b0764a53f2214a1253251bab0e0324 (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/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index fe40bdd984ff..f638803549e0 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -724,6 +724,7 @@ static int __setup_root(u32 nodesize, u32 leafsize, u32 sectorsize, | |||
724 | 724 | ||
725 | INIT_LIST_HEAD(&root->dirty_list); | 725 | INIT_LIST_HEAD(&root->dirty_list); |
726 | spin_lock_init(&root->node_lock); | 726 | spin_lock_init(&root->node_lock); |
727 | mutex_init(&root->objectid_mutex); | ||
727 | memset(&root->root_key, 0, sizeof(root->root_key)); | 728 | memset(&root->root_key, 0, sizeof(root->root_key)); |
728 | memset(&root->root_item, 0, sizeof(root->root_item)); | 729 | memset(&root->root_item, 0, sizeof(root->root_item)); |
729 | memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); | 730 | memset(&root->defrag_progress, 0, sizeof(root->defrag_progress)); |
@@ -1146,6 +1147,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1146 | INIT_LIST_HEAD(&fs_info->space_info); | 1147 | INIT_LIST_HEAD(&fs_info->space_info); |
1147 | btrfs_mapping_init(&fs_info->mapping_tree); | 1148 | btrfs_mapping_init(&fs_info->mapping_tree); |
1148 | atomic_set(&fs_info->nr_async_submits, 0); | 1149 | atomic_set(&fs_info->nr_async_submits, 0); |
1150 | atomic_set(&fs_info->throttles, 0); | ||
1149 | fs_info->sb = sb; | 1151 | fs_info->sb = sb; |
1150 | fs_info->max_extent = (u64)-1; | 1152 | fs_info->max_extent = (u64)-1; |
1151 | fs_info->max_inline = 8192 * 1024; | 1153 | fs_info->max_inline = 8192 * 1024; |
@@ -1199,7 +1201,7 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1199 | mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS); | 1201 | mapping_set_gfp_mask(fs_info->btree_inode->i_mapping, GFP_NOFS); |
1200 | 1202 | ||
1201 | mutex_init(&fs_info->trans_mutex); | 1203 | mutex_init(&fs_info->trans_mutex); |
1202 | mutex_init(&fs_info->fs_mutex); | 1204 | mutex_init(&fs_info->drop_mutex); |
1203 | mutex_init(&fs_info->alloc_mutex); | 1205 | mutex_init(&fs_info->alloc_mutex); |
1204 | mutex_init(&fs_info->chunk_mutex); | 1206 | mutex_init(&fs_info->chunk_mutex); |
1205 | 1207 | ||
@@ -1278,8 +1280,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1278 | goto fail_sb_buffer; | 1280 | goto fail_sb_buffer; |
1279 | } | 1281 | } |
1280 | 1282 | ||
1281 | mutex_lock(&fs_info->fs_mutex); | ||
1282 | |||
1283 | mutex_lock(&fs_info->chunk_mutex); | 1283 | mutex_lock(&fs_info->chunk_mutex); |
1284 | ret = btrfs_read_sys_array(tree_root); | 1284 | ret = btrfs_read_sys_array(tree_root); |
1285 | mutex_unlock(&fs_info->chunk_mutex); | 1285 | mutex_unlock(&fs_info->chunk_mutex); |
@@ -1342,7 +1342,6 @@ struct btrfs_root *open_ctree(struct super_block *sb, | |||
1342 | fs_info->metadata_alloc_profile = (u64)-1; | 1342 | fs_info->metadata_alloc_profile = (u64)-1; |
1343 | fs_info->system_alloc_profile = fs_info->metadata_alloc_profile; | 1343 | fs_info->system_alloc_profile = fs_info->metadata_alloc_profile; |
1344 | 1344 | ||
1345 | mutex_unlock(&fs_info->fs_mutex); | ||
1346 | return tree_root; | 1345 | return tree_root; |
1347 | 1346 | ||
1348 | fail_extent_root: | 1347 | fail_extent_root: |
@@ -1350,7 +1349,6 @@ fail_extent_root: | |||
1350 | fail_tree_root: | 1349 | fail_tree_root: |
1351 | free_extent_buffer(tree_root->node); | 1350 | free_extent_buffer(tree_root->node); |
1352 | fail_sys_array: | 1351 | fail_sys_array: |
1353 | mutex_unlock(&fs_info->fs_mutex); | ||
1354 | fail_sb_buffer: | 1352 | fail_sb_buffer: |
1355 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); | 1353 | extent_io_tree_empty_lru(&BTRFS_I(fs_info->btree_inode)->io_tree); |
1356 | btrfs_stop_workers(&fs_info->workers); | 1354 | btrfs_stop_workers(&fs_info->workers); |
@@ -1562,8 +1560,9 @@ int close_ctree(struct btrfs_root *root) | |||
1562 | struct btrfs_fs_info *fs_info = root->fs_info; | 1560 | struct btrfs_fs_info *fs_info = root->fs_info; |
1563 | 1561 | ||
1564 | fs_info->closing = 1; | 1562 | fs_info->closing = 1; |
1563 | smp_mb(); | ||
1564 | |||
1565 | btrfs_transaction_flush_work(root); | 1565 | btrfs_transaction_flush_work(root); |
1566 | mutex_lock(&fs_info->fs_mutex); | ||
1567 | btrfs_defrag_dirty_roots(root->fs_info); | 1566 | btrfs_defrag_dirty_roots(root->fs_info); |
1568 | trans = btrfs_start_transaction(root, 1); | 1567 | trans = btrfs_start_transaction(root, 1); |
1569 | ret = btrfs_commit_transaction(trans, root); | 1568 | ret = btrfs_commit_transaction(trans, root); |
@@ -1574,7 +1573,6 @@ int close_ctree(struct btrfs_root *root) | |||
1574 | BUG_ON(ret); | 1573 | BUG_ON(ret); |
1575 | 1574 | ||
1576 | write_ctree_super(NULL, root); | 1575 | write_ctree_super(NULL, root); |
1577 | mutex_unlock(&fs_info->fs_mutex); | ||
1578 | 1576 | ||
1579 | btrfs_transaction_flush_work(root); | 1577 | btrfs_transaction_flush_work(root); |
1580 | 1578 | ||
@@ -1679,7 +1677,8 @@ void btrfs_throttle(struct btrfs_root *root) | |||
1679 | struct backing_dev_info *bdi; | 1677 | struct backing_dev_info *bdi; |
1680 | 1678 | ||
1681 | bdi = &root->fs_info->bdi; | 1679 | bdi = &root->fs_info->bdi; |
1682 | if (root->fs_info->throttles && bdi_write_congested(bdi)) { | 1680 | if (atomic_read(&root->fs_info->throttles) && |
1681 | bdi_write_congested(bdi)) { | ||
1683 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) | 1682 | #if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,18) |
1684 | congestion_wait(WRITE, HZ/20); | 1683 | congestion_wait(WRITE, HZ/20); |
1685 | #else | 1684 | #else |