Patch "Btrfs: fix racy system chunk allocation when setting block group ro" has been added to the 4.0-stable tree
Subsystems (2)
This is a note to let you know that I've just added the patch titled
Btrfs: fix racy system chunk allocation when setting block group ro
to the 4.0-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
btrfs-fix-racy-system-chunk-allocation-when-setting-block-group-ro.patch
and it can be found in the queue-4.0 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
a96295965b600f2dc6ad661c4803c86e87db3d7bMon Sep 17 00:00:00 2001
From: Filipe Manana <[email protected]>
Date: Mon, 18 May 2015 19:11:40 +0100
Subject: Btrfs: fix racy system chunk allocation when setting block group ro
From: Filipe Manana <[email protected]>
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.
setting block group ro")
--- fs/btrfs/extent-tree.c | 2 ++ fs/btrfs/volumes.c | 1 + 2 files changed, 3 insertions(+)
fs/btrfs/extent-tree.c +2 -0
@@ -8548,7 +8548,9 @@ int btrfs_set_block_group_ro(struct btrf out:if (cache->flags &BTRFS_BLOCK_GROUP_SYSTEM ) { alloc_flags =update_block_group_flags (root, cache->flags); +lock_chunks (root->fs_info->chunk_root);check_system_chunk (trans, root, alloc_flags); +unlock_chunks (root->fs_info->chunk_root); }btrfs_end_transaction (trans, root);
fs/btrfs/volumes.c +1 -0
@@ -4626,6 +4626,7 @@ int btrfs_alloc_chunk(struct btrfs_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); }
Patches currently in stable-queue which might be from [email protected] are
queue-4.0/btrfs-fix-racy-system-chunk-allocation-when-setting-block-group-ro.patch