aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/tree-defrag.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/tree-defrag.c')
-rw-r--r--fs/btrfs/tree-defrag.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/btrfs/tree-defrag.c b/fs/btrfs/tree-defrag.c
index 256af1870eef..5085e9e693b9 100644
--- a/fs/btrfs/tree-defrag.c
+++ b/fs/btrfs/tree-defrag.c
@@ -28,6 +28,7 @@ static void reada_defrag(struct btrfs_root *root,
28 int i; 28 int i;
29 u32 nritems; 29 u32 nritems;
30 u64 bytenr; 30 u64 bytenr;
31 u64 gen;
31 u32 blocksize; 32 u32 blocksize;
32 int ret; 33 int ret;
33 34
@@ -35,7 +36,8 @@ static void reada_defrag(struct btrfs_root *root,
35 nritems = btrfs_header_nritems(node); 36 nritems = btrfs_header_nritems(node);
36 for (i = 0; i < nritems; i++) { 37 for (i = 0; i < nritems; i++) {
37 bytenr = btrfs_node_blockptr(node, i); 38 bytenr = btrfs_node_blockptr(node, i);
38 ret = readahead_tree_block(root, bytenr, blocksize); 39 gen = btrfs_node_ptr_generation(node, i);
40 ret = readahead_tree_block(root, bytenr, blocksize, gen);
39 if (ret) 41 if (ret)
40 break; 42 break;
41 } 43 }
@@ -101,10 +103,11 @@ static int defrag_walk_down(struct btrfs_trans_handle *trans,
101 path->slots[*level]++; 103 path->slots[*level]++;
102 continue; 104 continue;
103 } 105 }
104 btrfs_verify_block_csum(root, next);
105 } else { 106 } else {
106 next = read_tree_block(root, bytenr, 107 next = read_tree_block(root, bytenr,
107 btrfs_level_size(root, *level - 1)); 108 btrfs_level_size(root, *level - 1),
109 btrfs_node_ptr_generation(cur,
110 path->slots[*level]));
108 } 111 }
109 ret = btrfs_cow_block(trans, root, next, path->nodes[*level], 112 ret = btrfs_cow_block(trans, root, next, path->nodes[*level],
110 path->slots[*level], &next); 113 path->slots[*level], &next);