Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 1 | #include <linux/err.h> |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 2 | #include <linux/gfp.h> |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 3 | #include <linux/slab.h> |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 4 | #include <linux/module.h> |
| 5 | #include <linux/spinlock.h> |
Jens Axboe | 0a2118d | 2007-10-19 09:23:05 -0400 | [diff] [blame] | 6 | #include <linux/version.h> |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 7 | #include <linux/hardirq.h> |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 8 | #include "extent_map.h" |
| 9 | |
Chris Mason | 86479a0 | 2007-09-10 19:58:16 -0400 | [diff] [blame] | 10 | /* temporary define until extent_map moves out of btrfs */ |
| 11 | struct kmem_cache *btrfs_cache_create(const char *name, size_t size, |
| 12 | unsigned long extra_flags, |
| 13 | void (*ctor)(void *, struct kmem_cache *, |
| 14 | unsigned long)); |
| 15 | |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 16 | static struct kmem_cache *extent_map_cache; |
Chris Mason | ca66462 | 2007-11-27 11:16:35 -0500 | [diff] [blame] | 17 | |
Wyatt Banks | 2f4cbe6 | 2007-11-19 10:22:33 -0500 | [diff] [blame] | 18 | int __init extent_map_init(void) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 19 | { |
Chris Mason | 86479a0 | 2007-09-10 19:58:16 -0400 | [diff] [blame] | 20 | extent_map_cache = btrfs_cache_create("extent_map", |
Chris Mason | 6d36dcd | 2007-10-15 16:14:37 -0400 | [diff] [blame] | 21 | sizeof(struct extent_map), 0, |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 22 | NULL); |
Wyatt Banks | 2f4cbe6 | 2007-11-19 10:22:33 -0500 | [diff] [blame] | 23 | if (!extent_map_cache) |
| 24 | return -ENOMEM; |
Wyatt Banks | 2f4cbe6 | 2007-11-19 10:22:33 -0500 | [diff] [blame] | 25 | return 0; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 26 | } |
| 27 | |
Christian Hesse | 17636e0 | 2007-12-11 09:25:06 -0500 | [diff] [blame] | 28 | void extent_map_exit(void) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 29 | { |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 30 | if (extent_map_cache) |
| 31 | kmem_cache_destroy(extent_map_cache); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 32 | } |
| 33 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 34 | /** |
| 35 | * extent_map_tree_init - initialize extent map tree |
| 36 | * @tree: tree to initialize |
| 37 | * @mask: flags for memory allocations during tree operations |
| 38 | * |
| 39 | * Initialize the extent tree @tree. Should be called for each new inode |
| 40 | * or other user of the extent_map interface. |
| 41 | */ |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 42 | void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 43 | { |
| 44 | tree->map.rb_node = NULL; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 45 | spin_lock_init(&tree->lock); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 46 | } |
| 47 | EXPORT_SYMBOL(extent_map_tree_init); |
| 48 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 49 | /** |
| 50 | * alloc_extent_map - allocate new extent map structure |
| 51 | * @mask: memory allocation flags |
| 52 | * |
| 53 | * Allocate a new extent_map structure. The new structure is |
| 54 | * returned with a reference count of one and needs to be |
| 55 | * freed using free_extent_map() |
| 56 | */ |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 57 | struct extent_map *alloc_extent_map(gfp_t mask) |
| 58 | { |
| 59 | struct extent_map *em; |
| 60 | em = kmem_cache_alloc(extent_map_cache, mask); |
| 61 | if (!em || IS_ERR(em)) |
| 62 | return em; |
| 63 | em->in_tree = 0; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 64 | em->flags = 0; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 65 | atomic_set(&em->refs, 1); |
| 66 | return em; |
| 67 | } |
| 68 | EXPORT_SYMBOL(alloc_extent_map); |
| 69 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 70 | /** |
| 71 | * free_extent_map - drop reference count of an extent_map |
| 72 | * @em: extent map beeing releasead |
| 73 | * |
| 74 | * Drops the reference out on @em by one and free the structure |
| 75 | * if the reference count hits zero. |
| 76 | */ |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 77 | void free_extent_map(struct extent_map *em) |
| 78 | { |
Chris Mason | 2bf5a72 | 2007-08-30 11:54:02 -0400 | [diff] [blame] | 79 | if (!em) |
| 80 | return; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 81 | WARN_ON(atomic_read(&em->refs) == 0); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 82 | if (atomic_dec_and_test(&em->refs)) { |
| 83 | WARN_ON(em->in_tree); |
| 84 | kmem_cache_free(extent_map_cache, em); |
| 85 | } |
| 86 | } |
| 87 | EXPORT_SYMBOL(free_extent_map); |
| 88 | |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 89 | static struct rb_node *tree_insert(struct rb_root *root, u64 offset, |
| 90 | struct rb_node *node) |
| 91 | { |
| 92 | struct rb_node ** p = &root->rb_node; |
| 93 | struct rb_node * parent = NULL; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 94 | struct extent_map *entry; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 95 | |
| 96 | while(*p) { |
| 97 | parent = *p; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 98 | entry = rb_entry(parent, struct extent_map, rb_node); |
| 99 | |
| 100 | WARN_ON(!entry->in_tree); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 101 | |
| 102 | if (offset < entry->start) |
| 103 | p = &(*p)->rb_left; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 104 | else if (offset >= extent_map_end(entry)) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 105 | p = &(*p)->rb_right; |
| 106 | else |
| 107 | return parent; |
| 108 | } |
| 109 | |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 110 | entry = rb_entry(node, struct extent_map, rb_node); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 111 | entry->in_tree = 1; |
| 112 | rb_link_node(node, parent, p); |
| 113 | rb_insert_color(node, root); |
| 114 | return NULL; |
| 115 | } |
| 116 | |
| 117 | static struct rb_node *__tree_search(struct rb_root *root, u64 offset, |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 118 | struct rb_node **prev_ret, |
| 119 | struct rb_node **next_ret) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 120 | { |
| 121 | struct rb_node * n = root->rb_node; |
| 122 | struct rb_node *prev = NULL; |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 123 | struct rb_node *orig_prev = NULL; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 124 | struct extent_map *entry; |
| 125 | struct extent_map *prev_entry = NULL; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 126 | |
| 127 | while(n) { |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 128 | entry = rb_entry(n, struct extent_map, rb_node); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 129 | prev = n; |
| 130 | prev_entry = entry; |
| 131 | |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 132 | WARN_ON(!entry->in_tree); |
| 133 | |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 134 | if (offset < entry->start) |
| 135 | n = n->rb_left; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 136 | else if (offset >= extent_map_end(entry)) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 137 | n = n->rb_right; |
| 138 | else |
| 139 | return n; |
| 140 | } |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 141 | |
| 142 | if (prev_ret) { |
| 143 | orig_prev = prev; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 144 | while(prev && offset >= extent_map_end(prev_entry)) { |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 145 | prev = rb_next(prev); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 146 | prev_entry = rb_entry(prev, struct extent_map, rb_node); |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 147 | } |
| 148 | *prev_ret = prev; |
| 149 | prev = orig_prev; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 150 | } |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 151 | |
| 152 | if (next_ret) { |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 153 | prev_entry = rb_entry(prev, struct extent_map, rb_node); |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 154 | while(prev && offset < prev_entry->start) { |
| 155 | prev = rb_prev(prev); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 156 | prev_entry = rb_entry(prev, struct extent_map, rb_node); |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 157 | } |
| 158 | *next_ret = prev; |
| 159 | } |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 160 | return NULL; |
| 161 | } |
| 162 | |
| 163 | static inline struct rb_node *tree_search(struct rb_root *root, u64 offset) |
| 164 | { |
| 165 | struct rb_node *prev; |
| 166 | struct rb_node *ret; |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 167 | ret = __tree_search(root, offset, &prev, NULL); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 168 | if (!ret) |
| 169 | return prev; |
| 170 | return ret; |
| 171 | } |
| 172 | |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 173 | static int mergable_maps(struct extent_map *prev, struct extent_map *next) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 174 | { |
Chris Mason | 7f3c74f | 2008-07-18 12:01:11 -0400 | [diff] [blame] | 175 | if (test_bit(EXTENT_FLAG_PINNED, &prev->flags)) |
| 176 | return 0; |
| 177 | |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 178 | if (extent_map_end(prev) == next->start && |
| 179 | prev->flags == next->flags && |
| 180 | prev->bdev == next->bdev && |
| 181 | ((next->block_start == EXTENT_MAP_HOLE && |
| 182 | prev->block_start == EXTENT_MAP_HOLE) || |
| 183 | (next->block_start == EXTENT_MAP_INLINE && |
| 184 | prev->block_start == EXTENT_MAP_INLINE) || |
| 185 | (next->block_start == EXTENT_MAP_DELALLOC && |
| 186 | prev->block_start == EXTENT_MAP_DELALLOC) || |
| 187 | (next->block_start < EXTENT_MAP_LAST_BYTE - 1 && |
| 188 | next->block_start == extent_map_block_end(prev)))) { |
| 189 | return 1; |
| 190 | } |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 191 | return 0; |
| 192 | } |
| 193 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 194 | /** |
| 195 | * add_extent_mapping - add new extent map to the extent tree |
| 196 | * @tree: tree to insert new map in |
| 197 | * @em: map to insert |
| 198 | * |
| 199 | * Insert @em into @tree or perform a simple forward/backward merge with |
| 200 | * existing mappings. The extent_map struct passed in will be inserted |
| 201 | * into the tree directly, with an additional reference taken, or a |
| 202 | * reference dropped if the merge attempt was sucessfull. |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 203 | */ |
| 204 | int add_extent_mapping(struct extent_map_tree *tree, |
| 205 | struct extent_map *em) |
| 206 | { |
| 207 | int ret = 0; |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 208 | struct extent_map *merge = NULL; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 209 | struct rb_node *rb; |
| 210 | |
David Woodhouse | 64f26f7 | 2008-07-24 10:09:43 -0400 | [diff] [blame^] | 211 | assert_spin_locked(&tree->lock); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 212 | rb = tree_insert(&tree->map, em->start, &em->rb_node); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 213 | if (rb) { |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 214 | ret = -EEXIST; |
Chris Mason | e6dcd2d | 2008-07-17 12:53:50 -0400 | [diff] [blame] | 215 | free_extent_map(merge); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 216 | goto out; |
| 217 | } |
| 218 | atomic_inc(&em->refs); |
| 219 | if (em->start != 0) { |
| 220 | rb = rb_prev(&em->rb_node); |
| 221 | if (rb) |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 222 | merge = rb_entry(rb, struct extent_map, rb_node); |
| 223 | if (rb && mergable_maps(merge, em)) { |
| 224 | em->start = merge->start; |
| 225 | em->len += merge->len; |
| 226 | em->block_start = merge->block_start; |
| 227 | merge->in_tree = 0; |
| 228 | rb_erase(&merge->rb_node, &tree->map); |
| 229 | free_extent_map(merge); |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 230 | } |
| 231 | } |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 232 | rb = rb_next(&em->rb_node); |
| 233 | if (rb) |
| 234 | merge = rb_entry(rb, struct extent_map, rb_node); |
| 235 | if (rb && mergable_maps(em, merge)) { |
| 236 | em->len += merge->len; |
| 237 | rb_erase(&merge->rb_node, &tree->map); |
| 238 | merge->in_tree = 0; |
| 239 | free_extent_map(merge); |
| 240 | } |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 241 | out: |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 242 | return ret; |
| 243 | } |
| 244 | EXPORT_SYMBOL(add_extent_mapping); |
| 245 | |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 246 | static u64 range_end(u64 start, u64 len) |
| 247 | { |
| 248 | if (start + len < start) |
| 249 | return (u64)-1; |
| 250 | return start + len; |
| 251 | } |
| 252 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 253 | /** |
| 254 | * lookup_extent_mapping - lookup extent_map |
| 255 | * @tree: tree to lookup in |
| 256 | * @start: byte offset to start the search |
| 257 | * @len: length of the lookup range |
| 258 | * |
| 259 | * Find and return the first extent_map struct in @tree that intersects the |
| 260 | * [start, len] range. There may be additional objects in the tree that |
| 261 | * intersect, so check the object returned carefully to make sure that no |
| 262 | * additional lookups are needed. |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 263 | */ |
| 264 | struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree, |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 265 | u64 start, u64 len) |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 266 | { |
| 267 | struct extent_map *em; |
| 268 | struct rb_node *rb_node; |
Christoph Hellwig | 306929f | 2008-06-10 10:21:04 -0400 | [diff] [blame] | 269 | struct rb_node *prev = NULL; |
| 270 | struct rb_node *next = NULL; |
| 271 | u64 end = range_end(start, len); |
| 272 | |
David Woodhouse | 64f26f7 | 2008-07-24 10:09:43 -0400 | [diff] [blame^] | 273 | assert_spin_locked(&tree->lock); |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 274 | rb_node = __tree_search(&tree->map, start, &prev, &next); |
| 275 | if (!rb_node && prev) { |
| 276 | em = rb_entry(prev, struct extent_map, rb_node); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 277 | if (end > em->start && start < extent_map_end(em)) |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 278 | goto found; |
| 279 | } |
| 280 | if (!rb_node && next) { |
| 281 | em = rb_entry(next, struct extent_map, rb_node); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 282 | if (end > em->start && start < extent_map_end(em)) |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 283 | goto found; |
| 284 | } |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 285 | if (!rb_node) { |
| 286 | em = NULL; |
| 287 | goto out; |
| 288 | } |
| 289 | if (IS_ERR(rb_node)) { |
| 290 | em = ERR_PTR(PTR_ERR(rb_node)); |
| 291 | goto out; |
| 292 | } |
| 293 | em = rb_entry(rb_node, struct extent_map, rb_node); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 294 | if (end > em->start && start < extent_map_end(em)) |
| 295 | goto found; |
| 296 | |
| 297 | em = NULL; |
| 298 | goto out; |
| 299 | |
Chris Mason | 5f56406 | 2008-01-22 16:47:59 -0500 | [diff] [blame] | 300 | found: |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 301 | atomic_inc(&em->refs); |
| 302 | out: |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 303 | return em; |
| 304 | } |
| 305 | EXPORT_SYMBOL(lookup_extent_mapping); |
| 306 | |
Christoph Hellwig | 9d2423c | 2008-06-11 21:52:17 -0400 | [diff] [blame] | 307 | /** |
| 308 | * remove_extent_mapping - removes an extent_map from the extent tree |
| 309 | * @tree: extent tree to remove from |
| 310 | * @em: extent map beeing removed |
| 311 | * |
| 312 | * Removes @em from @tree. No reference counts are dropped, and no checks |
| 313 | * are done to see if the range is in use |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 314 | */ |
| 315 | int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em) |
| 316 | { |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 317 | int ret = 0; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 318 | |
Chris Mason | 7f3c74f | 2008-07-18 12:01:11 -0400 | [diff] [blame] | 319 | WARN_ON(test_bit(EXTENT_FLAG_PINNED, &em->flags)); |
David Woodhouse | 64f26f7 | 2008-07-24 10:09:43 -0400 | [diff] [blame^] | 320 | assert_spin_locked(&tree->lock); |
Chris Mason | d1310b2 | 2008-01-24 16:13:08 -0500 | [diff] [blame] | 321 | rb_erase(&em->rb_node, &tree->map); |
| 322 | em->in_tree = 0; |
Chris Mason | a52d9a8 | 2007-08-27 16:49:44 -0400 | [diff] [blame] | 323 | return ret; |
| 324 | } |
| 325 | EXPORT_SYMBOL(remove_extent_mapping); |