aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/btrfs/extent_map.c61
1 files changed, 49 insertions, 12 deletions
diff --git a/fs/btrfs/extent_map.c b/fs/btrfs/extent_map.c
index ba46f7911d99..f5a04eb9a2ac 100644
--- a/fs/btrfs/extent_map.c
+++ b/fs/btrfs/extent_map.c
@@ -31,6 +31,14 @@ void extent_map_exit(void)
31 kmem_cache_destroy(extent_map_cache); 31 kmem_cache_destroy(extent_map_cache);
32} 32}
33 33
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 */
34void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask) 42void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask)
35{ 43{
36 tree->map.rb_node = NULL; 44 tree->map.rb_node = NULL;
@@ -39,6 +47,14 @@ void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask)
39} 47}
40EXPORT_SYMBOL(extent_map_tree_init); 48EXPORT_SYMBOL(extent_map_tree_init);
41 49
50/**
51 * alloc_extent_map - allocate new extent map structure
52 * @mask: memory allocation flags
53 *
54 * Allocate a new extent_map structure. The new structure is
55 * returned with a reference count of one and needs to be
56 * freed using free_extent_map()
57 */
42struct extent_map *alloc_extent_map(gfp_t mask) 58struct extent_map *alloc_extent_map(gfp_t mask)
43{ 59{
44 struct extent_map *em; 60 struct extent_map *em;
@@ -52,6 +68,13 @@ struct extent_map *alloc_extent_map(gfp_t mask)
52} 68}
53EXPORT_SYMBOL(alloc_extent_map); 69EXPORT_SYMBOL(alloc_extent_map);
54 70
71/**
72 * free_extent_map - drop reference count of an extent_map
73 * @em: extent map beeing releasead
74 *
75 * Drops the reference out on @em by one and free the structure
76 * if the reference count hits zero.
77 */
55void free_extent_map(struct extent_map *em) 78void free_extent_map(struct extent_map *em)
56{ 79{
57 if (!em) 80 if (!em)
@@ -166,10 +189,15 @@ static int mergable_maps(struct extent_map *prev, struct extent_map *next)
166 return 0; 189 return 0;
167} 190}
168 191
169/* 192/**
170 * add_extent_mapping tries a simple forward/backward merge with existing 193 * add_extent_mapping - add new extent map to the extent tree
171 * mappings. The extent_map struct passed in will be inserted into 194 * @tree: tree to insert new map in
172 * the tree directly (no copies made, just a reference taken). 195 * @em: map to insert
196 *
197 * Insert @em into @tree or perform a simple forward/backward merge with
198 * existing mappings. The extent_map struct passed in will be inserted
199 * into the tree directly, with an additional reference taken, or a
200 * reference dropped if the merge attempt was sucessfull.
173 */ 201 */
174int add_extent_mapping(struct extent_map_tree *tree, 202int add_extent_mapping(struct extent_map_tree *tree,
175 struct extent_map *em) 203 struct extent_map *em)
@@ -220,11 +248,16 @@ static u64 range_end(u64 start, u64 len)
220 return start + len; 248 return start + len;
221} 249}
222 250
223/* 251/**
224 * lookup_extent_mapping returns the first extent_map struct in the 252 * lookup_extent_mapping - lookup extent_map
225 * tree that intersects the [start, len] range. There may 253 * @tree: tree to lookup in
226 * be additional objects in the tree that intersect, so check the object 254 * @start: byte offset to start the search
227 * returned carefully to make sure you don't need additional lookups. 255 * @len: length of the lookup range
256 *
257 * Find and return the first extent_map struct in @tree that intersects the
258 * [start, len] range. There may be additional objects in the tree that
259 * intersect, so check the object returned carefully to make sure that no
260 * additional lookups are needed.
228 */ 261 */
229struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree, 262struct extent_map *lookup_extent_mapping(struct extent_map_tree *tree,
230 u64 start, u64 len) 263 u64 start, u64 len)
@@ -273,9 +306,13 @@ out:
273} 306}
274EXPORT_SYMBOL(lookup_extent_mapping); 307EXPORT_SYMBOL(lookup_extent_mapping);
275 308
276/* 309/**
277 * removes an extent_map struct from the tree. No reference counts are 310 * remove_extent_mapping - removes an extent_map from the extent tree
278 * dropped, and no checks are done to see if the range is in use 311 * @tree: extent tree to remove from
312 * @em: extent map beeing removed
313 *
314 * Removes @em from @tree. No reference counts are dropped, and no checks
315 * are done to see if the range is in use
279 */ 316 */
280int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em) 317int remove_extent_mapping(struct extent_map_tree *tree, struct extent_map *em)
281{ 318{