Btrfs: fix deadlock during allocating chunks
authorLiu Bo <liubo2009@cn.fujitsu.com>
Thu, 29 Mar 2012 13:57:44 +0000 (09:57 -0400)
committerChris Mason <chris.mason@oracle.com>
Thu, 29 Mar 2012 13:57:44 +0000 (09:57 -0400)
commit15d1ff8111aad85d8b40ee396758990d17a2caac
tree5258905b649150abae0a8aa010bbaa7ef1077e97
parent2bcc0328c3a043880796a602c75fbeb1537aa1e1
Btrfs: fix deadlock during allocating chunks

This deadlock comes from xfstests 251.

We'll hold the chunk_mutex throughout the whole of a chunk allocation.
But if we find that we've used up system chunk space, we need to allocate a
new system chunk, but this will lead to a recursion of chunk allocation and end
up with a deadlock on chunk_mutex.
So instead we need to allocate the system chunk first if we find we're in ENOSPC.

Signed-off-by: Liu Bo <liubo2009@cn.fujitsu.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/extent-tree.c