Whamcloud - gitweb
LU-1669 llite: Replace write mutex with range lock
[fs/lustre-release.git] / lustre / ldlm / interval_tree.c
index b052766..53c23d5 100644 (file)
@@ -99,7 +99,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);
@@ -111,11 +111,11 @@ 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);
 }
+EXPORT_SYMBOL(node_equal);
 
 static inline __u64 max_u64(__u64 x, __u64 y)
 {
@@ -623,59 +623,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);