aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/extent-tree.c59
1 files changed, 7 insertions, 52 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8f441783a6ed..ebfd304138ca 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -209,27 +209,22 @@ again:
209 209
210 last = max(search_start, cache->key.objectid); 210 last = max(search_start, cache->key.objectid);
211 211
212 spin_lock_irq(&free_space_cache->lock);
213 state = find_first_extent_bit_state(free_space_cache, last, EXTENT_DIRTY);
214 while(1) { 212 while(1) {
215 if (!state) { 213 ret = find_first_extent_bit(&root->fs_info->free_space_cache,
214 last, &start, &end, EXTENT_DIRTY);
215 if (ret) {
216 if (!cache_miss) 216 if (!cache_miss)
217 cache_miss = last; 217 cache_miss = last;
218 spin_unlock_irq(&free_space_cache->lock);
219 goto new_group; 218 goto new_group;
220 } 219 }
221 220
222 start = max(last, state->start); 221 start = max(last, start);
223 last = state->end + 1; 222 last = end + 1;
224 if (last - start < num) { 223 if (last - start < num) {
225 if (last == cache->key.objectid + cache->key.offset) 224 if (last == cache->key.objectid + cache->key.offset)
226 cache_miss = start; 225 cache_miss = start;
227 do {
228 state = extent_state_next(state);
229 } while(state && !(state->state & EXTENT_DIRTY));
230 continue; 226 continue;
231 } 227 }
232 spin_unlock_irq(&free_space_cache->lock);
233 if (data != BTRFS_BLOCK_GROUP_MIXED && 228 if (data != BTRFS_BLOCK_GROUP_MIXED &&
234 start + num > cache->key.objectid + cache->key.offset) 229 start + num > cache->key.objectid + cache->key.offset)
235 goto new_group; 230 goto new_group;
@@ -1485,29 +1480,8 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
1485 data = BTRFS_BLOCK_GROUP_MIXED; 1480 data = BTRFS_BLOCK_GROUP_MIXED;
1486 } 1481 }
1487 1482
1488 if (!data) { 1483 if (search_end == (u64)-1)
1489 last_ptr = &root->fs_info->last_alloc; 1484 search_end = btrfs_super_total_bytes(&info->super_copy);
1490 empty_cluster = 128 * 1024;
1491 }
1492
1493 if (data && btrfs_test_opt(root, SSD)) {
1494 last_ptr = &root->fs_info->last_data_alloc;
1495 empty_cluster = 2 * 1024 * 1024;
1496 }
1497
1498 if (last_ptr) {
1499 if (*last_ptr)
1500 hint_byte = *last_ptr;
1501 else {
1502 hint_byte = hint_byte &
1503 ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1);
1504 empty_size += empty_cluster;
1505 }
1506 search_start = max(search_start, hint_byte);
1507 }
1508
1509 search_end = min(search_end,
1510 btrfs_super_total_bytes(&info->super_copy));
1511 if (hint_byte) { 1485 if (hint_byte) {
1512 block_group = btrfs_lookup_block_group(info, hint_byte); 1486 block_group = btrfs_lookup_block_group(info, hint_byte);
1513 if (!block_group) 1487 if (!block_group)
@@ -1531,18 +1505,6 @@ check_failed:
1531 } 1505 }
1532 search_start = find_search_start(root, &block_group, search_start, 1506 search_start = find_search_start(root, &block_group, search_start,
1533 total_needed, data); 1507 total_needed, data);
1534
1535 if (last_ptr && *last_ptr && search_start != *last_ptr) {
1536 *last_ptr = 0;
1537 if (!empty_size) {
1538 empty_size += empty_cluster;
1539 total_needed += empty_size;
1540 }
1541 search_start = find_search_start(root, &block_group,
1542 search_start, total_needed,
1543 data);
1544 }
1545
1546 search_start = stripe_align(root, search_start); 1508 search_start = stripe_align(root, search_start);
1547 cached_start = search_start; 1509 cached_start = search_start;
1548 btrfs_init_path(path); 1510 btrfs_init_path(path);
@@ -1670,13 +1632,6 @@ check_pending:
1670 } 1632 }
1671 ins->offset = num_bytes; 1633 ins->offset = num_bytes;
1672 btrfs_free_path(path); 1634 btrfs_free_path(path);
1673 if (last_ptr) {
1674 *last_ptr = ins->objectid + ins->offset;
1675 if (*last_ptr ==
1676 btrfs_super_total_bytes(&root->fs_info->super_copy)) {
1677 *last_ptr = 0;
1678 }
1679 }
1680 return 0; 1635 return 0;
1681 1636
1682new_group: 1637new_group: