btt: Replace overlapping IO
authorJan Kara <jack@suse.cz>
Thu, 5 May 2016 15:17:08 +0000 (17:17 +0200)
committerJens Axboe <axboe@fb.com>
Thu, 5 May 2016 15:20:18 +0000 (09:20 -0600)
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>
Signed-off-by: Jens Axboe <axboe@fb.com>
btt/dip_rb.c

index 867a97bd999773ffe1301e7a7ae45772cfc0ed6e..2aa7ffcc763b01145b5b0b7f07c806c347eb8e3c 100644 (file)
@@ -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);