diff options
author | Josef Bacik <jbacik@redhat.com> | 2008-11-20 12:16:16 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-11-20 12:16:16 -0500 |
commit | ea6a478ed9758cb0f5af228104b9434840aa20ff (patch) | |
tree | 1dd41601f8bb031a1e222b073458067af5d4b70d /fs/btrfs/extent-tree.c | |
parent | 0e6bd956ed238eb2f69386f251847fe3163532e1 (diff) |
Btrfs: Fix for lockdep warnings with alloc_mutex and pinned_mutex
This the lockdep complaint by having a different mutex to gaurd caching the
block group, so you don't end up with this backwards dependancy. Thank you,
Signed-off-by: Josef Bacik <jbacik@redhat.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index b33e0bfb99e1..a970472eab17 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -170,8 +170,8 @@ static int add_new_free_space(struct btrfs_block_group_cache *block_group, | |||
170 | start = extent_end + 1; | 170 | start = extent_end + 1; |
171 | } else if (extent_start > start && extent_start < end) { | 171 | } else if (extent_start > start && extent_start < end) { |
172 | size = extent_start - start; | 172 | size = extent_start - start; |
173 | ret = btrfs_add_free_space_lock(block_group, start, | 173 | ret = btrfs_add_free_space(block_group, start, |
174 | size); | 174 | size); |
175 | BUG_ON(ret); | 175 | BUG_ON(ret); |
176 | start = extent_end + 1; | 176 | start = extent_end + 1; |
177 | } else { | 177 | } else { |
@@ -181,7 +181,7 @@ static int add_new_free_space(struct btrfs_block_group_cache *block_group, | |||
181 | 181 | ||
182 | if (start < end) { | 182 | if (start < end) { |
183 | size = end - start; | 183 | size = end - start; |
184 | ret = btrfs_add_free_space_lock(block_group, start, size); | 184 | ret = btrfs_add_free_space(block_group, start, size); |
185 | BUG_ON(ret); | 185 | BUG_ON(ret); |
186 | } | 186 | } |
187 | mutex_unlock(&info->pinned_mutex); | 187 | mutex_unlock(&info->pinned_mutex); |
@@ -2842,17 +2842,19 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, | |||
2842 | if (!block_group) | 2842 | if (!block_group) |
2843 | goto new_group_no_lock; | 2843 | goto new_group_no_lock; |
2844 | 2844 | ||
2845 | if (unlikely(!block_group->cached)) { | ||
2846 | mutex_lock(&block_group->cache_mutex); | ||
2847 | ret = cache_block_group(root, block_group); | ||
2848 | mutex_unlock(&block_group->cache_mutex); | ||
2849 | if (ret) | ||
2850 | break; | ||
2851 | } | ||
2852 | |||
2845 | mutex_lock(&block_group->alloc_mutex); | 2853 | mutex_lock(&block_group->alloc_mutex); |
2846 | if (unlikely(!block_group_bits(block_group, data))) | 2854 | if (unlikely(!block_group_bits(block_group, data))) |
2847 | goto new_group; | 2855 | goto new_group; |
2848 | 2856 | ||
2849 | ret = cache_block_group(root, block_group); | 2857 | if (unlikely(block_group->ro)) |
2850 | if (ret) { | ||
2851 | mutex_unlock(&block_group->alloc_mutex); | ||
2852 | break; | ||
2853 | } | ||
2854 | |||
2855 | if (block_group->ro) | ||
2856 | goto new_group; | 2858 | goto new_group; |
2857 | 2859 | ||
2858 | free_space = btrfs_find_free_space(block_group, search_start, | 2860 | free_space = btrfs_find_free_space(block_group, search_start, |
@@ -3273,12 +3275,12 @@ int btrfs_alloc_logged_extent(struct btrfs_trans_handle *trans, | |||
3273 | struct btrfs_block_group_cache *block_group; | 3275 | struct btrfs_block_group_cache *block_group; |
3274 | 3276 | ||
3275 | block_group = btrfs_lookup_block_group(root->fs_info, ins->objectid); | 3277 | block_group = btrfs_lookup_block_group(root->fs_info, ins->objectid); |
3276 | mutex_lock(&block_group->alloc_mutex); | 3278 | mutex_lock(&block_group->cache_mutex); |
3277 | cache_block_group(root, block_group); | 3279 | cache_block_group(root, block_group); |
3280 | mutex_unlock(&block_group->cache_mutex); | ||
3278 | 3281 | ||
3279 | ret = btrfs_remove_free_space_lock(block_group, ins->objectid, | 3282 | ret = btrfs_remove_free_space(block_group, ins->objectid, |
3280 | ins->offset); | 3283 | ins->offset); |
3281 | mutex_unlock(&block_group->alloc_mutex); | ||
3282 | BUG_ON(ret); | 3284 | BUG_ON(ret); |
3283 | ret = __btrfs_alloc_reserved_extent(trans, root, parent, root_objectid, | 3285 | ret = __btrfs_alloc_reserved_extent(trans, root, parent, root_objectid, |
3284 | ref_generation, owner, ins); | 3286 | ref_generation, owner, ins); |
@@ -5801,6 +5803,7 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
5801 | 5803 | ||
5802 | spin_lock_init(&cache->lock); | 5804 | spin_lock_init(&cache->lock); |
5803 | mutex_init(&cache->alloc_mutex); | 5805 | mutex_init(&cache->alloc_mutex); |
5806 | mutex_init(&cache->cache_mutex); | ||
5804 | INIT_LIST_HEAD(&cache->list); | 5807 | INIT_LIST_HEAD(&cache->list); |
5805 | read_extent_buffer(leaf, &cache->item, | 5808 | read_extent_buffer(leaf, &cache->item, |
5806 | btrfs_item_ptr_offset(leaf, path->slots[0]), | 5809 | btrfs_item_ptr_offset(leaf, path->slots[0]), |
@@ -5854,6 +5857,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, | |||
5854 | cache->key.offset = size; | 5857 | cache->key.offset = size; |
5855 | spin_lock_init(&cache->lock); | 5858 | spin_lock_init(&cache->lock); |
5856 | mutex_init(&cache->alloc_mutex); | 5859 | mutex_init(&cache->alloc_mutex); |
5860 | mutex_init(&cache->cache_mutex); | ||
5857 | INIT_LIST_HEAD(&cache->list); | 5861 | INIT_LIST_HEAD(&cache->list); |
5858 | btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY); | 5862 | btrfs_set_key_type(&cache->key, BTRFS_BLOCK_GROUP_ITEM_KEY); |
5859 | 5863 | ||