Btrfs: clean up search_extent_mapping()
[firefly-linux-kernel-4.4.55.git] / fs / btrfs / extent_map.c
index a24a3f2fa13e6fe4a1670073933aa1de61490dc4..911a9db801e0a776a9a960180fb2b95f0ec14863 100644 (file)
@@ -28,12 +28,11 @@ void extent_map_exit(void)
 /**
  * extent_map_tree_init - initialize extent map tree
  * @tree:              tree to initialize
- * @mask:              flags for memory allocations during tree operations
  *
  * Initialize the extent tree @tree.  Should be called for each new inode
  * or other user of the extent_map interface.
  */
-void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask)
+void extent_map_tree_init(struct extent_map_tree *tree)
 {
        tree->map = RB_ROOT;
        rwlock_init(&tree->lock);
@@ -41,16 +40,15 @@ void extent_map_tree_init(struct extent_map_tree *tree, gfp_t mask)
 
 /**
  * alloc_extent_map - allocate new extent map structure
- * @mask:      memory allocation flags
  *
  * Allocate a new extent_map structure.  The new structure is
  * returned with a reference count of one and needs to be
  * freed using free_extent_map()
  */
-struct extent_map *alloc_extent_map(gfp_t mask)
+struct extent_map *alloc_extent_map(void)
 {
        struct extent_map *em;
-       em = kmem_cache_alloc(extent_map_cache, mask);
+       em = kmem_cache_alloc(extent_map_cache, GFP_NOFS);
        if (!em)
                return NULL;
        em->in_tree = 0;
@@ -381,23 +379,12 @@ struct extent_map *search_extent_mapping(struct extent_map_tree *tree,
                em = rb_entry(next, struct extent_map, rb_node);
                goto found;
        }
-       if (!rb_node) {
-               em = NULL;
-               goto out;
-       }
-       if (IS_ERR(rb_node)) {
-               em = ERR_CAST(rb_node);
-               goto out;
-       }
-       em = rb_entry(rb_node, struct extent_map, rb_node);
-       goto found;
-
-       em = NULL;
-       goto out;
+       if (!rb_node)
+               return NULL;
 
+       em = rb_entry(rb_node, struct extent_map, rb_node);
 found:
        atomic_inc(&em->refs);
-out:
        return em;
 }