From b8735f6517e805b0fc76f7ee830778b1d5fadea2 Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 30 Nov 2020 15:50:20 +0100 Subject: [PATCH 1/2] rbtree: Fix swapping out-of-tree node with root Signed-off-by: Robert Baldyga --- src/utils/utils_rbtree.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/utils/utils_rbtree.c b/src/utils/utils_rbtree.c index e4ce67f..02debec 100644 --- a/src/utils/utils_rbtree.c +++ b/src/utils/utils_rbtree.c @@ -192,6 +192,10 @@ static void ocf_rb_tree_update_children(struct ocf_rb_node *node) node->right->parent = node; } +/* + * Note: When swapping with out-of-tree element, the tree member must go + * as node1 and out-of-tree item as node2. + */ static void ocf_rb_tree_swap(struct ocf_rb_tree *tree, struct ocf_rb_node *node1, struct ocf_rb_node *node2) { @@ -218,8 +222,8 @@ static void ocf_rb_tree_swap(struct ocf_rb_tree *tree, ocf_rb_tree_update_children(node1); ocf_rb_tree_update_children(node2); - ocf_rb_tree_update_parent(tree, node2->parent, node1, node2); ocf_rb_tree_update_parent(tree, node1->parent, node2, node1); + ocf_rb_tree_update_parent(tree, node2->parent, node1, node2); } static struct ocf_rb_node *ocf_rb_tree_successor(struct ocf_rb_node *node) From 9bcafb5bfb666274cbddcf7b5e218c6f3eee37cd Mon Sep 17 00:00:00 2001 From: Robert Baldyga Date: Mon, 30 Nov 2020 15:57:33 +0100 Subject: [PATCH 2/2] seq_cutoff: Initialize each stream with different LBA Initializing each stream with unique LBA ensures there are no initial rbtree collisions, and thus helps to avoid clustering of all the streams into one big linked list instead of forming performance friendly proper tree structure. Signed-off-by: Robert Baldyga --- src/ocf_seq_cutoff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ocf_seq_cutoff.c b/src/ocf_seq_cutoff.c index 236a2c9..5d137ea 100644 --- a/src/ocf_seq_cutoff.c +++ b/src/ocf_seq_cutoff.c @@ -73,7 +73,7 @@ void ocf_core_seq_cutoff_init(ocf_core_t core) for (i = 0; i < OCF_SEQ_CUTOFF_MAX_STREAMS; i++) { stream = &core->seq_cutoff.streams[i]; - stream->last = 0; + stream->last = 4096 * i; stream->bytes = 0; stream->rw = 0; ocf_rb_tree_insert(&core->seq_cutoff.tree, &stream->node);