btrfs-progs: check: introduce function to check tree block backref in extent tree
[platform/upstream/btrfs-progs.git] / radix-tree.c
index baa25ca..f259ab5 100644 (file)
@@ -1,4 +1,22 @@
 /*
+ * Copyright (C) 2007 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License v2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ */
+
+/*
  * Copyright (C) 2001 Momchil Velikov
  * Portions Copyright (C) 2001 Christoph Hellwig
  * Copyright (C) 2005 SGI, Christoph Lameter <clameter@sgi.com>
@@ -55,12 +73,7 @@ struct radix_tree_preload {
        int nr;
        struct radix_tree_node *nodes[RADIX_TREE_MAX_PATH];
 };
-struct radix_tree_preload radix_tree_preloads = { 0, };
-
-static inline gfp_t root_gfp_mask(struct radix_tree_root *root)
-{
-       return root->gfp_mask & __GFP_BITS_MASK;
-}
+static struct radix_tree_preload radix_tree_preloads = { 0, };
 
 static int internal_nodes = 0;
 /*
@@ -296,7 +309,7 @@ static inline void **__lookup_slot(struct radix_tree_root *root,
                return NULL;
 
        if (height == 0 && root->rnode)
-               return (void **)&root->rnode;
+               return (void *)&root->rnode;
 
        shift = (height-1) * RADIX_TREE_MAP_SHIFT;
        slot = &root->rnode;
@@ -815,10 +828,10 @@ int radix_tree_tagged(struct radix_tree_root *root, unsigned int tag)
 static unsigned long __maxindex(unsigned int height)
 {
        unsigned int tmp = height * RADIX_TREE_MAP_SHIFT;
-       unsigned long index = (~0UL >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1;
+       unsigned long index = ~0UL;
 
-       if (tmp >= RADIX_TREE_INDEX_BITS)
-               index = ~0UL;
+       if (tmp < RADIX_TREE_INDEX_BITS)
+               index = (index >> (RADIX_TREE_INDEX_BITS - tmp - 1)) >> 1;
        return index;
 }