aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-09-11 15:54:42 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:07 -0400
commitd00aff00139b40f2e9c60299d76aac29d72e48ba (patch)
tree3ef3d84c42dc809cd92ab6339abd968fdede357d /fs
parent3a5f1d458ad1610a06e38f0be2fbc6ac215439c0 (diff)
Btrfs: Optimize tree log block allocations
Since tree log blocks get freed every transaction, they never really need to be written to disk. This skips the step where we update metadata to record they were allocated. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/btrfs/disk-io.c5
-rw-r--r--fs/btrfs/extent-tree.c19
-rw-r--r--fs/btrfs/tree-log.c20
3 files changed, 23 insertions, 21 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 7c06eb4ecfdd..5edb7f885799 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -829,9 +829,8 @@ int btrfs_free_log_root_tree(struct btrfs_trans_handle *trans,
829 WARN_ON(btrfs_header_level(eb) != 0); 829 WARN_ON(btrfs_header_level(eb) != 0);
830 WARN_ON(btrfs_header_nritems(eb) != 0); 830 WARN_ON(btrfs_header_nritems(eb) != 0);
831 831
832 ret = btrfs_free_extent(trans, fs_info->tree_root, 832 ret = btrfs_free_reserved_extent(fs_info->tree_root,
833 eb->start, eb->len, 833 eb->start, eb->len);
834 BTRFS_TREE_LOG_OBJECTID, 0, 0, 0, 1);
835 BUG_ON(ret); 834 BUG_ON(ret);
836 835
837 free_extent_buffer(eb); 836 free_extent_buffer(eb);
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 3181759da1cf..c479d71e2869 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1872,8 +1872,15 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
1872 return 0; 1872 return 0;
1873 } 1873 }
1874 /* if metadata always pin */ 1874 /* if metadata always pin */
1875 if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) 1875 if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) {
1876 if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) {
1877 /* btrfs_free_reserved_extent */
1878 set_extent_dirty(&root->fs_info->free_space_cache,
1879 bytenr, bytenr + num_bytes - 1, GFP_NOFS);
1880 return 0;
1881 }
1876 pin = 1; 1882 pin = 1;
1883 }
1877 1884
1878 /* if data pin when any transaction has committed this */ 1885 /* if data pin when any transaction has committed this */
1879 if (ref_generation != trans->transid) 1886 if (ref_generation != trans->transid)
@@ -2361,11 +2368,13 @@ int btrfs_alloc_extent(struct btrfs_trans_handle *trans,
2361 min_alloc_size, empty_size, hint_byte, 2368 min_alloc_size, empty_size, hint_byte,
2362 search_end, ins, data); 2369 search_end, ins, data);
2363 BUG_ON(ret); 2370 BUG_ON(ret);
2364 ret = __btrfs_alloc_reserved_extent(trans, root, root_objectid, 2371 if (root_objectid != BTRFS_TREE_LOG_OBJECTID) {
2365 ref_generation, owner, 2372 ret = __btrfs_alloc_reserved_extent(trans, root, root_objectid,
2366 owner_offset, ins); 2373 ref_generation, owner,
2367 BUG_ON(ret); 2374 owner_offset, ins);
2375 BUG_ON(ret);
2368 2376
2377 }
2369 maybe_unlock_mutex(root); 2378 maybe_unlock_mutex(root);
2370 return ret; 2379 return ret;
2371} 2380}
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index f43ee33ec2dc..5f77bee0f846 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -1728,9 +1728,8 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans,
1728 1728
1729 WARN_ON(root_owner != 1729 WARN_ON(root_owner !=
1730 BTRFS_TREE_LOG_OBJECTID); 1730 BTRFS_TREE_LOG_OBJECTID);
1731 ret = btrfs_free_extent(trans, root, bytenr, 1731 ret = btrfs_free_reserved_extent(root,
1732 blocksize, root_owner, 1732 bytenr, blocksize);
1733 root_gen, 0, 0, 1);
1734 BUG_ON(ret); 1733 BUG_ON(ret);
1735 } 1734 }
1736 free_extent_buffer(next); 1735 free_extent_buffer(next);
@@ -1775,8 +1774,7 @@ static int noinline walk_down_log_tree(struct btrfs_trans_handle *trans,
1775 BUG_ON(ret); 1774 BUG_ON(ret);
1776 } 1775 }
1777 WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); 1776 WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
1778 ret = btrfs_free_extent(trans, root, bytenr, blocksize, 1777 ret = btrfs_free_reserved_extent(root, bytenr, blocksize);
1779 root_owner, root_gen, 0, 0, 1);
1780 BUG_ON(ret); 1778 BUG_ON(ret);
1781 } 1779 }
1782 free_extent_buffer(path->nodes[*level]); 1780 free_extent_buffer(path->nodes[*level]);
@@ -1837,10 +1835,9 @@ static int noinline walk_up_log_tree(struct btrfs_trans_handle *trans,
1837 } 1835 }
1838 1836
1839 WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID); 1837 WARN_ON(root_owner != BTRFS_TREE_LOG_OBJECTID);
1840 ret = btrfs_free_extent(trans, root, 1838 ret = btrfs_free_reserved_extent(root,
1841 path->nodes[*level]->start, 1839 path->nodes[*level]->start,
1842 path->nodes[*level]->len, 1840 path->nodes[*level]->len);
1843 root_owner, root_gen, 0, 0, 1);
1844 BUG_ON(ret); 1841 BUG_ON(ret);
1845 } 1842 }
1846 free_extent_buffer(path->nodes[*level]); 1843 free_extent_buffer(path->nodes[*level]);
@@ -1910,11 +1907,8 @@ static int walk_log_tree(struct btrfs_trans_handle *trans,
1910 } 1907 }
1911 WARN_ON(log->root_key.objectid != 1908 WARN_ON(log->root_key.objectid !=
1912 BTRFS_TREE_LOG_OBJECTID); 1909 BTRFS_TREE_LOG_OBJECTID);
1913 ret = btrfs_free_extent(trans, log, 1910 ret = btrfs_free_reserved_extent(log, next->start,
1914 next->start, next->len, 1911 next->len);
1915 log->root_key.objectid,
1916 btrfs_header_generation(next),
1917 0, 0, 1);
1918 BUG_ON(ret); 1912 BUG_ON(ret);
1919 } 1913 }
1920 } 1914 }