Btrfs: avoid taking the chunk_mutex in do_chunk_alloc

Everytime we try to allocate disk space we try and see if we can pre-emptively
allocate a chunk, but in the common case we don't allocate anything, so there is
no sense in taking the chunk_mutex at all.  So instead if we are allocating a
chunk, mark it in the space_info so we don't get two people trying to allocate
at the same time.  Thanks,

Signed-off-by: Josef Bacik <josef@redhat.com>
Reviewed-by: Liu Bo <liubo2009@cn.fujitsu.com>
This commit is contained in:
Josef Bacik
2011-04-11 20:20:11 -04:00
committed by Chris Mason
parent 0d399205ed
commit 6d74119f1a
2 changed files with 28 additions and 6 deletions

View File

@@ -740,8 +740,10 @@ struct btrfs_space_info {
*/
unsigned long reservation_progress;
int full; /* indicates that we cannot allocate any more
int full:1; /* indicates that we cannot allocate any more
chunks for this space */
int chunk_alloc:1; /* set if we are allocating a chunk */
int force_alloc; /* set if we need to force a chunk alloc for
this space */