diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-12 16:22:34 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-12 16:22:34 -0400 |
commit | e2fa7227cdf132d72e7410dd0679dc573a1c2618 (patch) | |
tree | 2f739ce2f7f7735c81a86c209290c050efa85ade /fs | |
parent | bb492bb0a5453222109a72859353728959c2539d (diff) |
Btrfs: struct key endian fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/ctree.c | 92 | ||||
-rw-r--r-- | fs/btrfs/ctree.h | 78 | ||||
-rw-r--r-- | fs/btrfs/extent-tree.c | 34 | ||||
-rw-r--r-- | fs/btrfs/kerncompat.h | 3 | ||||
-rw-r--r-- | fs/btrfs/mkfs.c | 14 | ||||
-rw-r--r-- | fs/btrfs/quick-test.c | 6 | ||||
-rw-r--r-- | fs/btrfs/random-test.c | 17 |
7 files changed, 162 insertions, 82 deletions
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c index e43c827e0dfd..489019ac04b8 100644 --- a/fs/btrfs/ctree.c +++ b/fs/btrfs/ctree.c | |||
@@ -95,19 +95,23 @@ int leaf_free_space(struct leaf *leaf) | |||
95 | /* | 95 | /* |
96 | * compare two keys in a memcmp fashion | 96 | * compare two keys in a memcmp fashion |
97 | */ | 97 | */ |
98 | int comp_keys(struct key *k1, struct key *k2) | 98 | int comp_keys(struct btrfs_disk_key *disk, struct btrfs_key *k2) |
99 | { | 99 | { |
100 | if (k1->objectid > k2->objectid) | 100 | struct btrfs_key k1; |
101 | |||
102 | btrfs_disk_key_to_cpu(&k1, disk); | ||
103 | |||
104 | if (k1.objectid > k2->objectid) | ||
101 | return 1; | 105 | return 1; |
102 | if (k1->objectid < k2->objectid) | 106 | if (k1.objectid < k2->objectid) |
103 | return -1; | 107 | return -1; |
104 | if (k1->flags > k2->flags) | 108 | if (k1.flags > k2->flags) |
105 | return 1; | 109 | return 1; |
106 | if (k1->flags < k2->flags) | 110 | if (k1.flags < k2->flags) |
107 | return -1; | 111 | return -1; |
108 | if (k1->offset > k2->offset) | 112 | if (k1.offset > k2->offset) |
109 | return 1; | 113 | return 1; |
110 | if (k1->offset < k2->offset) | 114 | if (k1.offset < k2->offset) |
111 | return -1; | 115 | return -1; |
112 | return 0; | 116 | return 0; |
113 | } | 117 | } |
@@ -125,15 +129,18 @@ int check_node(struct ctree_path *path, int level) | |||
125 | parent_slot = path->slots[level + 1]; | 129 | parent_slot = path->slots[level + 1]; |
126 | BUG_ON(nritems == 0); | 130 | BUG_ON(nritems == 0); |
127 | if (parent) { | 131 | if (parent) { |
128 | struct key *parent_key; | 132 | struct btrfs_disk_key *parent_key; |
129 | parent_key = &parent->keys[parent_slot]; | 133 | parent_key = &parent->keys[parent_slot]; |
130 | BUG_ON(memcmp(parent_key, node->keys, sizeof(struct key))); | 134 | BUG_ON(memcmp(parent_key, node->keys, |
135 | sizeof(struct btrfs_disk_key))); | ||
131 | BUG_ON(parent->blockptrs[parent_slot] != | 136 | BUG_ON(parent->blockptrs[parent_slot] != |
132 | btrfs_header_blocknr(&node->header)); | 137 | btrfs_header_blocknr(&node->header)); |
133 | } | 138 | } |
134 | BUG_ON(nritems > NODEPTRS_PER_BLOCK); | 139 | BUG_ON(nritems > NODEPTRS_PER_BLOCK); |
135 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { | 140 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { |
136 | BUG_ON(comp_keys(&node->keys[i], &node->keys[i+1]) >= 0); | 141 | struct btrfs_key cpukey; |
142 | btrfs_disk_key_to_cpu(&cpukey, &node->keys[i + 1]); | ||
143 | BUG_ON(comp_keys(&node->keys[i], &cpukey) >= 0); | ||
137 | } | 144 | } |
138 | return 0; | 145 | return 0; |
139 | } | 146 | } |
@@ -155,16 +162,18 @@ int check_leaf(struct ctree_path *path, int level) | |||
155 | return 0; | 162 | return 0; |
156 | 163 | ||
157 | if (parent) { | 164 | if (parent) { |
158 | struct key *parent_key; | 165 | struct btrfs_disk_key *parent_key; |
159 | parent_key = &parent->keys[parent_slot]; | 166 | parent_key = &parent->keys[parent_slot]; |
160 | BUG_ON(memcmp(parent_key, &leaf->items[0].key, | 167 | BUG_ON(memcmp(parent_key, &leaf->items[0].key, |
161 | sizeof(struct key))); | 168 | sizeof(struct btrfs_disk_key))); |
162 | BUG_ON(parent->blockptrs[parent_slot] != | 169 | BUG_ON(parent->blockptrs[parent_slot] != |
163 | btrfs_header_blocknr(&leaf->header)); | 170 | btrfs_header_blocknr(&leaf->header)); |
164 | } | 171 | } |
165 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { | 172 | for (i = 0; nritems > 1 && i < nritems - 2; i++) { |
173 | struct btrfs_key cpukey; | ||
174 | btrfs_disk_key_to_cpu(&cpukey, &leaf->items[i + 1].key); | ||
166 | BUG_ON(comp_keys(&leaf->items[i].key, | 175 | BUG_ON(comp_keys(&leaf->items[i].key, |
167 | &leaf->items[i+1].key) >= 0); | 176 | &cpukey) >= 0); |
168 | BUG_ON(leaf->items[i].offset != leaf->items[i + 1].offset + | 177 | BUG_ON(leaf->items[i].offset != leaf->items[i + 1].offset + |
169 | leaf->items[i + 1].size); | 178 | leaf->items[i + 1].size); |
170 | if (i == 0) { | 179 | if (i == 0) { |
@@ -191,18 +200,18 @@ int check_block(struct ctree_path *path, int level) | |||
191 | * | 200 | * |
192 | * slot may point to max if the key is bigger than all of the keys | 201 | * slot may point to max if the key is bigger than all of the keys |
193 | */ | 202 | */ |
194 | int generic_bin_search(char *p, int item_size, struct key *key, | 203 | int generic_bin_search(char *p, int item_size, struct btrfs_key *key, |
195 | int max, int *slot) | 204 | int max, int *slot) |
196 | { | 205 | { |
197 | int low = 0; | 206 | int low = 0; |
198 | int high = max; | 207 | int high = max; |
199 | int mid; | 208 | int mid; |
200 | int ret; | 209 | int ret; |
201 | struct key *tmp; | 210 | struct btrfs_disk_key *tmp; |
202 | 211 | ||
203 | while(low < high) { | 212 | while(low < high) { |
204 | mid = (low + high) / 2; | 213 | mid = (low + high) / 2; |
205 | tmp = (struct key *)(p + mid * item_size); | 214 | tmp = (struct btrfs_disk_key *)(p + mid * item_size); |
206 | ret = comp_keys(tmp, key); | 215 | ret = comp_keys(tmp, key); |
207 | 216 | ||
208 | if (ret < 0) | 217 | if (ret < 0) |
@@ -222,7 +231,7 @@ int generic_bin_search(char *p, int item_size, struct key *key, | |||
222 | * simple bin_search frontend that does the right thing for | 231 | * simple bin_search frontend that does the right thing for |
223 | * leaves vs nodes | 232 | * leaves vs nodes |
224 | */ | 233 | */ |
225 | int bin_search(struct node *c, struct key *key, int *slot) | 234 | int bin_search(struct node *c, struct btrfs_key *key, int *slot) |
226 | { | 235 | { |
227 | if (btrfs_is_leaf(c)) { | 236 | if (btrfs_is_leaf(c)) { |
228 | struct leaf *l = (struct leaf *)c; | 237 | struct leaf *l = (struct leaf *)c; |
@@ -230,7 +239,8 @@ int bin_search(struct node *c, struct key *key, int *slot) | |||
230 | key, btrfs_header_nritems(&c->header), | 239 | key, btrfs_header_nritems(&c->header), |
231 | slot); | 240 | slot); |
232 | } else { | 241 | } else { |
233 | return generic_bin_search((void *)c->keys, sizeof(struct key), | 242 | return generic_bin_search((void *)c->keys, |
243 | sizeof(struct btrfs_disk_key), | ||
234 | key, btrfs_header_nritems(&c->header), | 244 | key, btrfs_header_nritems(&c->header), |
235 | slot); | 245 | slot); |
236 | } | 246 | } |
@@ -339,7 +349,7 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
339 | ret = wret; | 349 | ret = wret; |
340 | } else { | 350 | } else { |
341 | memcpy(parent->keys + pslot + 1, right->keys, | 351 | memcpy(parent->keys + pslot + 1, right->keys, |
342 | sizeof(struct key)); | 352 | sizeof(struct btrfs_disk_key)); |
343 | BUG_ON(list_empty(&parent_buf->dirty)); | 353 | BUG_ON(list_empty(&parent_buf->dirty)); |
344 | } | 354 | } |
345 | } | 355 | } |
@@ -374,7 +384,8 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
374 | ret = wret; | 384 | ret = wret; |
375 | } else { | 385 | } else { |
376 | /* update the parent key to reflect our changes */ | 386 | /* update the parent key to reflect our changes */ |
377 | memcpy(parent->keys + pslot, mid->keys, sizeof(struct key)); | 387 | memcpy(parent->keys + pslot, mid->keys, |
388 | sizeof(struct btrfs_disk_key)); | ||
378 | BUG_ON(list_empty(&parent_buf->dirty)); | 389 | BUG_ON(list_empty(&parent_buf->dirty)); |
379 | } | 390 | } |
380 | 391 | ||
@@ -417,7 +428,7 @@ static int balance_level(struct ctree_root *root, struct ctree_path *path, | |||
417 | * tree. if ins_len < 0, nodes will be merged as we walk down the tree (if | 428 | * tree. if ins_len < 0, nodes will be merged as we walk down the tree (if |
418 | * possible) | 429 | * possible) |
419 | */ | 430 | */ |
420 | int search_slot(struct ctree_root *root, struct key *key, | 431 | int search_slot(struct ctree_root *root, struct btrfs_key *key, |
421 | struct ctree_path *p, int ins_len, int cow) | 432 | struct ctree_path *p, int ins_len, int cow) |
422 | { | 433 | { |
423 | struct tree_buffer *b; | 434 | struct tree_buffer *b; |
@@ -499,7 +510,7 @@ again: | |||
499 | * fixing up the blocks in ram so the tree is consistent. | 510 | * fixing up the blocks in ram so the tree is consistent. |
500 | */ | 511 | */ |
501 | static int fixup_low_keys(struct ctree_root *root, | 512 | static int fixup_low_keys(struct ctree_root *root, |
502 | struct ctree_path *path, struct key *key, | 513 | struct ctree_path *path, struct btrfs_disk_key *key, |
503 | int level) | 514 | int level) |
504 | { | 515 | { |
505 | int i; | 516 | int i; |
@@ -546,12 +557,13 @@ static int push_node_left(struct ctree_root *root, struct tree_buffer *dst_buf, | |||
546 | push_items = src_nritems; | 557 | push_items = src_nritems; |
547 | 558 | ||
548 | memcpy(dst->keys + dst_nritems, src->keys, | 559 | memcpy(dst->keys + dst_nritems, src->keys, |
549 | push_items * sizeof(struct key)); | 560 | push_items * sizeof(struct btrfs_disk_key)); |
550 | memcpy(dst->blockptrs + dst_nritems, src->blockptrs, | 561 | memcpy(dst->blockptrs + dst_nritems, src->blockptrs, |
551 | push_items * sizeof(u64)); | 562 | push_items * sizeof(u64)); |
552 | if (push_items < src_nritems) { | 563 | if (push_items < src_nritems) { |
553 | memmove(src->keys, src->keys + push_items, | 564 | memmove(src->keys, src->keys + push_items, |
554 | (src_nritems - push_items) * sizeof(struct key)); | 565 | (src_nritems - push_items) * |
566 | sizeof(struct btrfs_disk_key)); | ||
555 | memmove(src->blockptrs, src->blockptrs + push_items, | 567 | memmove(src->blockptrs, src->blockptrs + push_items, |
556 | (src_nritems - push_items) * sizeof(u64)); | 568 | (src_nritems - push_items) * sizeof(u64)); |
557 | } | 569 | } |
@@ -598,11 +610,11 @@ static int balance_node_right(struct ctree_root *root, | |||
598 | push_items = max_push; | 610 | push_items = max_push; |
599 | 611 | ||
600 | memmove(dst->keys + push_items, dst->keys, | 612 | memmove(dst->keys + push_items, dst->keys, |
601 | dst_nritems * sizeof(struct key)); | 613 | dst_nritems * sizeof(struct btrfs_disk_key)); |
602 | memmove(dst->blockptrs + push_items, dst->blockptrs, | 614 | memmove(dst->blockptrs + push_items, dst->blockptrs, |
603 | dst_nritems * sizeof(u64)); | 615 | dst_nritems * sizeof(u64)); |
604 | memcpy(dst->keys, src->keys + src_nritems - push_items, | 616 | memcpy(dst->keys, src->keys + src_nritems - push_items, |
605 | push_items * sizeof(struct key)); | 617 | push_items * sizeof(struct btrfs_disk_key)); |
606 | memcpy(dst->blockptrs, src->blockptrs + src_nritems - push_items, | 618 | memcpy(dst->blockptrs, src->blockptrs + src_nritems - push_items, |
607 | push_items * sizeof(u64)); | 619 | push_items * sizeof(u64)); |
608 | 620 | ||
@@ -627,7 +639,7 @@ static int insert_new_root(struct ctree_root *root, | |||
627 | struct tree_buffer *t; | 639 | struct tree_buffer *t; |
628 | struct node *lower; | 640 | struct node *lower; |
629 | struct node *c; | 641 | struct node *c; |
630 | struct key *lower_key; | 642 | struct btrfs_disk_key *lower_key; |
631 | 643 | ||
632 | BUG_ON(path->nodes[level]); | 644 | BUG_ON(path->nodes[level]); |
633 | BUG_ON(path->nodes[level-1] != root->node); | 645 | BUG_ON(path->nodes[level-1] != root->node); |
@@ -645,7 +657,7 @@ static int insert_new_root(struct ctree_root *root, | |||
645 | lower_key = &((struct leaf *)lower)->items[0].key; | 657 | lower_key = &((struct leaf *)lower)->items[0].key; |
646 | else | 658 | else |
647 | lower_key = lower->keys; | 659 | lower_key = lower->keys; |
648 | memcpy(c->keys, lower_key, sizeof(struct key)); | 660 | memcpy(c->keys, lower_key, sizeof(struct btrfs_disk_key)); |
649 | c->blockptrs[0] = path->nodes[level-1]->blocknr; | 661 | c->blockptrs[0] = path->nodes[level-1]->blocknr; |
650 | /* the super has an extra ref to root->node */ | 662 | /* the super has an extra ref to root->node */ |
651 | tree_block_release(root, root->node); | 663 | tree_block_release(root, root->node); |
@@ -666,7 +678,7 @@ static int insert_new_root(struct ctree_root *root, | |||
666 | * returns zero on success and < 0 on any error | 678 | * returns zero on success and < 0 on any error |
667 | */ | 679 | */ |
668 | static int insert_ptr(struct ctree_root *root, | 680 | static int insert_ptr(struct ctree_root *root, |
669 | struct ctree_path *path, struct key *key, | 681 | struct ctree_path *path, struct btrfs_disk_key *key, |
670 | u64 blocknr, int slot, int level) | 682 | u64 blocknr, int slot, int level) |
671 | { | 683 | { |
672 | struct node *lower; | 684 | struct node *lower; |
@@ -681,11 +693,11 @@ static int insert_ptr(struct ctree_root *root, | |||
681 | BUG(); | 693 | BUG(); |
682 | if (slot != nritems) { | 694 | if (slot != nritems) { |
683 | memmove(lower->keys + slot + 1, lower->keys + slot, | 695 | memmove(lower->keys + slot + 1, lower->keys + slot, |
684 | (nritems - slot) * sizeof(struct key)); | 696 | (nritems - slot) * sizeof(struct btrfs_disk_key)); |
685 | memmove(lower->blockptrs + slot + 1, lower->blockptrs + slot, | 697 | memmove(lower->blockptrs + slot + 1, lower->blockptrs + slot, |
686 | (nritems - slot) * sizeof(u64)); | 698 | (nritems - slot) * sizeof(u64)); |
687 | } | 699 | } |
688 | memcpy(lower->keys + slot, key, sizeof(struct key)); | 700 | memcpy(lower->keys + slot, key, sizeof(struct btrfs_disk_key)); |
689 | lower->blockptrs[slot] = blocknr; | 701 | lower->blockptrs[slot] = blocknr; |
690 | btrfs_set_header_nritems(&lower->header, nritems + 1); | 702 | btrfs_set_header_nritems(&lower->header, nritems + 1); |
691 | if (lower->keys[1].objectid == 0) | 703 | if (lower->keys[1].objectid == 0) |
@@ -732,7 +744,7 @@ static int split_node(struct ctree_root *root, struct ctree_path *path, | |||
732 | btrfs_header_parentid(&root->node->node.header)); | 744 | btrfs_header_parentid(&root->node->node.header)); |
733 | mid = (c_nritems + 1) / 2; | 745 | mid = (c_nritems + 1) / 2; |
734 | memcpy(split->keys, c->keys + mid, | 746 | memcpy(split->keys, c->keys + mid, |
735 | (c_nritems - mid) * sizeof(struct key)); | 747 | (c_nritems - mid) * sizeof(struct btrfs_disk_key)); |
736 | memcpy(split->blockptrs, c->blockptrs + mid, | 748 | memcpy(split->blockptrs, c->blockptrs + mid, |
737 | (c_nritems - mid) * sizeof(u64)); | 749 | (c_nritems - mid) * sizeof(u64)); |
738 | btrfs_set_header_nritems(&split->header, c_nritems - mid); | 750 | btrfs_set_header_nritems(&split->header, c_nritems - mid); |
@@ -869,7 +881,7 @@ static int push_leaf_right(struct ctree_root *root, struct ctree_path *path, | |||
869 | BUG_ON(list_empty(&left_buf->dirty)); | 881 | BUG_ON(list_empty(&left_buf->dirty)); |
870 | BUG_ON(list_empty(&right_buf->dirty)); | 882 | BUG_ON(list_empty(&right_buf->dirty)); |
871 | memcpy(upper->node.keys + slot + 1, | 883 | memcpy(upper->node.keys + slot + 1, |
872 | &right->items[0].key, sizeof(struct key)); | 884 | &right->items[0].key, sizeof(struct btrfs_disk_key)); |
873 | BUG_ON(list_empty(&upper->dirty)); | 885 | BUG_ON(list_empty(&upper->dirty)); |
874 | 886 | ||
875 | /* then fixup the leaf pointer in the path */ | 887 | /* then fixup the leaf pointer in the path */ |
@@ -1090,7 +1102,7 @@ static int split_leaf(struct ctree_root *root, struct ctree_path *path, | |||
1090 | * Given a key and some data, insert an item into the tree. | 1102 | * Given a key and some data, insert an item into the tree. |
1091 | * This does all the path init required, making room in the tree if needed. | 1103 | * This does all the path init required, making room in the tree if needed. |
1092 | */ | 1104 | */ |
1093 | int insert_item(struct ctree_root *root, struct key *key, | 1105 | int insert_item(struct ctree_root *root, struct btrfs_key *cpu_key, |
1094 | void *data, int data_size) | 1106 | void *data, int data_size) |
1095 | { | 1107 | { |
1096 | int ret = 0; | 1108 | int ret = 0; |
@@ -1101,12 +1113,15 @@ int insert_item(struct ctree_root *root, struct key *key, | |||
1101 | u32 nritems; | 1113 | u32 nritems; |
1102 | unsigned int data_end; | 1114 | unsigned int data_end; |
1103 | struct ctree_path path; | 1115 | struct ctree_path path; |
1116 | struct btrfs_disk_key disk_key; | ||
1117 | |||
1118 | btrfs_cpu_key_to_disk(&disk_key, cpu_key); | ||
1104 | 1119 | ||
1105 | /* create a root if there isn't one */ | 1120 | /* create a root if there isn't one */ |
1106 | if (!root->node) | 1121 | if (!root->node) |
1107 | BUG(); | 1122 | BUG(); |
1108 | init_path(&path); | 1123 | init_path(&path); |
1109 | ret = search_slot(root, key, &path, data_size, 1); | 1124 | ret = search_slot(root, cpu_key, &path, data_size, 1); |
1110 | if (ret == 0) { | 1125 | if (ret == 0) { |
1111 | release_path(root, &path); | 1126 | release_path(root, &path); |
1112 | return -EEXIST; | 1127 | return -EEXIST; |
@@ -1148,7 +1163,8 @@ int insert_item(struct ctree_root *root, struct key *key, | |||
1148 | data_end = old_data; | 1163 | data_end = old_data; |
1149 | } | 1164 | } |
1150 | /* copy the new data in */ | 1165 | /* copy the new data in */ |
1151 | memcpy(&leaf->items[slot].key, key, sizeof(struct key)); | 1166 | memcpy(&leaf->items[slot].key, &disk_key, |
1167 | sizeof(struct btrfs_disk_key)); | ||
1152 | leaf->items[slot].offset = data_end - data_size; | 1168 | leaf->items[slot].offset = data_end - data_size; |
1153 | leaf->items[slot].size = data_size; | 1169 | leaf->items[slot].size = data_size; |
1154 | memcpy(leaf->data + data_end - data_size, data, data_size); | 1170 | memcpy(leaf->data + data_end - data_size, data, data_size); |
@@ -1156,7 +1172,7 @@ int insert_item(struct ctree_root *root, struct key *key, | |||
1156 | 1172 | ||
1157 | ret = 0; | 1173 | ret = 0; |
1158 | if (slot == 0) | 1174 | if (slot == 0) |
1159 | ret = fixup_low_keys(root, &path, key, 1); | 1175 | ret = fixup_low_keys(root, &path, &disk_key, 1); |
1160 | 1176 | ||
1161 | BUG_ON(list_empty(&leaf_buf->dirty)); | 1177 | BUG_ON(list_empty(&leaf_buf->dirty)); |
1162 | if (leaf_free_space(leaf) < 0) | 1178 | if (leaf_free_space(leaf) < 0) |
@@ -1187,7 +1203,7 @@ static int del_ptr(struct ctree_root *root, struct ctree_path *path, int level, | |||
1187 | nritems = btrfs_header_nritems(&node->header); | 1203 | nritems = btrfs_header_nritems(&node->header); |
1188 | if (slot != nritems -1) { | 1204 | if (slot != nritems -1) { |
1189 | memmove(node->keys + slot, node->keys + slot + 1, | 1205 | memmove(node->keys + slot, node->keys + slot + 1, |
1190 | sizeof(struct key) * (nritems - slot - 1)); | 1206 | sizeof(struct btrfs_disk_key) * (nritems - slot - 1)); |
1191 | memmove(node->blockptrs + slot, | 1207 | memmove(node->blockptrs + slot, |
1192 | node->blockptrs + slot + 1, | 1208 | node->blockptrs + slot + 1, |
1193 | sizeof(u64) * (nritems - slot - 1)); | 1209 | sizeof(u64) * (nritems - slot - 1)); |
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index e1aaca66d590..58e03e90f23a 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -2,6 +2,7 @@ | |||
2 | #define __CTREE__ | 2 | #define __CTREE__ |
3 | 3 | ||
4 | #include "list.h" | 4 | #include "list.h" |
5 | #include "kerncompat.h" | ||
5 | 6 | ||
6 | #define CTREE_BLOCKSIZE 1024 | 7 | #define CTREE_BLOCKSIZE 1024 |
7 | 8 | ||
@@ -14,8 +15,18 @@ | |||
14 | * may point to extents. | 15 | * may point to extents. |
15 | * | 16 | * |
16 | * offset is the starting byte offset for this key in the stream. | 17 | * offset is the starting byte offset for this key in the stream. |
18 | * | ||
19 | * btrfs_disk_key is in disk byte order. struct btrfs_key is always | ||
20 | * in cpu native order. Otherwise they are identical and their sizes | ||
21 | * should be the same (ie both packed) | ||
17 | */ | 22 | */ |
18 | struct key { | 23 | struct btrfs_disk_key { |
24 | __le64 objectid; | ||
25 | __le32 flags; | ||
26 | __le64 offset; | ||
27 | } __attribute__ ((__packed__)); | ||
28 | |||
29 | struct btrfs_key { | ||
19 | u64 objectid; | 30 | u64 objectid; |
20 | u32 flags; | 31 | u32 flags; |
21 | u64 offset; | 32 | u64 offset; |
@@ -37,7 +48,7 @@ struct btrfs_header { | |||
37 | 48 | ||
38 | #define MAX_LEVEL 8 | 49 | #define MAX_LEVEL 8 |
39 | #define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) / \ | 50 | #define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) / \ |
40 | (sizeof(struct key) + sizeof(u64))) | 51 | (sizeof(struct btrfs_disk_key) + sizeof(u64))) |
41 | 52 | ||
42 | struct tree_buffer; | 53 | struct tree_buffer; |
43 | 54 | ||
@@ -50,8 +61,8 @@ struct ctree_root { | |||
50 | struct tree_buffer *node; | 61 | struct tree_buffer *node; |
51 | struct tree_buffer *commit_root; | 62 | struct tree_buffer *commit_root; |
52 | struct ctree_root *extent_root; | 63 | struct ctree_root *extent_root; |
53 | struct key current_insert; | 64 | struct btrfs_key current_insert; |
54 | struct key last_insert; | 65 | struct btrfs_key last_insert; |
55 | int fp; | 66 | int fp; |
56 | struct radix_tree_root cache_radix; | 67 | struct radix_tree_root cache_radix; |
57 | struct radix_tree_root pinned_radix; | 68 | struct radix_tree_root pinned_radix; |
@@ -88,7 +99,7 @@ struct ctree_super_block { | |||
88 | * the item in the leaf (relative to the start of the data area) | 99 | * the item in the leaf (relative to the start of the data area) |
89 | */ | 100 | */ |
90 | struct item { | 101 | struct item { |
91 | struct key key; | 102 | struct btrfs_disk_key key; |
92 | u16 offset; | 103 | u16 offset; |
93 | u16 size; | 104 | u16 size; |
94 | } __attribute__ ((__packed__)); | 105 | } __attribute__ ((__packed__)); |
@@ -115,7 +126,7 @@ struct leaf { | |||
115 | */ | 126 | */ |
116 | struct node { | 127 | struct node { |
117 | struct btrfs_header header; | 128 | struct btrfs_header header; |
118 | struct key keys[NODEPTRS_PER_BLOCK]; | 129 | struct btrfs_disk_key keys[NODEPTRS_PER_BLOCK]; |
119 | u64 blockptrs[NODEPTRS_PER_BLOCK]; | 130 | u64 blockptrs[NODEPTRS_PER_BLOCK]; |
120 | } __attribute__ ((__packed__)); | 131 | } __attribute__ ((__packed__)); |
121 | 132 | ||
@@ -141,6 +152,55 @@ struct ctree_path { | |||
141 | int slots[MAX_LEVEL]; | 152 | int slots[MAX_LEVEL]; |
142 | }; | 153 | }; |
143 | 154 | ||
155 | static inline void btrfs_disk_key_to_cpu(struct btrfs_key *cpu, | ||
156 | struct btrfs_disk_key *disk) | ||
157 | { | ||
158 | cpu->offset = le64_to_cpu(disk->offset); | ||
159 | cpu->flags = le32_to_cpu(disk->flags); | ||
160 | cpu->objectid = le64_to_cpu(disk->objectid); | ||
161 | } | ||
162 | |||
163 | static inline void btrfs_cpu_key_to_disk(struct btrfs_disk_key *disk, | ||
164 | struct btrfs_key *cpu) | ||
165 | { | ||
166 | disk->offset = cpu_to_le64(cpu->offset); | ||
167 | disk->flags = cpu_to_le32(cpu->flags); | ||
168 | disk->objectid = cpu_to_le64(cpu->objectid); | ||
169 | } | ||
170 | |||
171 | static inline u64 btrfs_key_objectid(struct btrfs_disk_key *disk) | ||
172 | { | ||
173 | return le64_to_cpu(disk->objectid); | ||
174 | } | ||
175 | |||
176 | static inline void btrfs_set_key_objectid(struct btrfs_disk_key *disk, | ||
177 | u64 val) | ||
178 | { | ||
179 | disk->objectid = cpu_to_le64(val); | ||
180 | } | ||
181 | |||
182 | static inline u64 btrfs_key_offset(struct btrfs_disk_key *disk) | ||
183 | { | ||
184 | return le64_to_cpu(disk->offset); | ||
185 | } | ||
186 | |||
187 | static inline void btrfs_set_key_offset(struct btrfs_disk_key *disk, | ||
188 | u64 val) | ||
189 | { | ||
190 | disk->offset = cpu_to_le64(val); | ||
191 | } | ||
192 | |||
193 | static inline u32 btrfs_key_flags(struct btrfs_disk_key *disk) | ||
194 | { | ||
195 | return le32_to_cpu(disk->flags); | ||
196 | } | ||
197 | |||
198 | static inline void btrfs_set_key_flags(struct btrfs_disk_key *disk, | ||
199 | u32 val) | ||
200 | { | ||
201 | disk->flags = cpu_to_le32(val); | ||
202 | } | ||
203 | |||
144 | static inline u64 btrfs_header_blocknr(struct btrfs_header *h) | 204 | static inline u64 btrfs_header_blocknr(struct btrfs_header *h) |
145 | { | 205 | { |
146 | return le64_to_cpu(h->blocknr); | 206 | return le64_to_cpu(h->blocknr); |
@@ -203,11 +263,13 @@ static inline int btrfs_is_leaf(struct node *n) | |||
203 | struct tree_buffer *alloc_free_block(struct ctree_root *root); | 263 | struct tree_buffer *alloc_free_block(struct ctree_root *root); |
204 | int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf); | 264 | int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf); |
205 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks); | 265 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks); |
206 | int search_slot(struct ctree_root *root, struct key *key, struct ctree_path *p, int ins_len, int cow); | 266 | int search_slot(struct ctree_root *root, struct btrfs_key *key, |
267 | struct ctree_path *p, int ins_len, int cow); | ||
207 | void release_path(struct ctree_root *root, struct ctree_path *p); | 268 | void release_path(struct ctree_root *root, struct ctree_path *p); |
208 | void init_path(struct ctree_path *p); | 269 | void init_path(struct ctree_path *p); |
209 | int del_item(struct ctree_root *root, struct ctree_path *path); | 270 | int del_item(struct ctree_root *root, struct ctree_path *path); |
210 | int insert_item(struct ctree_root *root, struct key *key, void *data, int data_size); | 271 | int insert_item(struct ctree_root *root, struct btrfs_key *key, |
272 | void *data, int data_size); | ||
211 | int next_leaf(struct ctree_root *root, struct ctree_path *path); | 273 | int next_leaf(struct ctree_root *root, struct ctree_path *path); |
212 | int leaf_free_space(struct leaf *leaf); | 274 | int leaf_free_space(struct leaf *leaf); |
213 | int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap); | 275 | int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap); |
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 524c11fea24a..475e72215964 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -7,7 +7,8 @@ | |||
7 | #include "print-tree.h" | 7 | #include "print-tree.h" |
8 | 8 | ||
9 | static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, | 9 | static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, |
10 | u64 search_start, u64 search_end, struct key *ins); | 10 | u64 search_start, u64 search_end, |
11 | struct btrfs_key *ins); | ||
11 | static int finish_current_insert(struct ctree_root *extent_root); | 12 | static int finish_current_insert(struct ctree_root *extent_root); |
12 | static int run_pending(struct ctree_root *extent_root); | 13 | static int run_pending(struct ctree_root *extent_root); |
13 | 14 | ||
@@ -24,10 +25,10 @@ static int inc_block_ref(struct ctree_root *root, u64 blocknr) | |||
24 | { | 25 | { |
25 | struct ctree_path path; | 26 | struct ctree_path path; |
26 | int ret; | 27 | int ret; |
27 | struct key key; | 28 | struct btrfs_key key; |
28 | struct leaf *l; | 29 | struct leaf *l; |
29 | struct extent_item *item; | 30 | struct extent_item *item; |
30 | struct key ins; | 31 | struct btrfs_key ins; |
31 | 32 | ||
32 | find_free_extent(root->extent_root, 0, 0, (u64)-1, &ins); | 33 | find_free_extent(root->extent_root, 0, 0, (u64)-1, &ins); |
33 | init_path(&path); | 34 | init_path(&path); |
@@ -54,7 +55,7 @@ static int lookup_block_ref(struct ctree_root *root, u64 blocknr, u32 *refs) | |||
54 | { | 55 | { |
55 | struct ctree_path path; | 56 | struct ctree_path path; |
56 | int ret; | 57 | int ret; |
57 | struct key key; | 58 | struct btrfs_key key; |
58 | struct leaf *l; | 59 | struct leaf *l; |
59 | struct extent_item *item; | 60 | struct extent_item *item; |
60 | init_path(&path); | 61 | init_path(&path); |
@@ -113,7 +114,7 @@ int btrfs_finish_extent_commit(struct ctree_root *root) | |||
113 | 114 | ||
114 | static int finish_current_insert(struct ctree_root *extent_root) | 115 | static int finish_current_insert(struct ctree_root *extent_root) |
115 | { | 116 | { |
116 | struct key ins; | 117 | struct btrfs_key ins; |
117 | struct extent_item extent_item; | 118 | struct extent_item extent_item; |
118 | int i; | 119 | int i; |
119 | int ret; | 120 | int ret; |
@@ -140,12 +141,12 @@ static int finish_current_insert(struct ctree_root *extent_root) | |||
140 | int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) | 141 | int __free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) |
141 | { | 142 | { |
142 | struct ctree_path path; | 143 | struct ctree_path path; |
143 | struct key key; | 144 | struct btrfs_key key; |
144 | struct ctree_root *extent_root = root->extent_root; | 145 | struct ctree_root *extent_root = root->extent_root; |
145 | int ret; | 146 | int ret; |
146 | struct item *item; | 147 | struct item *item; |
147 | struct extent_item *ei; | 148 | struct extent_item *ei; |
148 | struct key ins; | 149 | struct btrfs_key ins; |
149 | 150 | ||
150 | key.objectid = blocknr; | 151 | key.objectid = blocknr; |
151 | key.flags = 0; | 152 | key.flags = 0; |
@@ -227,7 +228,7 @@ static int run_pending(struct ctree_root *extent_root) | |||
227 | */ | 228 | */ |
228 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) | 229 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) |
229 | { | 230 | { |
230 | struct key key; | 231 | struct btrfs_key key; |
231 | struct ctree_root *extent_root = root->extent_root; | 232 | struct ctree_root *extent_root = root->extent_root; |
232 | struct tree_buffer *t; | 233 | struct tree_buffer *t; |
233 | int pending_ret; | 234 | int pending_ret; |
@@ -256,10 +257,11 @@ int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks) | |||
256 | * Any available blocks before search_start are skipped. | 257 | * Any available blocks before search_start are skipped. |
257 | */ | 258 | */ |
258 | static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, | 259 | static int find_free_extent(struct ctree_root *orig_root, u64 num_blocks, |
259 | u64 search_start, u64 search_end, struct key *ins) | 260 | u64 search_start, u64 search_end, |
261 | struct btrfs_key *ins) | ||
260 | { | 262 | { |
261 | struct ctree_path path; | 263 | struct ctree_path path; |
262 | struct key *key; | 264 | struct btrfs_key key; |
263 | int ret; | 265 | int ret; |
264 | u64 hole_size = 0; | 266 | u64 hole_size = 0; |
265 | int slot = 0; | 267 | int slot = 0; |
@@ -306,12 +308,12 @@ check_failed: | |||
306 | ins->offset = (u64)-1; | 308 | ins->offset = (u64)-1; |
307 | goto check_pending; | 309 | goto check_pending; |
308 | } | 310 | } |
309 | key = &l->items[slot].key; | 311 | btrfs_disk_key_to_cpu(&key, &l->items[slot].key); |
310 | if (key->objectid >= search_start) { | 312 | if (key.objectid >= search_start) { |
311 | if (start_found) { | 313 | if (start_found) { |
312 | if (last_block < search_start) | 314 | if (last_block < search_start) |
313 | last_block = search_start; | 315 | last_block = search_start; |
314 | hole_size = key->objectid - last_block; | 316 | hole_size = key.objectid - last_block; |
315 | if (hole_size > total_needed) { | 317 | if (hole_size > total_needed) { |
316 | ins->objectid = last_block; | 318 | ins->objectid = last_block; |
317 | ins->offset = hole_size; | 319 | ins->offset = hole_size; |
@@ -320,7 +322,7 @@ check_failed: | |||
320 | } | 322 | } |
321 | } | 323 | } |
322 | start_found = 1; | 324 | start_found = 1; |
323 | last_block = key->objectid + key->offset; | 325 | last_block = key.objectid + key.offset; |
324 | path.slots[0]++; | 326 | path.slots[0]++; |
325 | } | 327 | } |
326 | // FIXME -ENOSPC | 328 | // FIXME -ENOSPC |
@@ -357,7 +359,7 @@ error: | |||
357 | * returns 0 if everything worked, non-zero otherwise. | 359 | * returns 0 if everything worked, non-zero otherwise. |
358 | */ | 360 | */ |
359 | int alloc_extent(struct ctree_root *root, u64 num_blocks, u64 search_start, | 361 | int alloc_extent(struct ctree_root *root, u64 num_blocks, u64 search_start, |
360 | u64 search_end, u64 owner, struct key *ins) | 362 | u64 search_end, u64 owner, struct btrfs_key *ins) |
361 | { | 363 | { |
362 | int ret; | 364 | int ret; |
363 | int pending_ret; | 365 | int pending_ret; |
@@ -400,7 +402,7 @@ int alloc_extent(struct ctree_root *root, u64 num_blocks, u64 search_start, | |||
400 | */ | 402 | */ |
401 | struct tree_buffer *alloc_free_block(struct ctree_root *root) | 403 | struct tree_buffer *alloc_free_block(struct ctree_root *root) |
402 | { | 404 | { |
403 | struct key ins; | 405 | struct btrfs_key ins; |
404 | int ret; | 406 | int ret; |
405 | struct tree_buffer *buf; | 407 | struct tree_buffer *buf; |
406 | 408 | ||
diff --git a/fs/btrfs/kerncompat.h b/fs/btrfs/kerncompat.h index 54cf70eaa01f..56239b922ba6 100644 --- a/fs/btrfs/kerncompat.h +++ b/fs/btrfs/kerncompat.h | |||
@@ -69,8 +69,6 @@ static inline void __clear_bit(int bit, unsigned long *map) { | |||
69 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ | 69 | const typeof( ((type *)0)->member ) *__mptr = (ptr); \ |
70 | (type *)( (char *)__mptr - __builtin_offsetof(type,member) );}) | 70 | (type *)( (char *)__mptr - __builtin_offsetof(type,member) );}) |
71 | 71 | ||
72 | #endif | ||
73 | |||
74 | #define ENOMEM 5 | 72 | #define ENOMEM 5 |
75 | #define EEXIST 6 | 73 | #define EEXIST 6 |
76 | 74 | ||
@@ -94,3 +92,4 @@ typedef u64 __bitwise __be64; | |||
94 | #define le32_to_cpu(x) ((__force u32)(__le32)(x)) | 92 | #define le32_to_cpu(x) ((__force u32)(__le32)(x)) |
95 | #define cpu_to_le16(x) ((__force __le16)(u16)(x)) | 93 | #define cpu_to_le16(x) ((__force __le16)(u16)(x)) |
96 | #define le16_to_cpu(x) ((__force u16)(__le16)(x)) | 94 | #define le16_to_cpu(x) ((__force u16)(__le16)(x)) |
95 | #endif | ||
diff --git a/fs/btrfs/mkfs.c b/fs/btrfs/mkfs.c index b2ba94696297..5290423343f8 100644 --- a/fs/btrfs/mkfs.c +++ b/fs/btrfs/mkfs.c | |||
@@ -45,9 +45,9 @@ int mkfs(int fd) | |||
45 | btrfs_set_header_nritems(&empty_leaf.header, 3); | 45 | btrfs_set_header_nritems(&empty_leaf.header, 3); |
46 | 46 | ||
47 | /* item1, reserve blocks 0-16 */ | 47 | /* item1, reserve blocks 0-16 */ |
48 | item.key.objectid = 0; | 48 | item.key.objectid = cpu_to_le64(0); |
49 | item.key.offset = 17; | 49 | item.key.offset = cpu_to_le64(17); |
50 | item.key.flags = 0; | 50 | item.key.flags = cpu_to_le32(0); |
51 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item); | 51 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item); |
52 | item.size = sizeof(struct extent_item); | 52 | item.size = sizeof(struct extent_item); |
53 | extent_item.refs = 1; | 53 | extent_item.refs = 1; |
@@ -56,16 +56,16 @@ int mkfs(int fd) | |||
56 | memcpy(empty_leaf.data + item.offset, &extent_item, item.size); | 56 | memcpy(empty_leaf.data + item.offset, &extent_item, item.size); |
57 | 57 | ||
58 | /* item2, give block 17 to the root */ | 58 | /* item2, give block 17 to the root */ |
59 | item.key.objectid = 17; | 59 | item.key.objectid = cpu_to_le64(17); |
60 | item.key.offset = 1; | 60 | item.key.offset = cpu_to_le64(1); |
61 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item) * 2; | 61 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item) * 2; |
62 | extent_item.owner = 1; | 62 | extent_item.owner = 1; |
63 | memcpy(empty_leaf.items + 1, &item, sizeof(item)); | 63 | memcpy(empty_leaf.items + 1, &item, sizeof(item)); |
64 | memcpy(empty_leaf.data + item.offset, &extent_item, item.size); | 64 | memcpy(empty_leaf.data + item.offset, &extent_item, item.size); |
65 | 65 | ||
66 | /* item3, give block 18 for the extent root */ | 66 | /* item3, give block 18 for the extent root */ |
67 | item.key.objectid = 18; | 67 | item.key.objectid = cpu_to_le64(18); |
68 | item.key.offset = 1; | 68 | item.key.offset = cpu_to_le64(1); |
69 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item) * 3; | 69 | item.offset = LEAF_DATA_SIZE - sizeof(struct extent_item) * 3; |
70 | extent_item.owner = 2; | 70 | extent_item.owner = 2; |
71 | memcpy(empty_leaf.items + 2, &item, sizeof(item)); | 71 | memcpy(empty_leaf.items + 2, &item, sizeof(item)); |
diff --git a/fs/btrfs/quick-test.c b/fs/btrfs/quick-test.c index 07fd71b77627..ab3bda53a2f6 100644 --- a/fs/btrfs/quick-test.c +++ b/fs/btrfs/quick-test.c | |||
@@ -13,8 +13,8 @@ int next_key(int i, int max_key) { | |||
13 | } | 13 | } |
14 | 14 | ||
15 | int main(int ac, char **av) { | 15 | int main(int ac, char **av) { |
16 | struct key ins; | 16 | struct btrfs_key ins; |
17 | struct key last = { (u64)-1, 0, 0}; | 17 | struct btrfs_key last = { (u64)-1, 0, 0}; |
18 | char *buf; | 18 | char *buf; |
19 | int i; | 19 | int i; |
20 | int num; | 20 | int num; |
@@ -146,7 +146,7 @@ int main(int ac, char **av) { | |||
146 | slot = path.slots[0]; | 146 | slot = path.slots[0]; |
147 | leaf = &path.nodes[0]->leaf; | 147 | leaf = &path.nodes[0]->leaf; |
148 | 148 | ||
149 | memcpy(&last, &leaf->items[slot].key, sizeof(last)); | 149 | btrfs_disk_key_to_cpu(&last, &leaf->items[slot].key); |
150 | if (tree_size % 10000 == 0) | 150 | if (tree_size % 10000 == 0) |
151 | printf("big del %d:%d\n", tree_size, i); | 151 | printf("big del %d:%d\n", tree_size, i); |
152 | ret = del_item(root, &path); | 152 | ret = del_item(root, &path); |
diff --git a/fs/btrfs/random-test.c b/fs/btrfs/random-test.c index 5d99b730a69c..34a15841ebd3 100644 --- a/fs/btrfs/random-test.c +++ b/fs/btrfs/random-test.c | |||
@@ -10,7 +10,8 @@ | |||
10 | int keep_running = 1; | 10 | int keep_running = 1; |
11 | struct ctree_super_block super; | 11 | struct ctree_super_block super; |
12 | 12 | ||
13 | static int setup_key(struct radix_tree_root *root, struct key *key, int exists) | 13 | static int setup_key(struct radix_tree_root *root, struct btrfs_key *key, |
14 | int exists) | ||
14 | { | 15 | { |
15 | int num = rand(); | 16 | int num = rand(); |
16 | unsigned long res[2]; | 17 | unsigned long res[2]; |
@@ -38,7 +39,7 @@ again: | |||
38 | static int ins_one(struct ctree_root *root, struct radix_tree_root *radix) | 39 | static int ins_one(struct ctree_root *root, struct radix_tree_root *radix) |
39 | { | 40 | { |
40 | struct ctree_path path; | 41 | struct ctree_path path; |
41 | struct key key; | 42 | struct btrfs_key key; |
42 | int ret; | 43 | int ret; |
43 | char buf[128]; | 44 | char buf[128]; |
44 | unsigned long oid; | 45 | unsigned long oid; |
@@ -63,7 +64,7 @@ error: | |||
63 | static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix) | 64 | static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix) |
64 | { | 65 | { |
65 | struct ctree_path path; | 66 | struct ctree_path path; |
66 | struct key key; | 67 | struct btrfs_key key; |
67 | int ret; | 68 | int ret; |
68 | char buf[128]; | 69 | char buf[128]; |
69 | init_path(&path); | 70 | init_path(&path); |
@@ -82,7 +83,7 @@ static int insert_dup(struct ctree_root *root, struct radix_tree_root *radix) | |||
82 | static int del_one(struct ctree_root *root, struct radix_tree_root *radix) | 83 | static int del_one(struct ctree_root *root, struct radix_tree_root *radix) |
83 | { | 84 | { |
84 | struct ctree_path path; | 85 | struct ctree_path path; |
85 | struct key key; | 86 | struct btrfs_key key; |
86 | int ret; | 87 | int ret; |
87 | unsigned long *ptr; | 88 | unsigned long *ptr; |
88 | init_path(&path); | 89 | init_path(&path); |
@@ -108,7 +109,7 @@ error: | |||
108 | static int lookup_item(struct ctree_root *root, struct radix_tree_root *radix) | 109 | static int lookup_item(struct ctree_root *root, struct radix_tree_root *radix) |
109 | { | 110 | { |
110 | struct ctree_path path; | 111 | struct ctree_path path; |
111 | struct key key; | 112 | struct btrfs_key key; |
112 | int ret; | 113 | int ret; |
113 | init_path(&path); | 114 | init_path(&path); |
114 | ret = setup_key(radix, &key, 1); | 115 | ret = setup_key(radix, &key, 1); |
@@ -127,7 +128,7 @@ error: | |||
127 | static int lookup_enoent(struct ctree_root *root, struct radix_tree_root *radix) | 128 | static int lookup_enoent(struct ctree_root *root, struct radix_tree_root *radix) |
128 | { | 129 | { |
129 | struct ctree_path path; | 130 | struct ctree_path path; |
130 | struct key key; | 131 | struct btrfs_key key; |
131 | int ret; | 132 | int ret; |
132 | init_path(&path); | 133 | init_path(&path); |
133 | ret = setup_key(radix, &key, 0); | 134 | ret = setup_key(radix, &key, 0); |
@@ -147,7 +148,7 @@ static int empty_tree(struct ctree_root *root, struct radix_tree_root *radix, | |||
147 | int nr) | 148 | int nr) |
148 | { | 149 | { |
149 | struct ctree_path path; | 150 | struct ctree_path path; |
150 | struct key key; | 151 | struct btrfs_key key; |
151 | unsigned long found = 0; | 152 | unsigned long found = 0; |
152 | int ret; | 153 | int ret; |
153 | int slot; | 154 | int slot; |
@@ -248,7 +249,7 @@ int (*ops[])(struct ctree_root *root, struct radix_tree_root *radix) = | |||
248 | static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix) | 249 | static int fill_radix(struct ctree_root *root, struct radix_tree_root *radix) |
249 | { | 250 | { |
250 | struct ctree_path path; | 251 | struct ctree_path path; |
251 | struct key key; | 252 | struct btrfs_key key; |
252 | unsigned long found; | 253 | unsigned long found; |
253 | int ret; | 254 | int ret; |
254 | int slot; | 255 | int slot; |