Btrfs: Allow tree blocks larger than the page size
Signed-off-by: Chris Mason <chris.mason@oracle.com>
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index daf019a..3feac2f 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -27,13 +27,15 @@
{
int i;
u32 nritems;
- u64 blocknr;
+ u64 bytenr;
+ u32 blocksize;
int ret;
+ blocksize = btrfs_level_size(root, btrfs_header_level(node) - 1);
nritems = btrfs_header_nritems(node);
for (i = 0; i < nritems; i++) {
- blocknr = btrfs_node_blockptr(node, i);
- ret = readahead_tree_block(root, blocknr);
+ bytenr = btrfs_node_blockptr(node, i);
+ ret = readahead_tree_block(root, bytenr, blocksize);
if (ret)
break;
}
@@ -46,7 +48,7 @@
{
struct extent_buffer *next;
struct extent_buffer *cur;
- u64 blocknr;
+ u64 bytenr;
int ret = 0;
int is_extent = 0;
@@ -80,10 +82,11 @@
break;
}
- blocknr = btrfs_node_blockptr(cur, path->slots[*level]);
+ bytenr = btrfs_node_blockptr(cur, path->slots[*level]);
if (cache_only) {
- next = btrfs_find_tree_block(root, blocknr);
+ next = btrfs_find_tree_block(root, bytenr,
+ btrfs_level_size(root, *level - 1));
/* FIXME, test for defrag */
if (!next || !btrfs_buffer_uptodate(next)) {
free_extent_buffer(next);
@@ -91,7 +94,8 @@
continue;
}
} else {
- next = read_tree_block(root, blocknr);
+ next = read_tree_block(root, bytenr,
+ btrfs_level_size(root, *level - 1));
}
ret = btrfs_cow_block(trans, root, next, path->nodes[*level],
path->slots[*level], &next);