]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix deadlock when using free space tree due to block group creation
authorFilipe Manana <fdmanana@suse.com>
Tue, 8 Jan 2019 11:44:41 +0000 (11:44 +0000)
committerDavid Sterba <dsterba@suse.com>
Wed, 9 Jan 2019 13:52:36 +0000 (14:52 +0100)
commit9a1c5d98ea569d0899a8e515a48a9215e0c2958e
treeb83db2ff93e52ee665492f8f32d6d97ac5a3c088
parent0797b3cf9e36d1e2318923dcfe53eca7bead13ef
Btrfs: fix deadlock when using free space tree due to block group creation

When modifying the free space tree we can end up COWing one of its extent
buffers which in turn might result in allocating a new chunk, which in
turn can result in flushing (finish creation) of pending block groups. If
that happens we can deadlock because creating a pending block group needs
to update the free space tree, and if any of the updates tries to modify
the same extent buffer that we are COWing, we end up in a deadlock since
we try to write lock twice the same extent buffer.

So fix this by skipping pending block group creation if we are COWing an
extent buffer from the free space tree. This is a case missed by commit
6e00e6924043d ("Btrfs: fix deadlock when writing out free space caches").

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=202173
Fixes: 6e00e6924043d ("Btrfs: fix deadlock when writing out free space caches")
CC: stable@vger.kernel.org # 4.18+
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/ctree.c