aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
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
commit925baeddc5b0764a53f2214a1253251bab0e0324 (patch)
tree0e069bf9cc1c4ecd17c812fd1fb81bf807909ee6 /fs/btrfs/ctree.h
parent1cc127b5d1b71453091859301de4a7dd6ee96fa8 (diff)
Btrfs: Start btree concurrency work.
The allocation trees and the chunk trees are serialized via their own dedicated mutexes. This means allocation location is still not very fine grained. The main FS btree is protected by locks on each block in the btree. Locks are taken top / down, and as processing finishes on a given level of the tree, the lock is released after locking the lower level. The end result of a search is now a path where only the lowest level is locked. Releasing or freeing the path drops any locks held. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h23
1 files changed, 15 insertions, 8 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index dcea9d706d9b..50891b39f366 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -330,8 +330,13 @@ struct btrfs_node {
330struct btrfs_path { 330struct btrfs_path {
331 struct extent_buffer *nodes[BTRFS_MAX_LEVEL]; 331 struct extent_buffer *nodes[BTRFS_MAX_LEVEL];
332 int slots[BTRFS_MAX_LEVEL]; 332 int slots[BTRFS_MAX_LEVEL];
333 /* if there is real range locking, this locks field will change */
334 int locks[BTRFS_MAX_LEVEL];
333 int reada; 335 int reada;
336 /* keep some upper locks as we walk down */
337 int keep_locks;
334 int lowest_level; 338 int lowest_level;
339 int skip_locking;
335}; 340};
336 341
337/* 342/*
@@ -515,6 +520,8 @@ struct btrfs_fs_info {
515 spinlock_t hash_lock; 520 spinlock_t hash_lock;
516 struct mutex trans_mutex; 521 struct mutex trans_mutex;
517 struct mutex fs_mutex; 522 struct mutex fs_mutex;
523 struct mutex alloc_mutex;
524 struct mutex chunk_mutex;
518 struct list_head trans_list; 525 struct list_head trans_list;
519 struct list_head hashers; 526 struct list_head hashers;
520 struct list_head dead_roots; 527 struct list_head dead_roots;
@@ -576,6 +583,10 @@ struct btrfs_fs_info {
576 */ 583 */
577struct btrfs_root { 584struct btrfs_root {
578 struct extent_buffer *node; 585 struct extent_buffer *node;
586
587 /* the node lock is held while changing the node pointer */
588 spinlock_t node_lock;
589
579 struct extent_buffer *commit_root; 590 struct extent_buffer *commit_root;
580 struct btrfs_root_item root_item; 591 struct btrfs_root_item root_item;
581 struct btrfs_key root_key; 592 struct btrfs_key root_key;
@@ -1353,13 +1364,7 @@ struct btrfs_block_group_cache *btrfs_find_block_group(struct btrfs_root *root,
1353 struct btrfs_block_group_cache 1364 struct btrfs_block_group_cache
1354 *hint, u64 search_start, 1365 *hint, u64 search_start,
1355 int data, int owner); 1366 int data, int owner);
1356int btrfs_inc_root_ref(struct btrfs_trans_handle *trans,
1357 struct btrfs_root *root, u64 owner_objectid);
1358struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, 1367struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1359 struct btrfs_root *root, u32 size,
1360 u64 root_objectid,
1361 u64 hint, u64 empty_size);
1362struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1363 struct btrfs_root *root, 1368 struct btrfs_root *root,
1364 u32 blocksize, 1369 u32 blocksize,
1365 u64 root_objectid, 1370 u64 root_objectid,
@@ -1368,8 +1373,6 @@ struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1368 int level, 1373 int level,
1369 u64 hint, 1374 u64 hint,
1370 u64 empty_size); 1375 u64 empty_size);
1371int btrfs_grow_extent_tree(struct btrfs_trans_handle *trans,
1372 struct btrfs_root *root, u64 new_size);
1373int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size); 1376int btrfs_shrink_extent_tree(struct btrfs_root *root, u64 new_size);
1374int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans, 1377int btrfs_insert_extent_backref(struct btrfs_trans_handle *trans,
1375 struct btrfs_root *root, 1378 struct btrfs_root *root,
@@ -1409,6 +1412,10 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
1409int btrfs_previous_item(struct btrfs_root *root, 1412int btrfs_previous_item(struct btrfs_root *root,
1410 struct btrfs_path *path, u64 min_objectid, 1413 struct btrfs_path *path, u64 min_objectid,
1411 int type); 1414 int type);
1415
1416struct extent_buffer *btrfs_root_node(struct btrfs_root *root);
1417struct extent_buffer *btrfs_lock_root_node(struct btrfs_root *root);
1418
1412int btrfs_cow_block(struct btrfs_trans_handle *trans, 1419int btrfs_cow_block(struct btrfs_trans_handle *trans,
1413 struct btrfs_root *root, struct extent_buffer *buf, 1420 struct btrfs_root *root, struct extent_buffer *buf,
1414 struct extent_buffer *parent, int parent_slot, 1421 struct extent_buffer *parent, int parent_slot,