public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] More for the 3.18 merge window
@ 2014-09-18 14:49 Philipp Reisner
  2014-09-18 14:49 ` [PATCH 1/2] drbd: compute the end before rb_insert_augmented() Philipp Reisner
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Philipp Reisner @ 2014-09-18 14:49 UTC (permalink / raw)
  To: linux-kernel, Jens Axboe; +Cc: drbd-dev, Lai Jiangshan, Michel Lespinasse

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: stable@kernel.org


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(-)

-- 
1.9.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] drbd: compute the end before rb_insert_augmented()
  2014-09-18 14:49 [PATCH 0/2] More for the 3.18 merge window Philipp Reisner
@ 2014-09-18 14:49 ` Philipp Reisner
  2014-09-18 14:49 ` [PATCH 2/2] drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks Philipp Reisner
  2014-09-18 15:00 ` [PATCH 0/2] More for the 3.18 merge window Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Reisner @ 2014-09-18 14:49 UTC (permalink / raw)
  To: linux-kernel, Jens Axboe; +Cc: drbd-dev, Lai Jiangshan, Michel Lespinasse

From: Lai Jiangshan <laijs@cn.fujitsu.com>

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.

CC: Michel Lespinasse <walken@google.com>
CC: stable@kernel.org # v3.10+
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>
---
 drivers/block/drbd/drbd_interval.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
index 89c497c..04a14e0 100644
--- a/drivers/block/drbd/drbd_interval.c
+++ b/drivers/block/drbd/drbd_interval.c
@@ -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;
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks
  2014-09-18 14:49 [PATCH 0/2] More for the 3.18 merge window Philipp Reisner
  2014-09-18 14:49 ` [PATCH 1/2] drbd: compute the end before rb_insert_augmented() Philipp Reisner
@ 2014-09-18 14:49 ` Philipp Reisner
  2014-09-18 15:00 ` [PATCH 0/2] More for the 3.18 merge window Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Philipp Reisner @ 2014-09-18 14:49 UTC (permalink / raw)
  To: linux-kernel, Jens Axboe; +Cc: drbd-dev, Lai Jiangshan, Michel Lespinasse

From: Lai Jiangshan <laijs@cn.fujitsu.com>

The original code are the same as RB_DECLARE_CALLBACKS().

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>
---
 drivers/block/drbd/drbd_interval.c | 36 ++----------------------------------
 1 file changed, 2 insertions(+), 34 deletions(-)

diff --git a/drivers/block/drbd/drbd_interval.c b/drivers/block/drbd/drbd_interval.c
index 04a14e0..51b25ad 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)
 	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
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] More for the 3.18 merge window
  2014-09-18 14:49 [PATCH 0/2] More for the 3.18 merge window Philipp Reisner
  2014-09-18 14:49 ` [PATCH 1/2] drbd: compute the end before rb_insert_augmented() Philipp Reisner
  2014-09-18 14:49 ` [PATCH 2/2] drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks Philipp Reisner
@ 2014-09-18 15:00 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2014-09-18 15:00 UTC (permalink / raw)
  To: Philipp Reisner, linux-kernel; +Cc: drbd-dev, Lai Jiangshan, Michel Lespinasse

On 2014-09-18 08:49, Philipp Reisner wrote:
> 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: stable@kernel.org

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-18 15:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-18 14:49 [PATCH 0/2] More for the 3.18 merge window Philipp Reisner
2014-09-18 14:49 ` [PATCH 1/2] drbd: compute the end before rb_insert_augmented() Philipp Reisner
2014-09-18 14:49 ` [PATCH 2/2] drbd: use RB_DECLARE_CALLBACKS() to define augment callbacks Philipp Reisner
2014-09-18 15:00 ` [PATCH 0/2] More for the 3.18 merge window Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox