Skip to content

Commit 5fa353f

Browse files
Lai JiangshanJiri Slaby
authored andcommitted
drbd: compute the end before rb_insert_augmented()
commit 82cfb90 upstream. Commit 9868365 "Merge branch 'drbd-8.4_ed6' into for-3.8-drivers-drbd-8.4_ed6" switches to the new augment API, but the new API requires that the tree is augmented before rb_insert_augmented() is called, which is missing. So we add the augment-code to drbd_insert_interval() when it travels the tree up to down before rb_insert_augmented(). See the example in include/linux/interval_tree_generic.h or Documentation/rbtree.txt. drbd_insert_interval() may cancel the insertion when traveling, in this case, the just added augment-code does nothing before cancel since the @this node is already in the subtrees in this case. CC: Michel Lespinasse <walken@google.com> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com> Signed-off-by: Andreas Gruenbacher <agruen@linbit.com> Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Jens Axboe <axboe@fb.com> Signed-off-by: Jiri Slaby <jslaby@suse.cz>
1 parent de91001 commit 5fa353f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎drivers/block/drbd/drbd_interval.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ bool
7979
drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
8080
{
8181
struct rb_node **new = &root->rb_node, *parent = NULL;
82+
sector_t this_end = this->sector + (this->size >> 9);
8283

8384
BUG_ON(!IS_ALIGNED(this->size, 512));
8485

@@ -87,6 +88,8 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
8788
rb_entry(*new, struct drbd_interval, rb);
8889

8990
parent = *new;
91+
if (here->end < this_end)
92+
here->end = this_end;
9093
if (this->sector < here->sector)
9194
new = &(*new)->rb_left;
9295
else if (this->sector > here->sector)
@@ -99,6 +102,7 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)
99102
return false;
100103
}
101104

105+
this->end = this_end;
102106
rb_link_node(&this->rb, parent, new);
103107
rb_insert_augmented(&this->rb, root, &augment_callbacks);
104108
return true;

0 commit comments

Comments
 (0)