]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix racy system chunk allocation when setting block group ro
authorFilipe Manana <fdmanana@suse.com>
Mon, 18 May 2015 18:11:40 +0000 (19:11 +0100)
committerChris Mason <clm@fb.com>
Wed, 20 May 2015 01:04:17 +0000 (18:04 -0700)
commit36bbd27dc25ed6d0a9ee6e4b2222d63e8bbb695e
tree77d962c73ba063add20fcc8b47950be4c1ee75a2
parenteb39c0463e4d312a45504b35edab3f8f5a8344d1
Btrfs: fix racy system chunk allocation when setting block group ro

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.

Cc: stable@vger.kernel.org # 4.0+
Fixes: 88f17451501d ("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>
fs/btrfs/extent-tree.c
fs/btrfs/volumes.c