Whamcloud - gitweb
LU-6245 tests: remove it_test
[fs/lustre-release.git] / lustre / ldlm / interval_tree.c
index 5d54f25..b39b105 100644 (file)
@@ -1,6 +1,4 @@
-/* -*- mode: c; c-basic-offset: 8; indent-tabs-mode: nil; -*-
- * vim:expandtab:shiftwidth=8:tabstop=8:
- *
+/*
  * GPL HEADER START
  *
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
 /*
  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
  * Use is subject to license terms.
+ *
+ * Copyright (c) 2014, Intel Corporation.
  */
 /*
  * This file is part of Lustre, http://www.lustre.org/
  * Author: Huang Wei <huangwei@clusterfs.com>
  * Author: Jay Xiong <jinshan.xiong@sun.com>
  */
-#ifdef __KERNEL__
-# include <lustre_dlm.h>
-#else
-# include <liblustre.h>
-#endif
-#include <obd_support.h>
+
+#include <lustre_dlm.h>
 #include <interval_tree.h>
 
 enum {
@@ -101,7 +93,7 @@ static inline int extent_equal(struct interval_node_extent *e1,
         return (e1->start == e2->start) && (e1->end == e2->end);
 }
 
-static inline int extent_overlapped(struct interval_node_extent *e1, 
+static inline int extent_overlapped(struct interval_node_extent *e1,
                                     struct interval_node_extent *e2)
 {
         return (e1->start <= e2->end) && (e2->start <= e1->end);
@@ -113,10 +105,9 @@ static inline int node_compare(struct interval_node *n1,
         return extent_compare(&n1->in_extent, &n2->in_extent);
 }
 
-static inline int node_equal(struct interval_node *n1,
-                             struct interval_node *n2)
+int node_equal(struct interval_node *n1, struct interval_node *n2)
 {
-        return extent_equal(&n1->in_extent, &n2->in_extent);
+       return extent_equal(&n1->in_extent, &n2->in_extent);
 }
 
 static inline __u64 max_u64(__u64 x, __u64 y)
@@ -625,59 +616,61 @@ static inline int interval_may_overlap(struct interval_node *node,
  *
  */
 enum interval_iter interval_search(struct interval_node *node,
-                                   struct interval_node_extent *ext,
-                                   interval_callback_t func,
-                                   void *data)
-{
-        struct interval_node *parent;
-        enum interval_iter rc = INTERVAL_ITER_CONT;
-
-        LASSERT(ext != NULL);
-        LASSERT(func != NULL);
-
-        while (node) {
-                if (ext->end < interval_low(node)) {
-                        if (node->in_left) {
-                                node = node->in_left;
-                                continue;
-                        }
-                } else if (interval_may_overlap(node, ext)) {
-                        if (extent_overlapped(ext, &node->in_extent)) {
-                                rc = func(node, data);
-                                if (rc == INTERVAL_ITER_STOP)
-                                        break;
-                        }
-
-                        if (node->in_left) {
-                                node = node->in_left;
-                                continue;
-                        }
-                        if (node->in_right) {
-                                node = node->in_right;
-                                continue;
-                        }
-                } 
-
-                parent = node->in_parent;
-                while (parent) {
-                        if (node_is_left_child(node) &&
-                            parent->in_right) {
-                                /* If we ever got the left, it means that the 
-                                 * parent met ext->end<interval_low(parent), or
-                                 * may_overlap(parent). If the former is true,
-                                 * we needn't go back. So stop early and check
-                                 * may_overlap(parent) after this loop.  */
-                                node = parent->in_right;
-                                break;
-                        }
-                        node = parent;
-                        parent = parent->in_parent;
-                }
-                if (parent == NULL || !interval_may_overlap(parent, ext))
-                        break;
-        }
-
-        return rc;
+                                  struct interval_node_extent *ext,
+                                  interval_callback_t func,
+                                  void *data)
+{
+       struct interval_node *parent;
+       enum interval_iter rc = INTERVAL_ITER_CONT;
+
+       ENTRY;
+
+       LASSERT(ext != NULL);
+       LASSERT(func != NULL);
+
+       while (node) {
+               if (ext->end < interval_low(node)) {
+                       if (node->in_left) {
+                               node = node->in_left;
+                               continue;
+                       }
+               } else if (interval_may_overlap(node, ext)) {
+                       if (extent_overlapped(ext, &node->in_extent)) {
+                               rc = func(node, data);
+                               if (rc == INTERVAL_ITER_STOP)
+                                       break;
+                       }
+
+                       if (node->in_left) {
+                               node = node->in_left;
+                               continue;
+                       }
+                       if (node->in_right) {
+                               node = node->in_right;
+                               continue;
+                       }
+               }
+
+               parent = node->in_parent;
+               while (parent) {
+                       if (node_is_left_child(node) &&
+                           parent->in_right) {
+                               /* If we ever got the left, it means that the
+                                * parent met ext->end<interval_low(parent), or
+                                * may_overlap(parent). If the former is true,
+                                * we needn't go back. So stop early and check
+                                * may_overlap(parent) after this loop.  */
+                               node = parent->in_right;
+                               break;
+                       }
+                       node = parent;
+                       parent = parent->in_parent;
+               }
+               if (parent == NULL || !interval_may_overlap(parent, ext))
+                       break;
+       }
+
+       RETURN(rc);
 }
 EXPORT_SYMBOL(interval_search);
 
@@ -767,4 +760,3 @@ void interval_expand(struct interval_node *root,
                 ext->end = interval_expand_high(root, ext->end);
         LASSERT(interval_is_overlapped(root, ext) == 0);
 }
-EXPORT_SYMBOL(interval_expand);