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/btrfs/extent-tree.c | |
parent | bb492bb0a5453222109a72859353728959c2539d (diff) |
Btrfs: struct key endian fixes
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 34 |
1 files changed, 18 insertions, 16 deletions
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 | ||