diff options
author | Chris Mason <chris.mason@oracle.com> | 2008-01-31 16:45:07 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:04:00 -0400 |
commit | 4529ba495c6fd0d79247784d0df55ae6512fa883 (patch) | |
tree | 92e42dce09b7509894ee4e163f06006e19a46b3e /fs/btrfs/extent-tree.c | |
parent | b0c68f8bed058d9f2023b067b16ed06a8c439544 (diff) |
Btrfs: Add data block hints to SSD mode too
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 90718f77bbc0..fa54ea590078 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -1410,6 +1410,7 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, | |||
1410 | int ret; | 1410 | int ret; |
1411 | int slot = 0; | 1411 | int slot = 0; |
1412 | u64 last_byte = 0; | 1412 | u64 last_byte = 0; |
1413 | u64 *last_ptr = NULL; | ||
1413 | u64 orig_search_start = search_start; | 1414 | u64 orig_search_start = search_start; |
1414 | int start_found; | 1415 | int start_found; |
1415 | struct extent_buffer *l; | 1416 | struct extent_buffer *l; |
@@ -1433,14 +1434,17 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans, | |||
1433 | 1434 | ||
1434 | /* for SSD, cluster allocations together as much as possible */ | 1435 | /* for SSD, cluster allocations together as much as possible */ |
1435 | if (btrfs_test_opt(root, SSD)) { | 1436 | if (btrfs_test_opt(root, SSD)) { |
1436 | if (!data) { | 1437 | if (data) |
1437 | if (root->fs_info->last_alloc) | 1438 | last_ptr = &root->fs_info->last_data_alloc; |
1438 | hint_byte = root->fs_info->last_alloc; | 1439 | else |
1439 | else { | 1440 | last_ptr = &root->fs_info->last_alloc; |
1440 | hint_byte = hint_byte & | 1441 | if (*last_ptr) { |
1441 | ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1); | 1442 | hint_byte = *last_ptr; |
1442 | empty_size += 16 * 1024 * 1024; | 1443 | } |
1443 | } | 1444 | else { |
1445 | hint_byte = hint_byte & | ||
1446 | ~((u64)BTRFS_BLOCK_GROUP_SIZE - 1); | ||
1447 | empty_size += 16 * 1024 * 1024; | ||
1444 | } | 1448 | } |
1445 | } | 1449 | } |
1446 | 1450 | ||
@@ -1470,8 +1474,8 @@ check_failed: | |||
1470 | search_start = find_search_start(root, &block_group, search_start, | 1474 | search_start = find_search_start(root, &block_group, search_start, |
1471 | total_needed, data); | 1475 | total_needed, data); |
1472 | 1476 | ||
1473 | if (!data && btrfs_test_opt(root, SSD) && info->last_alloc && | 1477 | if (btrfs_test_opt(root, SSD) && *last_ptr && |
1474 | search_start != info->last_alloc) { | 1478 | search_start != *last_ptr) { |
1475 | info->last_alloc = 0; | 1479 | info->last_alloc = 0; |
1476 | if (!empty_size) { | 1480 | if (!empty_size) { |
1477 | empty_size += 16 * 1024 * 1024; | 1481 | empty_size += 16 * 1024 * 1024; |
@@ -1609,6 +1613,8 @@ check_pending: | |||
1609 | } | 1613 | } |
1610 | ins->offset = num_bytes; | 1614 | ins->offset = num_bytes; |
1611 | btrfs_free_path(path); | 1615 | btrfs_free_path(path); |
1616 | if (btrfs_test_opt(root, SSD)) | ||
1617 | *last_ptr = ins->objectid + ins->offset; | ||
1612 | return 0; | 1618 | return 0; |
1613 | 1619 | ||
1614 | new_group: | 1620 | new_group: |
@@ -1636,8 +1642,6 @@ enospc: | |||
1636 | error: | 1642 | error: |
1637 | btrfs_release_path(root, path); | 1643 | btrfs_release_path(root, path); |
1638 | btrfs_free_path(path); | 1644 | btrfs_free_path(path); |
1639 | if (btrfs_test_opt(root, SSD) && !ret && !data) | ||
1640 | info->last_alloc = ins->objectid + ins->offset; | ||
1641 | return ret; | 1645 | return ret; |
1642 | } | 1646 | } |
1643 | /* | 1647 | /* |