diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-15 12:56:47 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-15 12:56:47 -0400 |
commit | 62e2749e03a855d98855f9ce032dbe72d5fad148 (patch) | |
tree | ed12521d1bde4ac7eda7f917b57b3cab1e76539d /fs/btrfs/extent-tree.c | |
parent | a1516c8921ce2c148b69493e858d95bc79c92f01 (diff) |
Btrfs: Use a chunk of the key flags to record the item type.
Add (untested and simple) directory item code
Fix comp_keys to use the new key ordering
Add btrfs_insert_empty_item
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 | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index d4f1ec328399..c81e14162ef1 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -35,6 +35,7 @@ static int inc_block_ref(struct btrfs_root *root, u64 blocknr) | |||
35 | btrfs_init_path(&path); | 35 | btrfs_init_path(&path); |
36 | key.objectid = blocknr; | 36 | key.objectid = blocknr; |
37 | key.flags = 0; | 37 | key.flags = 0; |
38 | btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); | ||
38 | key.offset = 1; | 39 | key.offset = 1; |
39 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 1); | 40 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 1); |
40 | if (ret != 0) | 41 | if (ret != 0) |
@@ -61,8 +62,9 @@ static int lookup_block_ref(struct btrfs_root *root, u64 blocknr, u32 *refs) | |||
61 | struct btrfs_extent_item *item; | 62 | struct btrfs_extent_item *item; |
62 | btrfs_init_path(&path); | 63 | btrfs_init_path(&path); |
63 | key.objectid = blocknr; | 64 | key.objectid = blocknr; |
64 | key.flags = 0; | ||
65 | key.offset = 1; | 65 | key.offset = 1; |
66 | key.flags = 0; | ||
67 | btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); | ||
66 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 0); | 68 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 0); |
67 | if (ret != 0) | 69 | if (ret != 0) |
68 | BUG(); | 70 | BUG(); |
@@ -123,6 +125,7 @@ static int finish_current_insert(struct btrfs_root *extent_root) | |||
123 | btrfs_header_parentid(&extent_root->node->node.header)); | 125 | btrfs_header_parentid(&extent_root->node->node.header)); |
124 | ins.offset = 1; | 126 | ins.offset = 1; |
125 | ins.flags = 0; | 127 | ins.flags = 0; |
128 | btrfs_set_key_type(&ins, BTRFS_EXTENT_ITEM_KEY); | ||
126 | 129 | ||
127 | for (i = 0; i < extent_root->current_insert.flags; i++) { | 130 | for (i = 0; i < extent_root->current_insert.flags; i++) { |
128 | ins.objectid = extent_root->current_insert.objectid + i; | 131 | ins.objectid = extent_root->current_insert.objectid + i; |
@@ -149,6 +152,7 @@ static int __free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) | |||
149 | 152 | ||
150 | key.objectid = blocknr; | 153 | key.objectid = blocknr; |
151 | key.flags = 0; | 154 | key.flags = 0; |
155 | btrfs_set_key_type(&key, BTRFS_EXTENT_ITEM_KEY); | ||
152 | key.offset = num_blocks; | 156 | key.offset = num_blocks; |
153 | 157 | ||
154 | find_free_extent(root, 0, 0, (u64)-1, &ins); | 158 | find_free_extent(root, 0, 0, (u64)-1, &ins); |
@@ -228,7 +232,6 @@ static int run_pending(struct btrfs_root *extent_root) | |||
228 | */ | 232 | */ |
229 | int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) | 233 | int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) |
230 | { | 234 | { |
231 | struct btrfs_key key; | ||
232 | struct btrfs_root *extent_root = root->extent_root; | 235 | struct btrfs_root *extent_root = root->extent_root; |
233 | struct btrfs_buffer *t; | 236 | struct btrfs_buffer *t; |
234 | int pending_ret; | 237 | int pending_ret; |
@@ -240,9 +243,6 @@ int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) | |||
240 | CTREE_EXTENT_PENDING_DEL); | 243 | CTREE_EXTENT_PENDING_DEL); |
241 | return 0; | 244 | return 0; |
242 | } | 245 | } |
243 | key.objectid = blocknr; | ||
244 | key.flags = 0; | ||
245 | key.offset = num_blocks; | ||
246 | ret = __free_extent(root, blocknr, num_blocks); | 246 | ret = __free_extent(root, blocknr, num_blocks); |
247 | pending_ret = run_pending(root->extent_root); | 247 | pending_ret = run_pending(root->extent_root); |
248 | return ret ? ret : pending_ret; | 248 | return ret ? ret : pending_ret; |
@@ -252,7 +252,7 @@ int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) | |||
252 | * walks the btree of allocated extents and find a hole of a given size. | 252 | * walks the btree of allocated extents and find a hole of a given size. |
253 | * The key ins is changed to record the hole: | 253 | * The key ins is changed to record the hole: |
254 | * ins->objectid == block start | 254 | * ins->objectid == block start |
255 | * ins->flags = 0 | 255 | * ins->flags = BTRFS_EXTENT_ITEM_KEY |
256 | * ins->offset == number of blocks | 256 | * ins->offset == number of blocks |
257 | * Any available blocks before search_start are skipped. | 257 | * Any available blocks before search_start are skipped. |
258 | */ | 258 | */ |
@@ -275,11 +275,14 @@ static int find_free_extent(struct btrfs_root *orig_root, u64 num_blocks, | |||
275 | total_needed += (btrfs_header_level(&root->node->node.header) + 1) * 3; | 275 | total_needed += (btrfs_header_level(&root->node->node.header) + 1) * 3; |
276 | if (root->last_insert.objectid > search_start) | 276 | if (root->last_insert.objectid > search_start) |
277 | search_start = root->last_insert.objectid; | 277 | search_start = root->last_insert.objectid; |
278 | |||
279 | ins->flags = 0; | ||
280 | btrfs_set_key_type(ins, BTRFS_EXTENT_ITEM_KEY); | ||
281 | |||
278 | check_failed: | 282 | check_failed: |
279 | btrfs_init_path(&path); | 283 | btrfs_init_path(&path); |
280 | ins->objectid = search_start; | 284 | ins->objectid = search_start; |
281 | ins->offset = 0; | 285 | ins->offset = 0; |
282 | ins->flags = 0; | ||
283 | start_found = 0; | 286 | start_found = 0; |
284 | ret = btrfs_search_slot(root, ins, &path, 0, 0); | 287 | ret = btrfs_search_slot(root, ins, &path, 0, 0); |
285 | if (ret < 0) | 288 | if (ret < 0) |