More for the 3.18 merge window
Subsystems (2)
Philipp Reisner
maintainercover More for the 3.18 merge window
Hi Jens,
please put these two patches into your for-3.18/drivers branch. They fix the safety code for concurrent overlapping write detection in a DRBD dual primary setup.
The first of those two should also go to the stable kernels, I marked it with CC: [email protected]
Lai Jiangshan (2):
drbd: compute the end before rb_insert_augmented()
drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks
drivers/block/drbd/drbd_interval.c | 40 ++++++-------------------------------- 1 file changed, 6 insertions(+), 34 deletions(-)
Signature · 1 line
1.9.1
Philipp Reisner
maintainerPATCH 1/2 drbd: compute the end before rb_insert_augmented()
From: Lai Jiangshan <[email protected]>
Commit 98683650 "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.
--- drivers/block/drbd/drbd_interval.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/block/drbd/drbd_interval.c +4 -0
@@ -79,6 +79,7 @@ bool drbd_insert_interval(struct rb_root *root, struct drbd_interval *this) { struct rb_node **new = &root->rb_node, *parent = NULL; +sector_t this_end = this->sector + (this->size >>9 );BUG_ON (!IS_ALIGNED (this->size,512 ));
@@ -87,6 +88,8 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this) rb_entry(*new, struct drbd_interval, rb); parent = *new; +if (here->end < this_end) + here->end = this_end;if (this->sector < here->sector) new = &(*new)->rb_left;else if (this->sector > here->sector)
@@ -99,6 +102,7 @@ drbd_insert_interval(struct rb_root *root, struct drbd_interval *this)return false; } + this->end = this_end;rb_link_node (&this->rb, parent, new);rb_insert_augmented (&this->rb, root, &augment_callbacks);return true;
Signature · 1 line
1.9.1
Philipp Reisner
maintainerPATCH 2/2 drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks
In reply to Philipp ReisnerFrom: Lai Jiangshan <[email protected]>
The original code are the same as RB_DECLARE_CALLBACKS().
--- drivers/block/drbd/drbd_interval.c | 36 ++---------------------------------- 1 file changed, 2 insertions(+), 34 deletions(-)
drivers/block/drbd/drbd_interval.c +2 -34
@@ -37,40 +37,8 @@ compute_subtree_last(struct drbd_interval *node)return max; } -static void augment_propagate (struct rb_node *rb,struct rb_node *stop) -{ -while (rb != stop) { - struct drbd_interval *node = rb_entry(rb, struct drbd_interval, rb); -sector_t subtree_last =compute_subtree_last (node); -if (node->end == subtree_last) -break ; - node->end = subtree_last; - rb =rb_parent (&node->rb); - } -} - -static void augment_copy (struct rb_node *rb_old,struct rb_node *rb_new) -{ - struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb); - struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb); - - new->end = old->end; -} - -static void augment_rotate (struct rb_node *rb_old,struct rb_node *rb_new) -{ - struct drbd_interval *old = rb_entry(rb_old, struct drbd_interval, rb); - struct drbd_interval *new = rb_entry(rb_new, struct drbd_interval, rb); - - new->end = old->end; - old->end =compute_subtree_last (old); -} - -static const struct rb_augment_callbacks augment_callbacks = { - augment_propagate, - augment_copy, - augment_rotate, -}; +RB_DECLARE_CALLBACKS(static, augment_callbacks, struct drbd_interval, rb, + sector_t, end, compute_subtree_last);/** * drbd_insert_interval - insert a new interval into a tree
Signature · 1 line
1.9.1
Quoted 8 lines · Philipp Reisner
Hi Jens,
please put these two patches into your for-3.18/drivers branch. They fix the safety code for concurrent overlapping write detection in a DRBD dual primary setup.
The first of those two should also go to the stable kernels, I marked it with CC: [email protected]
Applied, thanks.
Signature · 1 line
Jens Axboe