aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/block/drbd/drbd_interval.c36
1 files changed, 2 insertions, 34 deletions
diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
index 04a14e0f8878..51b25ad85251 100644
--- a/drivers/block/drbd/drbd_interval.c
+++ b/drivers/block/drbd/drbd_interval.c
@@ -37,40 +37,8 @@ compute_subtree_last(struct drbd_interval *node)
37 return max; 37 return max;
38} 38}
39 39
40static void augment_propagate(struct rb_node *rb, struct rb_node *stop) 40RB_DECLARE_CALLBACKS(static, augment_callbacks, struct drbd_interval, rb,
41{ 41 sector_t, end, compute_subtree_last);
42 while (rb != stop) {
43 struct drbd_interval *node = rb_entry(rb, struct drbd_interval, rb);
44 sector_t subtree_last = compute_subtree_last(node);
45 if (node->end == subtree_last)
46 break;
47 node->end = subtree_last;
48 rb = rb_parent(&node->rb);
49 }
50}
51
52static void augment_copy(struct rb_node *rb_old, struct rb_node *rb_new)
53{
54 struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb);
55 struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb);
56
57 new->end = old->end;
58}
59
60static void augment_rotate(struct rb_node *rb_old, struct rb_node *rb_new)
61{
62 struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb);
63 struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb);
64
65 new->end = old->end;
66 old->end = compute_subtree_last(old);
67}
68
69static const struct rb_augment_callbacks augment_callbacks = {
70 augment_propagate,
71 augment_copy,
72 augment_rotate,
73};
74 42
75/** 43/**
76 * drbd_insert_interval - insert a new interval into a tree 44 * drbd_insert_interval - insert a new interval into a tree