Skip to content

Commit

Permalink
Btrfs: Fix handling of space info full during allocations
Browse files Browse the repository at this point in the history
When we fail to allocate a new block group, we should still do the
checks to make sure allocations try again with the minimum requested
allocation size.

This also fixes a deadlock that come from a missed down_read in
the chunk allocation failure handling.

Signed-off-by: Chris Mason <chris.mason@oracle.com>
  • Loading branch information
Chris Mason committed Nov 13, 2008
1 parent 6f3577b commit 2ed6d66
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions fs/btrfs/extent-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -2301,9 +2301,9 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
up_read(&space_info->groups_sem);
ret = do_chunk_alloc(trans, root, num_bytes +
2 * 1024 * 1024, data, 1);
if (ret < 0)
break;
down_read(&space_info->groups_sem);
if (ret < 0)
goto loop_check;
head = &space_info->block_groups;
/*
* we've allocated a new chunk, keep
Expand All @@ -2314,6 +2314,7 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
} else if (!allowed_chunk_alloc) {
space_info->force_alloc = 1;
}
loop_check:
if (keep_going) {
cur = head->next;
extra_loop = 0;
Expand Down

0 comments on commit 2ed6d66

Please sign in to comment.