aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-02-01 14:51:59 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:00 -0400
commit60cde612c8eb51ba79dabb4088f149c6a9802fdf (patch)
tree0f77d3f1fcb304d77fce5a66314e36078aac8508 /fs/btrfs/extent-tree.c
parent21a4989d26d5ce43aac452fd67be592463a5996d (diff)
Btrfs: Use last_alloc optimizations for metadata, even without -o ssd
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 8761aec59e37..6f161abe2867 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1431,19 +1431,19 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
1431 data = BTRFS_BLOCK_GROUP_MIXED; 1431 data = BTRFS_BLOCK_GROUP_MIXED;
1432 } 1432 }
1433 1433
1434 /* for SSD, cluster allocations together as much as possible */ 1434 if (!data)
1435 if (btrfs_test_opt(root, SSD)) { 1435 last_ptr = &root->fs_info->last_alloc;
1436 if (data) 1436
1437 last_ptr = &root->fs_info->last_data_alloc; 1437 if (data && btrfs_test_opt(root, SSD))
1438 else 1438 last_ptr = &root->fs_info->last_data_alloc;
1439 last_ptr = &root->fs_info->last_alloc; 1439
1440 if (*last_ptr) { 1440 if (last_ptr) {
1441 if (*last_ptr)
1441 hint_byte = *last_ptr; 1442 hint_byte = *last_ptr;
1442 }
1443 else { 1443 else {
1444 hint_byte = hint_byte & 1444 hint_byte = hint_byte &
1445 ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1); 1445 ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1);
1446 empty_size += 16 * 1024 * 1024; 1446 empty_size += 2 * 1024 * 1024;
1447 } 1447 }
1448 } 1448 }
1449 1449
@@ -1473,9 +1473,8 @@ check_failed:
1473 search_start = find_search_start(root, &block_group, search_start, 1473 search_start = find_search_start(root, &block_group, search_start,
1474 total_needed, data); 1474 total_needed, data);
1475 1475
1476 if (btrfs_test_opt(root, SSD) && *last_ptr && 1476 if (last_ptr && *last_ptr && search_start != *last_ptr) {
1477 search_start != *last_ptr) { 1477 *last_ptr = 0;
1478 info->last_alloc = 0;
1479 if (!empty_size) { 1478 if (!empty_size) {
1480 empty_size += 16 * 1024 * 1024; 1479 empty_size += 16 * 1024 * 1024;
1481 total_needed += empty_size; 1480 total_needed += empty_size;
@@ -1612,7 +1611,7 @@ check_pending:
1612 } 1611 }
1613 ins->offset = num_bytes; 1612 ins->offset = num_bytes;
1614 btrfs_free_path(path); 1613 btrfs_free_path(path);
1615 if (btrfs_test_opt(root, SSD)) 1614 if (last_ptr)
1616 *last_ptr = ins->objectid + ins->offset; 1615 *last_ptr = ins->objectid + ins->offset;
1617 return 0; 1616 return 0;
1618 1617
@@ -1827,8 +1826,7 @@ struct extent_buffer *__btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
1827 buf->start, buf->start + buf->len - 1, 1826 buf->start, buf->start + buf->len - 1,
1828 EXTENT_CSUM, GFP_NOFS); 1827 EXTENT_CSUM, GFP_NOFS);
1829 buf->flags |= EXTENT_CSUM; 1828 buf->flags |= EXTENT_CSUM;
1830 if (!btrfs_test_opt(root, SSD)) 1829 btrfs_set_buffer_defrag(buf);
1831 btrfs_set_buffer_defrag(buf);
1832 trans->blocks_used++; 1830 trans->blocks_used++;
1833 return buf; 1831 return buf;
1834} 1832}