diff options
author | Filipe Manana <fdmanana@suse.com> | 2015-05-18 19:11:40 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-06-06 08:20:52 -0700 |
commit | 68482f12d90fb757eef19493fb7bf7fdc1029a7a (patch) | |
tree | c0fbf05f5e9f2b0f17650ffb163c69079ec434f8 /fs/btrfs/volumes.c | |
parent | f0034a3a16b3c04b88a87ca2a49839f74f668215 (diff) | |
download | lwn-68482f12d90fb757eef19493fb7bf7fdc1029a7a.tar.gz lwn-68482f12d90fb757eef19493fb7bf7fdc1029a7a.zip |
Btrfs: fix racy system chunk allocation when setting block group ro
commit a96295965b600f2dc6ad661c4803c86e87db3d7b upstream.
If while setting a block group read-only we end up allocating a system
chunk, through check_system_chunk(), we were not doing it while holding
the chunk mutex which is a problem if a concurrent chunk allocation is
happening, through do_chunk_alloc(), as it means both block groups can
end up using the same logical addresses and physical regions in the
device(s). So make sure we hold the chunk mutex.
Fixes: 2f0810880f08 ("btrfs: delete chunk allocation attemp when
setting block group ro")
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r-- | fs/btrfs/volumes.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 8222f6f74147..44a7e0398d97 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@ -4626,6 +4626,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, { u64 chunk_offset; + ASSERT(mutex_is_locked(&extent_root->fs_info->chunk_mutex)); chunk_offset = find_next_chunk(extent_root->fs_info); return __btrfs_alloc_chunk(trans, extent_root, chunk_offset, type); } |