aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-defrag.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-10-15 16:15:53 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:03:56 -0400
commitdb94535db75e67fab12ccbb7f5ee548e33fed891 (patch)
tree1ad7dfc82b003294a94ee87d7329b24b902b369f /fs/btrfs/tree-defrag.c
parent1a5bc167f6707542b79a55452075525620ed43f5 (diff)
Btrfs: Allow tree blocks larger than the page size
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
-rw-r--r--fs/btrfs/tree-defrag.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index daf019afa0a1..3feac2f28628 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -27,13 +27,15 @@ static void reada_defrag(struct btrfs_root *root,
27{ 27{
28 int i; 28 int i;
29 u32 nritems; 29 u32 nritems;
30 u64 blocknr; 30 u64 bytenr;
31 u32 blocksize;
31 int ret; 32 int ret;
32 33
34 blocksize = btrfs_level_size(root, btrfs_header_level(node) - 1);
33 nritems = btrfs_header_nritems(node); 35 nritems = btrfs_header_nritems(node);
34 for (i = 0; i < nritems; i++) { 36 for (i = 0; i < nritems; i++) {
35 blocknr = btrfs_node_blockptr(node, i); 37 bytenr = btrfs_node_blockptr(node, i);
36 ret = readahead_tree_block(root, blocknr); 38 ret = readahead_tree_block(root, bytenr, blocksize);
37 if (ret) 39 if (ret)
38 break; 40 break;
39 } 41 }
@@ -46,7 +48,7 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
46{ 48{
47 struct extent_buffer *next; 49 struct extent_buffer *next;
48 struct extent_buffer *cur; 50 struct extent_buffer *cur;
49 u64 blocknr; 51 u64 bytenr;
50 int ret = 0; 52 int ret = 0;
51 int is_extent = 0; 53 int is_extent = 0;
52 54
@@ -80,10 +82,11 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
80 82
81 break; 83 break;
82 } 84 }
83 blocknr = btrfs_node_blockptr(cur, path->slots[*level]); 85 bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
84 86
85 if (cache_only) { 87 if (cache_only) {
86 next = btrfs_find_tree_block(root, blocknr); 88 next = btrfs_find_tree_block(root, bytenr,
89 btrfs_level_size(root, *level - 1));
87 /* FIXME, test for defrag */ 90 /* FIXME, test for defrag */
88 if (!next || !btrfs_buffer_uptodate(next)) { 91 if (!next || !btrfs_buffer_uptodate(next)) {
89 free_extent_buffer(next); 92 free_extent_buffer(next);
@@ -91,7 +94,8 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
91 continue; 94 continue;
92 } 95 }
93 } else { 96 } else {
94 next = read_tree_block(root, blocknr); 97 next = read_tree_block(root, bytenr,
98 btrfs_level_size(root, *level - 1));
95 } 99 }
96 ret = btrfs_cow_block(trans, root, next, path->nodes[*level], 100 ret = btrfs_cow_block(trans, root, next, path->nodes[*level],
97 path->slots[*level], &next); 101 path->slots[*level], &next);