From 048b101b94e8554f525c204ef9f4c34ecb507639 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 1 Oct 2008 19:11:18 -0400 Subject: [PATCH] --- yaml --- r: 128967 b: refs/heads/master c: cf749823857230017c86504bfdc70524f929ba96 h: refs/heads/master i: 128965: 0b5c8f8a4efa94d3fe11ba7f774e021bf64adf70 128963: 423c544db35639e526dd7495b49cf35ee52a5dd5 128959: 877dc9886e4b39cfa1e86c54ab2480cac1572859 v: v3 --- [refs] | 2 +- trunk/fs/btrfs/extent-tree.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/[refs] b/[refs] index a281fadb4e40..ff6f7929c3c3 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 83afeac42c5680b0b70d64fb8c4724cf05483fc2 +refs/heads/master: cf749823857230017c86504bfdc70524f929ba96 diff --git a/trunk/fs/btrfs/extent-tree.c b/trunk/fs/btrfs/extent-tree.c index 677d5e774fad..db37b867e4f1 100644 --- a/trunk/fs/btrfs/extent-tree.c +++ b/trunk/fs/btrfs/extent-tree.c @@ -1505,7 +1505,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, u64 thresh; u64 start; u64 num_bytes; - int ret = 0; + int ret = 0, waited = 0; flags = reduce_alloc_profile(extent_root, flags); @@ -1530,7 +1530,18 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, space_info->bytes_reserved + alloc_bytes) < thresh) goto out; - mutex_lock(&extent_root->fs_info->chunk_mutex); + while (!mutex_trylock(&extent_root->fs_info->chunk_mutex)) { + if (!force) + goto out; + mutex_unlock(&extent_root->fs_info->alloc_mutex); + cond_resched(); + mutex_lock(&extent_root->fs_info->alloc_mutex); + waited = 1; + } + + if (waited && space_info->full) + goto out_unlock; + ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes, flags); if (ret == -ENOSPC) { printk("space info full %Lu\n", flags);