aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorJosef Bacik <jbacik@redhat.com>2009-04-03 10:14:18 -0400
committerChris Mason <chris.mason@oracle.com>2009-04-03 10:14:18 -0400
commit6226cb0a5ea3f6289883753c15d53f48a6c6bbfb (patch)
tree819765cd5a5816017580f638c4b2a3e7f6354aea /fs/btrfs/ctree.h
parent2552d17e328044d1811cae733087a1fb9aac2eb6 (diff)
Btrfs: kill the block group alloc mutex
This patch removes the block group alloc mutex used to protect the free space tree for allocations and replaces it with a spin lock which is used only to protect the free space rb tree. This means we only take the lock when we are directly manipulating the tree, which makes us a touch faster with multi-threaded workloads. This patch also gets rid of btrfs_find_free_space and replaces it with btrfs_find_space_for_alloc, which takes the number of bytes you want to allocate, and empty_size, which is used to indicate how much free space should be at the end of the allocation. It will return an offset for the allocator to use. If we don't end up using it we _must_ call btrfs_add_free_space to put it back. This is the tradeoff to kill the alloc_mutex, since we need to make sure nobody else comes along and takes our space. Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h11
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index f48905ee5240..527744561f93 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -644,7 +644,6 @@ struct btrfs_block_group_cache {
644 struct btrfs_key key; 644 struct btrfs_key key;
645 struct btrfs_block_group_item item; 645 struct btrfs_block_group_item item;
646 spinlock_t lock; 646 spinlock_t lock;
647 struct mutex alloc_mutex;
648 struct mutex cache_mutex; 647 struct mutex cache_mutex;
649 u64 pinned; 648 u64 pinned;
650 u64 reserved; 649 u64 reserved;
@@ -656,6 +655,7 @@ struct btrfs_block_group_cache {
656 struct btrfs_space_info *space_info; 655 struct btrfs_space_info *space_info;
657 656
658 /* free space cache stuff */ 657 /* free space cache stuff */
658 spinlock_t tree_lock;
659 struct rb_root free_space_bytes; 659 struct rb_root free_space_bytes;
660 struct rb_root free_space_offset; 660 struct rb_root free_space_offset;
661 661
@@ -2177,17 +2177,12 @@ int btrfs_acl_chmod(struct inode *inode);
2177/* free-space-cache.c */ 2177/* free-space-cache.c */
2178int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, 2178int btrfs_add_free_space(struct btrfs_block_group_cache *block_group,
2179 u64 bytenr, u64 size); 2179 u64 bytenr, u64 size);
2180int btrfs_add_free_space_lock(struct btrfs_block_group_cache *block_group,
2181 u64 offset, u64 bytes);
2182int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, 2180int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group,
2183 u64 bytenr, u64 size); 2181 u64 bytenr, u64 size);
2184int btrfs_remove_free_space_lock(struct btrfs_block_group_cache *block_group,
2185 u64 offset, u64 bytes);
2186void btrfs_remove_free_space_cache(struct btrfs_block_group_cache 2182void btrfs_remove_free_space_cache(struct btrfs_block_group_cache
2187 *block_group); 2183 *block_group);
2188struct btrfs_free_space *btrfs_find_free_space(struct btrfs_block_group_cache 2184u64 btrfs_find_space_for_alloc(struct btrfs_block_group_cache *block_group,
2189 *block_group, u64 offset, 2185 u64 offset, u64 bytes, u64 empty_size);
2190 u64 bytes);
2191void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group, 2186void btrfs_dump_free_space(struct btrfs_block_group_cache *block_group,
2192 u64 bytes); 2187 u64 bytes);
2193u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group); 2188u64 btrfs_block_group_free_space(struct btrfs_block_group_cache *block_group);