1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __DRBD_INTERVAL_H
3 #define __DRBD_INTERVAL_H
5 #include <linux/types.h>
6 #include <linux/rbtree.h>
10 sector_t sector
; /* start sector of the interval */
11 unsigned int size
; /* size in bytes */
12 sector_t end
; /* highest interval end in subtree */
13 unsigned int local
:1 /* local or remote request? */;
14 unsigned int waiting
:1; /* someone is waiting for completion */
15 unsigned int completed
:1; /* this has been completed already;
16 * ignore for conflict detection */
19 static inline void drbd_clear_interval(struct drbd_interval
*i
)
21 RB_CLEAR_NODE(&i
->rb
);
24 static inline bool drbd_interval_empty(struct drbd_interval
*i
)
26 return RB_EMPTY_NODE(&i
->rb
);
29 extern bool drbd_insert_interval(struct rb_root
*, struct drbd_interval
*);
30 extern bool drbd_contains_interval(struct rb_root
*, sector_t
,
31 struct drbd_interval
*);
32 extern void drbd_remove_interval(struct rb_root
*, struct drbd_interval
*);
33 extern struct drbd_interval
*drbd_find_overlap(struct rb_root
*, sector_t
,
35 extern struct drbd_interval
*drbd_next_overlap(struct drbd_interval
*, sector_t
,
38 #define drbd_for_each_overlap(i, root, sector, size) \
39 for (i = drbd_find_overlap(root, sector, size); \
41 i = drbd_next_overlap(i, sector, size))
43 #endif /* __DRBD_INTERVAL_H */