Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 1 | #include <stdio.h> |
| 2 | #include <stdlib.h> |
| 3 | #include "kerncompat.h" |
| 4 | #include "radix-tree.h" |
| 5 | #include "ctree.h" |
| 6 | #include "disk-io.h" |
| 7 | #include "print-tree.h" |
| 8 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 9 | static int find_free_extent(struct btrfs_root *orig_root, u64 num_blocks, |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 10 | u64 search_start, u64 search_end, |
| 11 | struct btrfs_key *ins); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 12 | static int finish_current_insert(struct btrfs_root *extent_root); |
| 13 | static int run_pending(struct btrfs_root *extent_root); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 14 | |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 15 | /* |
| 16 | * pending extents are blocks that we're trying to allocate in the extent |
| 17 | * map while trying to grow the map because of other allocations. To avoid |
| 18 | * recursing, they are tagged in the radix tree and cleaned up after |
| 19 | * other allocations are done. The pending tag is also used in the same |
| 20 | * manner for deletes. |
| 21 | */ |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 22 | #define CTREE_EXTENT_PENDING_DEL 0 |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 23 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 24 | static int inc_block_ref(struct btrfs_root *root, u64 blocknr) |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 25 | { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 26 | struct btrfs_path path; |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 27 | int ret; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 28 | struct btrfs_key key; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 29 | struct btrfs_leaf *l; |
| 30 | struct btrfs_extent_item *item; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 31 | struct btrfs_key ins; |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 32 | u32 refs; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 33 | |
| 34 | find_free_extent(root->extent_root, 0, 0, (u64)-1, &ins); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 35 | btrfs_init_path(&path); |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 36 | key.objectid = blocknr; |
| 37 | key.flags = 0; |
| 38 | key.offset = 1; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 39 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 1); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 40 | if (ret != 0) |
| 41 | BUG(); |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 42 | BUG_ON(ret != 0); |
| 43 | l = &path.nodes[0]->leaf; |
Chris Mason | 4beb1b8 | 2007-03-14 10:31:29 -0400 | [diff] [blame] | 44 | item = btrfs_item_ptr(l, path.slots[0], struct btrfs_extent_item); |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 45 | refs = btrfs_extent_refs(item); |
| 46 | btrfs_set_extent_refs(item, refs + 1); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 47 | |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 48 | BUG_ON(list_empty(&path.nodes[0]->dirty)); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 49 | btrfs_release_path(root->extent_root, &path); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 50 | finish_current_insert(root->extent_root); |
| 51 | run_pending(root->extent_root); |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 52 | return 0; |
| 53 | } |
| 54 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 55 | static int lookup_block_ref(struct btrfs_root *root, u64 blocknr, u32 *refs) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 56 | { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 57 | struct btrfs_path path; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 58 | int ret; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 59 | struct btrfs_key key; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 60 | struct btrfs_leaf *l; |
| 61 | struct btrfs_extent_item *item; |
| 62 | btrfs_init_path(&path); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 63 | key.objectid = blocknr; |
| 64 | key.flags = 0; |
| 65 | key.offset = 1; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 66 | ret = btrfs_search_slot(root->extent_root, &key, &path, 0, 0); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 67 | if (ret != 0) |
| 68 | BUG(); |
| 69 | l = &path.nodes[0]->leaf; |
Chris Mason | 4beb1b8 | 2007-03-14 10:31:29 -0400 | [diff] [blame] | 70 | item = btrfs_item_ptr(l, path.slots[0], struct btrfs_extent_item); |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 71 | *refs = btrfs_extent_refs(item); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 72 | btrfs_release_path(root->extent_root, &path); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 73 | return 0; |
| 74 | } |
| 75 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 76 | int btrfs_inc_ref(struct btrfs_root *root, struct btrfs_buffer *buf) |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 77 | { |
| 78 | u64 blocknr; |
| 79 | int i; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 80 | |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 81 | if (!root->ref_cows) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 82 | return 0; |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 83 | if (btrfs_is_leaf(&buf->node)) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 84 | return 0; |
| 85 | |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 86 | for (i = 0; i < btrfs_header_nritems(&buf->node.header); i++) { |
Chris Mason | 1d4f8a0 | 2007-03-13 09:28:32 -0400 | [diff] [blame] | 87 | blocknr = btrfs_node_blockptr(&buf->node, i); |
Chris Mason | 02217ed | 2007-03-02 16:08:05 -0500 | [diff] [blame] | 88 | inc_block_ref(root, blocknr); |
| 89 | } |
| 90 | return 0; |
| 91 | } |
| 92 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 93 | int btrfs_finish_extent_commit(struct btrfs_root *root) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 94 | { |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 95 | unsigned long gang[8]; |
| 96 | int ret; |
| 97 | int i; |
| 98 | |
| 99 | while(1) { |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 100 | ret = radix_tree_gang_lookup(&root->pinned_radix, |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 101 | (void **)gang, 0, |
| 102 | ARRAY_SIZE(gang)); |
| 103 | if (!ret) |
| 104 | break; |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 105 | for (i = 0; i < ret; i++) { |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 106 | radix_tree_delete(&root->pinned_radix, gang[i]); |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 107 | } |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 108 | } |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 109 | root->last_insert.objectid = 0; |
| 110 | root->last_insert.offset = 0; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 111 | return 0; |
| 112 | } |
| 113 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 114 | static int finish_current_insert(struct btrfs_root *extent_root) |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 115 | { |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 116 | struct btrfs_key ins; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 117 | struct btrfs_extent_item extent_item; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 118 | int i; |
| 119 | int ret; |
| 120 | |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 121 | btrfs_set_extent_refs(&extent_item, 1); |
| 122 | btrfs_set_extent_owner(&extent_item, |
| 123 | btrfs_header_parentid(&extent_root->node->node.header)); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 124 | ins.offset = 1; |
| 125 | ins.flags = 0; |
| 126 | |
| 127 | for (i = 0; i < extent_root->current_insert.flags; i++) { |
| 128 | ins.objectid = extent_root->current_insert.objectid + i; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 129 | ret = btrfs_insert_item(extent_root, &ins, &extent_item, |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 130 | sizeof(extent_item)); |
| 131 | BUG_ON(ret); |
| 132 | } |
| 133 | extent_root->current_insert.offset = 0; |
| 134 | return 0; |
| 135 | } |
| 136 | |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 137 | /* |
| 138 | * remove an extent from the root, returns 0 on success |
| 139 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 140 | static int __free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 141 | { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 142 | struct btrfs_path path; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 143 | struct btrfs_key key; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 144 | struct btrfs_root *extent_root = root->extent_root; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 145 | int ret; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 146 | struct btrfs_extent_item *ei; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 147 | struct btrfs_key ins; |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 148 | u32 refs; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 149 | |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 150 | key.objectid = blocknr; |
| 151 | key.flags = 0; |
| 152 | key.offset = num_blocks; |
| 153 | |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 154 | find_free_extent(root, 0, 0, (u64)-1, &ins); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 155 | btrfs_init_path(&path); |
| 156 | ret = btrfs_search_slot(extent_root, &key, &path, -1, 1); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 157 | if (ret) { |
| 158 | printf("failed to find %Lu\n", key.objectid); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 159 | btrfs_print_tree(extent_root, extent_root->node); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 160 | printf("failed to find %Lu\n", key.objectid); |
| 161 | BUG(); |
| 162 | } |
Chris Mason | 123abc8 | 2007-03-14 14:14:43 -0400 | [diff] [blame^] | 163 | ei = btrfs_item_ptr(&path.nodes[0]->leaf, path.slots[0], |
| 164 | struct btrfs_extent_item); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 165 | BUG_ON(ei->refs == 0); |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 166 | refs = btrfs_extent_refs(ei) - 1; |
| 167 | btrfs_set_extent_refs(ei, refs); |
| 168 | if (refs == 0) { |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 169 | if (!root->ref_cows) { |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 170 | int err; |
| 171 | radix_tree_preload(GFP_KERNEL); |
| 172 | err = radix_tree_insert(&extent_root->pinned_radix, |
| 173 | blocknr, (void *)blocknr); |
| 174 | BUG_ON(err); |
| 175 | radix_tree_preload_end(); |
| 176 | } |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 177 | ret = btrfs_del_item(extent_root, &path); |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 178 | if (root != extent_root && |
Chris Mason | 7108749 | 2007-03-14 09:20:39 -0400 | [diff] [blame] | 179 | extent_root->last_insert.objectid > blocknr) |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 180 | extent_root->last_insert.objectid = blocknr; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 181 | if (ret) |
| 182 | BUG(); |
| 183 | } |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 184 | btrfs_release_path(extent_root, &path); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 185 | finish_current_insert(extent_root); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 186 | return ret; |
| 187 | } |
| 188 | |
| 189 | /* |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 190 | * find all the blocks marked as pending in the radix tree and remove |
| 191 | * them from the extent map |
| 192 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 193 | static int del_pending_extents(struct btrfs_root *extent_root) |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 194 | { |
| 195 | int ret; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 196 | struct btrfs_buffer *gang[4]; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 197 | int i; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 198 | |
| 199 | while(1) { |
| 200 | ret = radix_tree_gang_lookup_tag(&extent_root->cache_radix, |
| 201 | (void **)gang, 0, |
| 202 | ARRAY_SIZE(gang), |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 203 | CTREE_EXTENT_PENDING_DEL); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 204 | if (!ret) |
| 205 | break; |
| 206 | for (i = 0; i < ret; i++) { |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 207 | ret = __free_extent(extent_root, gang[i]->blocknr, 1); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 208 | radix_tree_tag_clear(&extent_root->cache_radix, |
| 209 | gang[i]->blocknr, |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 210 | CTREE_EXTENT_PENDING_DEL); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 211 | btrfs_block_release(extent_root, gang[i]); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 212 | } |
| 213 | } |
| 214 | return 0; |
| 215 | } |
| 216 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 217 | static int run_pending(struct btrfs_root *extent_root) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 218 | { |
| 219 | while(radix_tree_tagged(&extent_root->cache_radix, |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 220 | CTREE_EXTENT_PENDING_DEL)) |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 221 | del_pending_extents(extent_root); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 222 | return 0; |
| 223 | } |
| 224 | |
| 225 | |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 226 | /* |
| 227 | * remove an extent from the root, returns 0 on success |
| 228 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 229 | int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks) |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 230 | { |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 231 | struct btrfs_key key; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 232 | struct btrfs_root *extent_root = root->extent_root; |
| 233 | struct btrfs_buffer *t; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 234 | int pending_ret; |
| 235 | int ret; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 236 | |
| 237 | if (root == extent_root) { |
| 238 | t = find_tree_block(root, blocknr); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 239 | radix_tree_tag_set(&root->cache_radix, blocknr, |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 240 | CTREE_EXTENT_PENDING_DEL); |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 241 | return 0; |
| 242 | } |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 243 | key.objectid = blocknr; |
| 244 | key.flags = 0; |
| 245 | key.offset = num_blocks; |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 246 | ret = __free_extent(root, blocknr, num_blocks); |
| 247 | pending_ret = run_pending(root->extent_root); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 248 | return ret ? ret : pending_ret; |
| 249 | } |
| 250 | |
| 251 | /* |
| 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: |
| 254 | * ins->objectid == block start |
| 255 | * ins->flags = 0 |
| 256 | * ins->offset == number of blocks |
| 257 | * Any available blocks before search_start are skipped. |
| 258 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 259 | static int find_free_extent(struct btrfs_root *orig_root, u64 num_blocks, |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 260 | u64 search_start, u64 search_end, |
| 261 | struct btrfs_key *ins) |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 262 | { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 263 | struct btrfs_path path; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 264 | struct btrfs_key key; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 265 | int ret; |
| 266 | u64 hole_size = 0; |
| 267 | int slot = 0; |
| 268 | u64 last_block; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 269 | u64 test_block; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 270 | int start_found; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 271 | struct btrfs_leaf *l; |
| 272 | struct btrfs_root * root = orig_root->extent_root; |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 273 | int total_needed = num_blocks; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 274 | |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 275 | total_needed += (btrfs_header_level(&root->node->node.header) + 1) * 3; |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 276 | if (root->last_insert.objectid > search_start) |
| 277 | search_start = root->last_insert.objectid; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 278 | check_failed: |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 279 | btrfs_init_path(&path); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 280 | ins->objectid = search_start; |
| 281 | ins->offset = 0; |
| 282 | ins->flags = 0; |
| 283 | start_found = 0; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 284 | ret = btrfs_search_slot(root, ins, &path, 0, 0); |
Chris Mason | 0f70abe | 2007-02-28 16:46:22 -0500 | [diff] [blame] | 285 | if (ret < 0) |
| 286 | goto error; |
Chris Mason | aa5d6be | 2007-02-28 16:35:06 -0500 | [diff] [blame] | 287 | |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 288 | if (path.slots[0] > 0) |
| 289 | path.slots[0]--; |
| 290 | |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 291 | while (1) { |
| 292 | l = &path.nodes[0]->leaf; |
| 293 | slot = path.slots[0]; |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 294 | if (slot >= btrfs_header_nritems(&l->header)) { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 295 | ret = btrfs_next_leaf(root, &path); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 296 | if (ret == 0) |
| 297 | continue; |
Chris Mason | 0f70abe | 2007-02-28 16:46:22 -0500 | [diff] [blame] | 298 | if (ret < 0) |
| 299 | goto error; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 300 | if (!start_found) { |
| 301 | ins->objectid = search_start; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 302 | ins->offset = (u64)-1; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 303 | start_found = 1; |
| 304 | goto check_pending; |
| 305 | } |
| 306 | ins->objectid = last_block > search_start ? |
| 307 | last_block : search_start; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 308 | ins->offset = (u64)-1; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 309 | goto check_pending; |
| 310 | } |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 311 | btrfs_disk_key_to_cpu(&key, &l->items[slot].key); |
| 312 | if (key.objectid >= search_start) { |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 313 | if (start_found) { |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 314 | if (last_block < search_start) |
| 315 | last_block = search_start; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 316 | hole_size = key.objectid - last_block; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 317 | if (hole_size > total_needed) { |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 318 | ins->objectid = last_block; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 319 | ins->offset = hole_size; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 320 | goto check_pending; |
| 321 | } |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 322 | } |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 323 | } |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 324 | start_found = 1; |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 325 | last_block = key.objectid + key.offset; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 326 | path.slots[0]++; |
| 327 | } |
| 328 | // FIXME -ENOSPC |
| 329 | check_pending: |
| 330 | /* we have to make sure we didn't find an extent that has already |
| 331 | * been allocated by the map tree or the original allocation |
| 332 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 333 | btrfs_release_path(root, &path); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 334 | BUG_ON(ins->objectid < search_start); |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 335 | for (test_block = ins->objectid; |
| 336 | test_block < ins->objectid + total_needed; test_block++) { |
| 337 | if (radix_tree_lookup(&root->pinned_radix, test_block)) { |
| 338 | search_start = test_block + 1; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 339 | goto check_failed; |
| 340 | } |
| 341 | } |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 342 | BUG_ON(root->current_insert.offset); |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 343 | root->current_insert.offset = total_needed - num_blocks; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 344 | root->current_insert.objectid = ins->objectid + num_blocks; |
| 345 | root->current_insert.flags = 0; |
Chris Mason | 0579da4 | 2007-03-07 16:15:30 -0500 | [diff] [blame] | 346 | root->last_insert.objectid = ins->objectid; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 347 | ins->offset = num_blocks; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 348 | return 0; |
Chris Mason | 0f70abe | 2007-02-28 16:46:22 -0500 | [diff] [blame] | 349 | error: |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 350 | btrfs_release_path(root, &path); |
Chris Mason | 0f70abe | 2007-02-28 16:46:22 -0500 | [diff] [blame] | 351 | return ret; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | /* |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 355 | * finds a free extent and does all the dirty work required for allocation |
| 356 | * returns the key for the extent through ins, and a tree buffer for |
| 357 | * the first block of the extent through buf. |
| 358 | * |
| 359 | * returns 0 if everything worked, non-zero otherwise. |
| 360 | */ |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 361 | static int alloc_extent(struct btrfs_root *root, u64 num_blocks, |
| 362 | u64 search_start, u64 search_end, u64 owner, |
| 363 | struct btrfs_key *ins) |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 364 | { |
| 365 | int ret; |
| 366 | int pending_ret; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 367 | struct btrfs_root *extent_root = root->extent_root; |
| 368 | struct btrfs_extent_item extent_item; |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 369 | |
Chris Mason | cf27e1e | 2007-03-13 09:49:06 -0400 | [diff] [blame] | 370 | btrfs_set_extent_refs(&extent_item, 1); |
| 371 | btrfs_set_extent_owner(&extent_item, owner); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 372 | |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 373 | if (root == extent_root) { |
| 374 | BUG_ON(extent_root->current_insert.offset == 0); |
| 375 | BUG_ON(num_blocks != 1); |
| 376 | BUG_ON(extent_root->current_insert.flags == |
| 377 | extent_root->current_insert.offset); |
| 378 | ins->offset = 1; |
| 379 | ins->objectid = extent_root->current_insert.objectid + |
| 380 | extent_root->current_insert.flags++; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 381 | return 0; |
| 382 | } |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 383 | ret = find_free_extent(root, num_blocks, search_start, |
| 384 | search_end, ins); |
| 385 | if (ret) |
| 386 | return ret; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 387 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 388 | ret = btrfs_insert_item(extent_root, ins, &extent_item, |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 389 | sizeof(extent_item)); |
| 390 | |
| 391 | finish_current_insert(extent_root); |
| 392 | pending_ret = run_pending(extent_root); |
| 393 | if (ret) |
| 394 | return ret; |
| 395 | if (pending_ret) |
| 396 | return pending_ret; |
| 397 | return 0; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | /* |
| 401 | * helper function to allocate a block for a given tree |
| 402 | * returns the tree buffer or NULL. |
| 403 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 404 | struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_root *root) |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 405 | { |
Chris Mason | e2fa722 | 2007-03-12 16:22:34 -0400 | [diff] [blame] | 406 | struct btrfs_key ins; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 407 | int ret; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 408 | struct btrfs_buffer *buf; |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 409 | |
| 410 | ret = alloc_extent(root, 1, 0, (unsigned long)-1, |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 411 | btrfs_header_parentid(&root->node->node.header), |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 412 | &ins); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 413 | if (ret) { |
| 414 | BUG(); |
| 415 | return NULL; |
| 416 | } |
Chris Mason | 037e639 | 2007-03-07 11:50:24 -0500 | [diff] [blame] | 417 | buf = find_tree_block(root, ins.objectid); |
| 418 | dirty_tree_block(root, buf); |
Chris Mason | fec577f | 2007-02-26 10:40:21 -0500 | [diff] [blame] | 419 | return buf; |
| 420 | } |
Chris Mason | a28ec19 | 2007-03-06 20:08:01 -0500 | [diff] [blame] | 421 | |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 422 | /* |
| 423 | * helper function for drop_snapshot, this walks down the tree dropping ref |
| 424 | * counts as it goes. |
| 425 | */ |
| 426 | static int walk_down_tree(struct btrfs_root *root, |
| 427 | struct btrfs_path *path, int *level) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 428 | { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 429 | struct btrfs_buffer *next; |
| 430 | struct btrfs_buffer *cur; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 431 | u64 blocknr; |
| 432 | int ret; |
| 433 | u32 refs; |
| 434 | |
| 435 | ret = lookup_block_ref(root, path->nodes[*level]->blocknr, &refs); |
| 436 | BUG_ON(ret); |
| 437 | if (refs > 1) |
| 438 | goto out; |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 439 | /* |
| 440 | * walk down to the last node level and free all the leaves |
| 441 | */ |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 442 | while(*level > 0) { |
| 443 | cur = path->nodes[*level]; |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 444 | if (path->slots[*level] >= |
| 445 | btrfs_header_nritems(&cur->node.header)) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 446 | break; |
Chris Mason | 1d4f8a0 | 2007-03-13 09:28:32 -0400 | [diff] [blame] | 447 | blocknr = btrfs_node_blockptr(&cur->node, path->slots[*level]); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 448 | ret = lookup_block_ref(root, blocknr, &refs); |
| 449 | if (refs != 1 || *level == 1) { |
| 450 | path->slots[*level]++; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 451 | ret = btrfs_free_extent(root, blocknr, 1); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 452 | BUG_ON(ret); |
| 453 | continue; |
| 454 | } |
| 455 | BUG_ON(ret); |
| 456 | next = read_tree_block(root, blocknr); |
Chris Mason | 83e15a2 | 2007-03-12 09:03:27 -0400 | [diff] [blame] | 457 | if (path->nodes[*level-1]) |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 458 | btrfs_block_release(root, path->nodes[*level-1]); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 459 | path->nodes[*level-1] = next; |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 460 | *level = btrfs_header_level(&next->node.header); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 461 | path->slots[*level] = 0; |
| 462 | } |
| 463 | out: |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 464 | ret = btrfs_free_extent(root, path->nodes[*level]->blocknr, 1); |
| 465 | btrfs_block_release(root, path->nodes[*level]); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 466 | path->nodes[*level] = NULL; |
| 467 | *level += 1; |
| 468 | BUG_ON(ret); |
| 469 | return 0; |
| 470 | } |
| 471 | |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 472 | /* |
| 473 | * helper for dropping snapshots. This walks back up the tree in the path |
| 474 | * to find the first node higher up where we haven't yet gone through |
| 475 | * all the slots |
| 476 | */ |
| 477 | static int walk_up_tree(struct btrfs_root *root, struct btrfs_path *path, |
| 478 | int *level) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 479 | { |
| 480 | int i; |
| 481 | int slot; |
| 482 | int ret; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 483 | for(i = *level; i < BTRFS_MAX_LEVEL - 1 && path->nodes[i]; i++) { |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 484 | slot = path->slots[i]; |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 485 | if (slot < |
| 486 | btrfs_header_nritems(&path->nodes[i]->node.header)- 1) { |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 487 | path->slots[i]++; |
| 488 | *level = i; |
| 489 | return 0; |
| 490 | } else { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 491 | ret = btrfs_free_extent(root, |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 492 | path->nodes[*level]->blocknr, 1); |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 493 | btrfs_block_release(root, path->nodes[*level]); |
Chris Mason | 83e15a2 | 2007-03-12 09:03:27 -0400 | [diff] [blame] | 494 | path->nodes[*level] = NULL; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 495 | *level = i + 1; |
| 496 | BUG_ON(ret); |
| 497 | } |
| 498 | } |
| 499 | return 1; |
| 500 | } |
| 501 | |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 502 | /* |
| 503 | * drop the reference count on the tree rooted at 'snap'. This traverses |
| 504 | * the tree freeing any blocks that have a ref count of zero after being |
| 505 | * decremented. |
| 506 | */ |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 507 | int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 508 | { |
Chris Mason | 3768f36 | 2007-03-13 16:47:54 -0400 | [diff] [blame] | 509 | int ret = 0; |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 510 | int wret; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 511 | int level; |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 512 | struct btrfs_path path; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 513 | int i; |
| 514 | int orig_level; |
| 515 | |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 516 | btrfs_init_path(&path); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 517 | |
Chris Mason | 7518a23 | 2007-03-12 12:01:18 -0400 | [diff] [blame] | 518 | level = btrfs_header_level(&snap->node.header); |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 519 | orig_level = level; |
| 520 | path.nodes[level] = snap; |
| 521 | path.slots[level] = 0; |
| 522 | while(1) { |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 523 | wret = walk_down_tree(root, &path, &level); |
| 524 | if (wret > 0) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 525 | break; |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 526 | if (wret < 0) |
| 527 | ret = wret; |
| 528 | |
| 529 | wret = walk_up_tree(root, &path, &level); |
| 530 | if (wret > 0) |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 531 | break; |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 532 | if (wret < 0) |
| 533 | ret = wret; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 534 | } |
Chris Mason | 83e15a2 | 2007-03-12 09:03:27 -0400 | [diff] [blame] | 535 | for (i = 0; i <= orig_level; i++) { |
| 536 | if (path.nodes[i]) { |
Chris Mason | 234b63a | 2007-03-13 10:46:10 -0400 | [diff] [blame] | 537 | btrfs_block_release(root, path.nodes[i]); |
Chris Mason | 83e15a2 | 2007-03-12 09:03:27 -0400 | [diff] [blame] | 538 | } |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 539 | } |
Chris Mason | 9aca1d5 | 2007-03-13 11:09:37 -0400 | [diff] [blame] | 540 | return ret; |
Chris Mason | 20524f0 | 2007-03-10 06:35:47 -0500 | [diff] [blame] | 541 | } |