diff options
author | Andreas Gruenbacher <agruen@linbit.com> | 2011-01-03 11:42:00 -0500 |
---|---|---|
committer | Philipp Reisner <philipp.reisner@linbit.com> | 2011-08-25 08:58:04 -0400 |
commit | 0939b0e5cdeeafa0adf0150edd350092e47acc49 (patch) | |
tree | 8efaf1d9aadf77b76ca66b4968bce89cb78a6b98 /drivers/block/drbd/drbd_interval.h | |
parent | c3afd8f568999e974382f7b5b05267c018056016 (diff) |
drbd: Add interval tree data structure
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.h | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/block/drbd/drbd_interval.h b/drivers/block/drbd/drbd_interval.h new file mode 100644 index 000000000000..bf8dcf7bab09 --- /dev/null +++ b/drivers/block/drbd/drbd_interval.h | |||
@@ -0,0 +1,31 @@ | |||
1 | #ifndef __DRBD_INTERVAL_H | ||
2 | #define __DRBD_INTERVAL_H | ||
3 | |||
4 | #include <linux/types.h> | ||
5 | #include <linux/rbtree.h> | ||
6 | |||
7 | struct drbd_interval { | ||
8 | struct rb_node rb; | ||
9 | sector_t sector; /* start sector of the interval */ | ||
10 | unsigned int size; /* size in bytes */ | ||
11 | sector_t end; /* highest interval end in subtree */ | ||
12 | }; | ||
13 | |||
14 | static inline void drbd_clear_interval(struct drbd_interval *i) | ||
15 | { | ||
16 | RB_CLEAR_NODE(&i->rb); | ||
17 | } | ||
18 | |||
19 | static inline bool drbd_interval_empty(struct drbd_interval *i) | ||
20 | { | ||
21 | return RB_EMPTY_NODE(&i->rb); | ||
22 | } | ||
23 | |||
24 | bool drbd_insert_interval(struct rb_root *, struct drbd_interval *); | ||
25 | struct drbd_interval *drbd_find_interval(struct rb_root *, sector_t, | ||
26 | struct drbd_interval *); | ||
27 | void drbd_remove_interval(struct rb_root *, struct drbd_interval *); | ||
28 | struct drbd_interval *drbd_find_overlap(struct rb_root *, sector_t, | ||
29 | unsigned int); | ||
30 | |||
31 | #endif /* __DRBD_INTERVAL_H */ | ||