aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-13 09:28:32 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-13 09:28:32 -0400
commit1d4f8a0c1eca5586134b56a4114a7cd5e85e3560 (patch)
tree602ec189899092f0f61b1b857937cdf9d1799590 /fs/btrfs/ctree.c
parent0783fcfc4dc19b8bb99bd51b7afa669ba4cbd377 (diff)
Btrfs: node->blockptrs endian fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.c')
-rw-r--r--fs/btrfs/ctree.c31
1 files changed, 18 insertions, 13 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index 105556470055..762810731001 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -58,7 +58,8 @@ int btrfs_cow_block(struct ctree_root *root,
58 free_extent(root, buf->blocknr, 1); 58 free_extent(root, buf->blocknr, 1);
59 tree_block_release(root, buf); 59 tree_block_release(root, buf);
60 } else { 60 } else {
61 parent->node.blockptrs[parent_slot] = cow->blocknr; 61 btrfs_set_node_blockptr(&parent->node, parent_slot,
62 cow->blocknr);
62 BUG_ON(list_empty(&parent->dirty)); 63 BUG_ON(list_empty(&parent->dirty));
63 free_extent(root, buf->blocknr, 1); 64 free_extent(root, buf->blocknr, 1);
64 } 65 }
@@ -133,7 +134,7 @@ int check_node(struct ctree_path *path, int level)
133 parent_key = &parent->keys[parent_slot]; 134 parent_key = &parent->keys[parent_slot];
134 BUG_ON(memcmp(parent_key, node->keys, 135 BUG_ON(memcmp(parent_key, node->keys,
135 sizeof(struct btrfs_disk_key))); 136 sizeof(struct btrfs_disk_key)));
136 BUG_ON(parent->blockptrs[parent_slot] != 137 BUG_ON(btrfs_node_blockptr(parent, parent_slot) !=
137 btrfs_header_blocknr(&node->header)); 138 btrfs_header_blocknr(&node->header));
138 } 139 }
139 BUG_ON(nritems > NODEPTRS_PER_BLOCK); 140 BUG_ON(nritems > NODEPTRS_PER_BLOCK);
@@ -166,7 +167,7 @@ int check_leaf(struct ctree_path *path, int level)
166 parent_key = &parent->keys[parent_slot]; 167 parent_key = &parent->keys[parent_slot];
167 BUG_ON(memcmp(parent_key, &leaf->items[0].key, 168 BUG_ON(memcmp(parent_key, &leaf->items[0].key,
168 sizeof(struct btrfs_disk_key))); 169 sizeof(struct btrfs_disk_key)));
169 BUG_ON(parent->blockptrs[parent_slot] != 170 BUG_ON(btrfs_node_blockptr(parent, parent_slot) !=
170 btrfs_header_blocknr(&leaf->header)); 171 btrfs_header_blocknr(&leaf->header));
171 } 172 }
172 for (i = 0; nritems > 1 && i < nritems - 2; i++) { 173 for (i = 0; nritems > 1 && i < nritems - 2; i++) {
@@ -258,7 +259,7 @@ struct tree_buffer *read_node_slot(struct ctree_root *root,
258 return NULL; 259 return NULL;
259 if (slot >= btrfs_header_nritems(&node->header)) 260 if (slot >= btrfs_header_nritems(&node->header))
260 return NULL; 261 return NULL;
261 return read_tree_block(root, node->blockptrs[slot]); 262 return read_tree_block(root, btrfs_node_blockptr(node, slot));
262} 263}
263 264
264static int balance_level(struct ctree_root *root, struct ctree_path *path, 265static int balance_level(struct ctree_root *root, struct ctree_path *path,
@@ -283,7 +284,7 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path,
283 284
284 mid_buf = path->nodes[level]; 285 mid_buf = path->nodes[level];
285 mid = &mid_buf->node; 286 mid = &mid_buf->node;
286 orig_ptr = mid->blockptrs[orig_slot]; 287 orig_ptr = btrfs_node_blockptr(mid, orig_slot);
287 288
288 if (level < MAX_LEVEL - 1) 289 if (level < MAX_LEVEL - 1)
289 parent_buf = path->nodes[level + 1]; 290 parent_buf = path->nodes[level + 1];
@@ -407,7 +408,8 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path,
407 } 408 }
408 /* double check we haven't messed things up */ 409 /* double check we haven't messed things up */
409 check_block(path, level); 410 check_block(path, level);
410 if (orig_ptr != path->nodes[level]->node.blockptrs[path->slots[level]]) 411 if (orig_ptr != btrfs_node_blockptr(&path->nodes[level]->node,
412 path->slots[level]))
411 BUG(); 413 BUG();
412 414
413 if (right_buf) 415 if (right_buf)
@@ -482,7 +484,7 @@ again:
482 slot = p->slots[level]; 484 slot = p->slots[level];
483 BUG_ON(btrfs_header_nritems(&c->header) == 1); 485 BUG_ON(btrfs_header_nritems(&c->header) == 1);
484 } 486 }
485 b = read_tree_block(root, c->blockptrs[slot]); 487 b = read_tree_block(root, btrfs_node_blockptr(c, slot));
486 } else { 488 } else {
487 struct leaf *l = (struct leaf *)c; 489 struct leaf *l = (struct leaf *)c;
488 p->slots[level] = slot; 490 p->slots[level] = slot;
@@ -660,7 +662,7 @@ static int insert_new_root(struct ctree_root *root,
660 else 662 else
661 lower_key = lower->keys; 663 lower_key = lower->keys;
662 memcpy(c->keys, lower_key, sizeof(struct btrfs_disk_key)); 664 memcpy(c->keys, lower_key, sizeof(struct btrfs_disk_key));
663 c->blockptrs[0] = path->nodes[level-1]->blocknr; 665 btrfs_set_node_blockptr(c, 0, path->nodes[level - 1]->blocknr);
664 /* the super has an extra ref to root->node */ 666 /* the super has an extra ref to root->node */
665 tree_block_release(root, root->node); 667 tree_block_release(root, root->node);
666 root->node = t; 668 root->node = t;
@@ -700,7 +702,7 @@ static int insert_ptr(struct ctree_root *root,
700 (nritems - slot) * sizeof(u64)); 702 (nritems - slot) * sizeof(u64));
701 } 703 }
702 memcpy(lower->keys + slot, key, sizeof(struct btrfs_disk_key)); 704 memcpy(lower->keys + slot, key, sizeof(struct btrfs_disk_key));
703 lower->blockptrs[slot] = blocknr; 705 btrfs_set_node_blockptr(lower, slot, blocknr);
704 btrfs_set_header_nritems(&lower->header, nritems + 1); 706 btrfs_set_header_nritems(&lower->header, nritems + 1);
705 if (lower->keys[1].objectid == 0) 707 if (lower->keys[1].objectid == 0)
706 BUG(); 708 BUG();
@@ -820,7 +822,8 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path,
820 if (slot >= btrfs_header_nritems(&upper->node.header) - 1) { 822 if (slot >= btrfs_header_nritems(&upper->node.header) - 1) {
821 return 1; 823 return 1;
822 } 824 }
823 right_buf = read_tree_block(root, upper->node.blockptrs[slot + 1]); 825 right_buf = read_tree_block(root, btrfs_node_blockptr(&upper->node,
826 slot + 1));
824 right = &right_buf->leaf; 827 right = &right_buf->leaf;
825 free_space = leaf_free_space(right); 828 free_space = leaf_free_space(right);
826 if (free_space < data_size + sizeof(struct btrfs_item)) { 829 if (free_space < data_size + sizeof(struct btrfs_item)) {
@@ -926,7 +929,8 @@ static int push_leaf_left(struct ctree_root *root, struct ctree_path *path,
926 if (!path->nodes[1]) { 929 if (!path->nodes[1]) {
927 return 1; 930 return 1;
928 } 931 }
929 t = read_tree_block(root, path->nodes[1]->node.blockptrs[slot - 1]); 932 t = read_tree_block(root, btrfs_node_blockptr(&path->nodes[1]->node,
933 slot - 1));
930 left = &t->leaf; 934 left = &t->leaf;
931 free_space = leaf_free_space(left); 935 free_space = leaf_free_space(left);
932 if (free_space < data_size + sizeof(struct btrfs_item)) { 936 if (free_space < data_size + sizeof(struct btrfs_item)) {
@@ -1353,7 +1357,7 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path)
1353 level++; 1357 level++;
1354 continue; 1358 continue;
1355 } 1359 }
1356 blocknr = c->node.blockptrs[slot]; 1360 blocknr = btrfs_node_blockptr(&c->node, slot);
1357 if (next) 1361 if (next)
1358 tree_block_release(root, next); 1362 tree_block_release(root, next);
1359 next = read_tree_block(root, blocknr); 1363 next = read_tree_block(root, blocknr);
@@ -1368,7 +1372,8 @@ int next_leaf(struct ctree_root *root, struct ctree_path *path)
1368 path->slots[level] = 0; 1372 path->slots[level] = 0;
1369 if (!level) 1373 if (!level)
1370 break; 1374 break;
1371 next = read_tree_block(root, next->node.blockptrs[0]); 1375 next = read_tree_block(root,
1376 btrfs_node_blockptr(&next->node, 0));
1372 } 1377 }
1373 return 0; 1378 return 0;
1374} 1379}