aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent-tree.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 677d5e774fad..db37b867e4f1 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1505,7 +1505,7 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
1505 u64 thresh; 1505 u64 thresh;
1506 u64 start; 1506 u64 start;
1507 u64 num_bytes; 1507 u64 num_bytes;
1508 int ret = 0; 1508 int ret = 0, waited = 0;
1509 1509
1510 flags = reduce_alloc_profile(extent_root, flags); 1510 flags = reduce_alloc_profile(extent_root, flags);
1511 1511
@@ -1530,7 +1530,18 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
1530 space_info->bytes_reserved + alloc_bytes) < thresh) 1530 space_info->bytes_reserved + alloc_bytes) < thresh)
1531 goto out; 1531 goto out;
1532 1532
1533 mutex_lock(&extent_root->fs_info->chunk_mutex); 1533 while (!mutex_trylock(&extent_root->fs_info->chunk_mutex)) {
1534 if (!force)
1535 goto out;
1536 mutex_unlock(&extent_root->fs_info->alloc_mutex);
1537 cond_resched();
1538 mutex_lock(&extent_root->fs_info->alloc_mutex);
1539 waited = 1;
1540 }
1541
1542 if (waited && space_info->full)
1543 goto out_unlock;
1544
1534 ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes, flags); 1545 ret = btrfs_alloc_chunk(trans, extent_root, &start, &num_bytes, flags);
1535 if (ret == -ENOSPC) { 1546 if (ret == -ENOSPC) {
1536printk("space info full %Lu\n", flags); 1547printk("space info full %Lu\n", flags);