aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5b9b6b6df242..b42efc2ded51 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3089,6 +3089,13 @@ alloc:
3089 } 3089 }
3090 goto again; 3090 goto again;
3091 } 3091 }
3092
3093 /*
3094 * If we have less pinned bytes than we want to allocate then
3095 * don't bother committing the transaction, it won't help us.
3096 */
3097 if (data_sinfo->bytes_pinned < bytes)
3098 committed = 1;
3092 spin_unlock(&data_sinfo->lock); 3099 spin_unlock(&data_sinfo->lock);
3093 3100
3094 /* commit the current transaction and try again */ 3101 /* commit the current transaction and try again */
@@ -5211,9 +5218,7 @@ loop:
5211 * LOOP_NO_EMPTY_SIZE, set empty_size and empty_cluster to 0 and try 5218 * LOOP_NO_EMPTY_SIZE, set empty_size and empty_cluster to 0 and try
5212 * again 5219 * again
5213 */ 5220 */
5214 if (!ins->objectid && loop < LOOP_NO_EMPTY_SIZE && 5221 if (!ins->objectid && loop < LOOP_NO_EMPTY_SIZE) {
5215 (found_uncached_bg || empty_size || empty_cluster ||
5216 allowed_chunk_alloc)) {
5217 index = 0; 5222 index = 0;
5218 if (loop == LOOP_FIND_IDEAL && found_uncached_bg) { 5223 if (loop == LOOP_FIND_IDEAL && found_uncached_bg) {
5219 found_uncached_bg = false; 5224 found_uncached_bg = false;
@@ -5253,32 +5258,36 @@ loop:
5253 goto search; 5258 goto search;
5254 } 5259 }
5255 5260
5256 if (loop < LOOP_CACHING_WAIT) { 5261 loop++;
5257 loop++;
5258 goto search;
5259 }
5260 5262
5261 if (loop == LOOP_ALLOC_CHUNK) { 5263 if (loop == LOOP_ALLOC_CHUNK) {
5262 empty_size = 0; 5264 if (allowed_chunk_alloc) {
5263 empty_cluster = 0; 5265 ret = do_chunk_alloc(trans, root, num_bytes +
5264 } 5266 2 * 1024 * 1024, data,
5267 CHUNK_ALLOC_LIMITED);
5268 allowed_chunk_alloc = 0;
5269 if (ret == 1)
5270 done_chunk_alloc = 1;
5271 } else if (!done_chunk_alloc &&
5272 space_info->force_alloc ==
5273 CHUNK_ALLOC_NO_FORCE) {
5274 space_info->force_alloc = CHUNK_ALLOC_LIMITED;
5275 }
5265 5276
5266 if (allowed_chunk_alloc) { 5277 /*
5267 ret = do_chunk_alloc(trans, root, num_bytes + 5278 * We didn't allocate a chunk, go ahead and drop the
5268 2 * 1024 * 1024, data, 5279 * empty size and loop again.
5269 CHUNK_ALLOC_LIMITED); 5280 */
5270 allowed_chunk_alloc = 0; 5281 if (!done_chunk_alloc)
5271 done_chunk_alloc = 1; 5282 loop = LOOP_NO_EMPTY_SIZE;
5272 } else if (!done_chunk_alloc &&
5273 space_info->force_alloc == CHUNK_ALLOC_NO_FORCE) {
5274 space_info->force_alloc = CHUNK_ALLOC_LIMITED;
5275 } 5283 }
5276 5284
5277 if (loop < LOOP_NO_EMPTY_SIZE) { 5285 if (loop == LOOP_NO_EMPTY_SIZE) {
5278 loop++; 5286 empty_size = 0;
5279 goto search; 5287 empty_cluster = 0;
5280 } 5288 }
5281 ret = -ENOSPC; 5289
5290 goto search;
5282 } else if (!ins->objectid) { 5291 } else if (!ins->objectid) {
5283 ret = -ENOSPC; 5292 ret = -ENOSPC;
5284 } else if (ins->objectid) { 5293 } else if (ins->objectid) {