All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] dm-bufio: clean up rbtree block ordering
@ 2020-06-02 13:34 Mikulas Patocka
  0 siblings, 0 replies; only message in thread
From: Mikulas Patocka @ 2020-06-02 13:34 UTC (permalink / raw)
  To: Mike Snitzer, Heinz Mauelshagen; +Cc: dm-devel, Mikulas Patocka

[-- Attachment #1: dm-bufio-cleanup-tree.patch --]
[-- Type: text/plain, Size: 1146 bytes --]

dm-bufio use unnatural ordering in the rb-tree - blocks with smaller
nubmers were put to the right node and blocks with bigget numbers were put
to the left node.

This patch reverses the logic, so that i's natural.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>

---
 drivers/md/dm-bufio.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-2.6/drivers/md/dm-bufio.c
===================================================================
--- linux-2.6.orig/drivers/md/dm-bufio.c	2020-06-02 13:27:14.000000000 +0200
+++ linux-2.6/drivers/md/dm-bufio.c	2020-06-02 14:26:32.000000000 +0200
@@ -256,7 +256,7 @@ static struct dm_buffer *__find(struct d
 		if (b->block == block)
 			return b;
 
-		n = (b->block < block) ? n->rb_left : n->rb_right;
+		n = block < b->block ? n->rb_left : n->rb_right;
 	}
 
 	return NULL;
@@ -276,8 +276,8 @@ static void __insert(struct dm_bufio_cli
 		}
 
 		parent = *new;
-		new = (found->block < b->block) ?
-			&((*new)->rb_left) : &((*new)->rb_right);
+		new = b->block < found->block ?
+			&found->node.rb_left : &found->node.rb_right;
 	}
 
 	rb_link_node(&b->node, parent, new);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-06-02 13:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-02 13:34 [PATCH 1/3] dm-bufio: clean up rbtree block ordering Mikulas Patocka

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.