diff mbox

[5/9] btt: Replace overlapping IO

Message ID 1462461432-1900-6-git-send-email-jack@suse.cz (mailing list archive)
State New, archived
Headers show

Commit Message

Jan Kara May 5, 2016, 3:17 p.m. UTC
Currently btt keeps the original IO in its RB-tree even if it sees new
IO that is beginning at the same sector. However such IO most likely
means that we have just lost the completion event for the IO that is
still in the tree. So in such case replacing the IO in RB-tree makes
more sense to avoid bogus IOs being reported as taking huge amount of
time.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 btt/dip_rb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff mbox

Patch

diff --git a/btt/dip_rb.c b/btt/dip_rb.c
index 867a97bd9997..2aa7ffcc763b 100644
--- a/btt/dip_rb.c
+++ b/btt/dip_rb.c
@@ -37,8 +37,10 @@  int rb_insert(struct rb_root *root, struct io *iop)
 			p = &(*p)->rb_left;
 		else if (s > __s)
 			p = &(*p)->rb_right;
-		else
-			return 0;
+		else {
+			rb_replace_node(parent, &iop->rb_node, root);
+			return 1;
+		}
 	}
 
 	rb_link_node(&iop->rb_node, parent, p);