aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-01-31 16:45:07 -0500
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:00 -0400
commit4529ba495c6fd0d79247784d0df55ae6512fa883 (patch)
tree92e42dce09b7509894ee4e163f06006e19a46b3e /fs/btrfs
parentb0c68f8bed058d9f2023b067b16ed06a8c439544 (diff)
Btrfs: Add data block hints to SSD mode too
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs')
-rw-r--r--fs/btrfs/ctree.h1
-rw-r--r--fs/btrfs/disk-io.c1
-rw-r--r--fs/btrfs/extent-tree.c28
-rw-r--r--fs/btrfs/transaction.c1
4 files changed, 19 insertions, 12 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 8f93e066bf8b..35e9a7af10a5 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -354,6 +354,7 @@ struct btrfs_fs_info {
354 spinlock_t new_trans_lock; 354 spinlock_t new_trans_lock;
355 u64 delalloc_bytes; 355 u64 delalloc_bytes;
356 u64 last_alloc; 356 u64 last_alloc;
357 u64 last_data_alloc;
357}; 358};
358/* 359/*
359 * in ram representation of the tree. extent_root is used for all allocations 360 * in ram representation of the tree. extent_root is used for all allocations
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index ad72e2192015..dda8ad6c0077 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -688,6 +688,7 @@ struct btrfs_root *open_ctree(struct super_block *sb)
688 fs_info->closing = 0; 688 fs_info->closing = 0;
689 fs_info->total_pinned = 0; 689 fs_info->total_pinned = 0;
690 fs_info->last_alloc = 0; 690 fs_info->last_alloc = 0;
691 fs_info->last_data_alloc = 0;
691 692
692#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) 693#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
693 INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info); 694 INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info);
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
1614new_group: 1620new_group:
@@ -1636,8 +1642,6 @@ enospc:
1636error: 1642error:
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/*
diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index b4a1bc62a784..3f64d0c7ddb9 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -58,6 +58,7 @@ static int join_transaction(struct btrfs_root *root)
58 root->fs_info->generation++; 58 root->fs_info->generation++;
59 root->fs_info->running_transaction = cur_trans; 59 root->fs_info->running_transaction = cur_trans;
60 root->fs_info->last_alloc = 0; 60 root->fs_info->last_alloc = 0;
61 root->fs_info->last_data_alloc = 0;
61 cur_trans->num_writers = 1; 62 cur_trans->num_writers = 1;
62 cur_trans->num_joined = 0; 63 cur_trans->num_joined = 0;
63 cur_trans->transid = root->fs_info->generation; 64 cur_trans->transid = root->fs_info->generation;