diff options
author | Filipe Manana <fdmanana@suse.com> | 2014-12-04 10:31:01 -0500 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2014-12-10 15:22:28 -0500 |
commit | a1e7e16ed36b9b059c5ee94e372287418e2dc7bc (patch) | |
tree | f18b60f14d1601891aed8e978b66adb617b90d06 /fs/btrfs/free-space-cache.c | |
parent | 9627aeee3e203e30679549e4962633698a6bf87f (diff) |
Btrfs: ensure deletion from pinned_chunks list is protected
The call to remove_extent_mapping() actually deletes the extent map
from the list it's included in - fs_info->pinned_chunks - and that
list is protected by the chunk mutex. Therefore make that call
while holding the chunk mutex and remove the redundant list delete
call because it's a noop.
This fixes an overlook of the patch titled
"Btrfs: fix race between fs trimming and block group remove/allocation"
following the same obvervation from the patch titled
"Btrfs: fix unprotected deletion from pending_chunks list".
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs/btrfs/free-space-cache.c')
-rw-r--r-- | fs/btrfs/free-space-cache.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c index 030847bf7cec..edf32c5bbef1 100644 --- a/fs/btrfs/free-space-cache.c +++ b/fs/btrfs/free-space-cache.c | |||
@@ -3185,16 +3185,18 @@ out: | |||
3185 | 3185 | ||
3186 | spin_unlock(&block_group->lock); | 3186 | spin_unlock(&block_group->lock); |
3187 | 3187 | ||
3188 | lock_chunks(block_group->fs_info->chunk_root); | ||
3188 | em_tree = &block_group->fs_info->mapping_tree.map_tree; | 3189 | em_tree = &block_group->fs_info->mapping_tree.map_tree; |
3189 | write_lock(&em_tree->lock); | 3190 | write_lock(&em_tree->lock); |
3190 | em = lookup_extent_mapping(em_tree, block_group->key.objectid, | 3191 | em = lookup_extent_mapping(em_tree, block_group->key.objectid, |
3191 | 1); | 3192 | 1); |
3192 | BUG_ON(!em); /* logic error, can't happen */ | 3193 | BUG_ON(!em); /* logic error, can't happen */ |
3194 | /* | ||
3195 | * remove_extent_mapping() will delete us from the pinned_chunks | ||
3196 | * list, which is protected by the chunk mutex. | ||
3197 | */ | ||
3193 | remove_extent_mapping(em_tree, em); | 3198 | remove_extent_mapping(em_tree, em); |
3194 | write_unlock(&em_tree->lock); | 3199 | write_unlock(&em_tree->lock); |
3195 | |||
3196 | lock_chunks(block_group->fs_info->chunk_root); | ||
3197 | list_del_init(&em->list); | ||
3198 | unlock_chunks(block_group->fs_info->chunk_root); | 3200 | unlock_chunks(block_group->fs_info->chunk_root); |
3199 | 3201 | ||
3200 | /* once for us and once for the tree */ | 3202 | /* once for us and once for the tree */ |