summaryrefslogtreecommitdiff
path: root/drivers/block/drbd/drbd_interval.h
diff options
context:
space:
mode:
authorAndreas Gruenbacher <agruen@linbit.com>2011-02-17 20:11:24 +0300
committerPhilipp Reisner <philipp.reisner@linbit.com>2011-10-14 18:47:37 +0400
commitd0e22a260c5142171c730436664febb045b9f0f0 (patch)
treeaa8180451e2d741aad17760542fb6866e2c00e95 /drivers/block/drbd/drbd_interval.h
parentfcefa62e4c26e70c70b9e8252a4bc9b9031a4182 (diff)
downloadlinux-d0e22a260c5142171c730436664febb045b9f0f0.tar.xz
drbd: Iterate over all overlapping intervals in a tree
Add a macro and helper function for doing that. Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
Diffstat (limited to 'drivers/block/drbd/drbd_interval.h')
-rw-r--r--drivers/block/drbd/drbd_interval.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/drivers/block/drbd/drbd_interval.h b/drivers/block/drbd/drbd_interval.h
index 4010ad923948..f38fcb00c10d 100644
--- a/drivers/block/drbd/drbd_interval.h
+++ b/drivers/block/drbd/drbd_interval.h
@@ -23,10 +23,18 @@ static inline bool drbd_interval_empty(struct drbd_interval *i)
return RB_EMPTY_NODE(&i->rb);
}
-bool drbd_insert_interval(struct rb_root *, struct drbd_interval *);
-bool drbd_contains_interval(struct rb_root *, sector_t, struct drbd_interval *);
-void drbd_remove_interval(struct rb_root *, struct drbd_interval *);
-struct drbd_interval *drbd_find_overlap(struct rb_root *, sector_t,
+extern bool drbd_insert_interval(struct rb_root *, struct drbd_interval *);
+extern bool drbd_contains_interval(struct rb_root *, sector_t,
+ struct drbd_interval *);
+extern void drbd_remove_interval(struct rb_root *, struct drbd_interval *);
+extern struct drbd_interval *drbd_find_overlap(struct rb_root *, sector_t,
unsigned int);
+extern struct drbd_interval *drbd_next_overlap(struct drbd_interval *, sector_t,
+ unsigned int);
+
+#define drbd_for_each_overlap(i, root, sector, size) \
+ for (i = drbd_find_overlap(root, sector, size); \
+ i; \
+ i = drbd_next_overlap(i, sector, size))
#endif /* __DRBD_INTERVAL_H */