cfq-iosched: fix bug with aliased request and cooperation detection
authorJens Axboe <jens.axboe@oracle.com>
Thu, 23 Apr 2009 10:14:56 +0000 (12:14 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 24 Apr 2009 06:54:22 +0000 (08:54 +0200)
cfq_prio_tree_lookup() should return the direct match, yet it always
returns zero. Fix that.

cfq_prio_tree_add() assumes that we don't get a direct match, while
it is very possible that we do. Using O_DIRECT, you can have different
cfqq with matching requests, since you don't have the page cache
to serialize things for you. Fix this bug by only adding the cfqq if
there isn't an existing match.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
block/cfq-iosched.c

index 20a54b8e03e1c0ec4cdd1dd6d2485c20d2ba6f44..b0b754a6882b08721f876f1ceaad576022cd8b93 100644 (file)
@@ -584,12 +584,13 @@ cfq_prio_tree_lookup(struct cfq_data *cfqd, int ioprio, sector_t sector,
                else
                        break;
                p = n;
+               cfqq = NULL;
        }
 
        *ret_parent = parent;
        if (rb_link)
                *rb_link = p;
-       return NULL;
+       return cfqq;
 }
 
 static void cfq_prio_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq)
@@ -608,10 +609,10 @@ static void cfq_prio_tree_add(struct cfq_data *cfqd, struct cfq_queue *cfqq)
 
        __cfqq = cfq_prio_tree_lookup(cfqd, cfqq->ioprio, cfqq->next_rq->sector,
                                         &parent, &p);
-       BUG_ON(__cfqq);
-
-       rb_link_node(&cfqq->p_node, parent, p);
-       rb_insert_color(&cfqq->p_node, root);
+       if (!__cfqq) {
+               rb_link_node(&cfqq->p_node, parent, p);
+               rb_insert_color(&cfqq->p_node, root);
+       }
 }
 
 /*
This page took 0.025381 seconds and 5 git commands to generate.