do_chunk_alloc implements a loop checking whether there is a pending
chunk allocation and if so causes the caller do loop. Generally this
loop is executed only once, however testing with btrfs/072 on a
single core vm machines uncovered an extreme case where the system
could loop indefinitely. This is due to a missing cond_resched when
loop which doesn't give a chance to the previous chunk allocator finish
its job.

The fix is to simply add the missing cond_resched.

Fixes: 6d74119f1a3e ("Btrfs: avoid taking the chunk_mutex in do_chunk_alloc")
Signed-off-by: Nikolay Borisov <>
 fs/btrfs/extent-tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 0cf1d4c518e9..070227b78d4e 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4645,6 +4645,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle 
        if (wait_for_alloc) {
                wait_for_alloc = 0;
+               cond_resched();
                goto again;

To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to
More majordomo info at

Reply via email to