diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-10-29 14:49:05 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-10-29 14:49:05 -0400 |
commit | 2517920135b0d29e70453e5b03d70d7b94207df3 (patch) | |
tree | e0c526faa5c2c7bc3add340e5b7e8df26924dca9 /fs/btrfs/ctree.h | |
parent | 80eb234af09dbe6c97b2e3d60a13ec391e98fbba (diff) |
Btrfs: nuke fs wide allocation mutex V2
This patch removes the giant fs_info->alloc_mutex and replaces it with a bunch
of little locks.
There is now a pinned_mutex, which is used when messing with the pinned_extents
extent io tree, and the extent_ins_mutex which is used with the pending_del and
extent_ins extent io trees.
The locking for the extent tree stuff was inspired by a patch that Yan Zheng
wrote to fix a race condition, I cleaned it up some and changed the locking
around a little bit, but the idea remains the same. Basically instead of
holding the extent_ins_mutex throughout the processing of an extent on the
extent_ins or pending_del trees, we just hold it while we're searching and when
we clear the bits on those trees, and lock the extent for the duration of the
operations on the extent.
Also to keep from getting hung up waiting to lock an extent, I've added a
try_lock_extent so if we cannot lock the extent, move on to the next one in the
tree and we'll come back to that one. I have tested this heavily and it does
not appear to break anything. This has to be applied on top of my
find_free_extent redo patch.
I tested this patch on top of Yan's space reblancing code and it worked fine.
The only thing that has changed since the last version is I pulled out all my
debugging stuff, apparently I forgot to run guilt refresh before I sent the
last patch out. Thank you,
Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index caa860a1c3e5..fdba4f1b634e 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -558,6 +558,7 @@ struct btrfs_block_group_cache { | |||
558 | struct btrfs_key key; | 558 | struct btrfs_key key; |
559 | struct btrfs_block_group_item item; | 559 | struct btrfs_block_group_item item; |
560 | spinlock_t lock; | 560 | spinlock_t lock; |
561 | struct mutex alloc_mutex; | ||
561 | u64 pinned; | 562 | u64 pinned; |
562 | u64 reserved; | 563 | u64 reserved; |
563 | u64 flags; | 564 | u64 flags; |
@@ -635,7 +636,8 @@ struct btrfs_fs_info { | |||
635 | struct mutex tree_log_mutex; | 636 | struct mutex tree_log_mutex; |
636 | struct mutex transaction_kthread_mutex; | 637 | struct mutex transaction_kthread_mutex; |
637 | struct mutex cleaner_mutex; | 638 | struct mutex cleaner_mutex; |
638 | struct mutex alloc_mutex; | 639 | struct mutex extent_ins_mutex; |
640 | struct mutex pinned_mutex; | ||
639 | struct mutex chunk_mutex; | 641 | struct mutex chunk_mutex; |
640 | struct mutex drop_mutex; | 642 | struct mutex drop_mutex; |
641 | struct mutex volume_mutex; | 643 | struct mutex volume_mutex; |
@@ -1941,8 +1943,12 @@ int btrfs_acl_chmod(struct inode *inode); | |||
1941 | /* free-space-cache.c */ | 1943 | /* free-space-cache.c */ |
1942 | int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, | 1944 | int btrfs_add_free_space(struct btrfs_block_group_cache *block_group, |
1943 | u64 bytenr, u64 size); | 1945 | u64 bytenr, u64 size); |
1946 | int btrfs_add_free_space_lock(struct btrfs_block_group_cache *block_group, | ||
1947 | u64 offset, u64 bytes); | ||
1944 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, | 1948 | int btrfs_remove_free_space(struct btrfs_block_group_cache *block_group, |
1945 | u64 bytenr, u64 size); | 1949 | u64 bytenr, u64 size); |
1950 | int btrfs_remove_free_space_lock(struct btrfs_block_group_cache *block_group, | ||
1951 | u64 offset, u64 bytes); | ||
1946 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache | 1952 | void btrfs_remove_free_space_cache(struct btrfs_block_group_cache |
1947 | *block_group); | 1953 | *block_group); |
1948 | struct btrfs_free_space *btrfs_find_free_space(struct btrfs_block_group_cache | 1954 | struct btrfs_free_space *btrfs_find_free_space(struct btrfs_block_group_cache |