summaryrefslogtreecommitdiffstats
path: root/block/cfq-iosched.c
diff options
context:
space:
mode:
authorShaohua Li <shaohua.li@intel.com>2011-12-16 14:00:22 +0100
committerJens Axboe <axboe@kernel.dk>2011-12-16 14:00:22 +0100
commit4a0b75c7d02c2bd46ed227d4ba5941ba8a0aba5d (patch)
treea5a0c37a44c87227539ebc356178cc80435144d9 /block/cfq-iosched.c
parentf1f8cc94651738b418ba54c039df536303b91704 (diff)
downloadlinux-4a0b75c7d02c2bd46ed227d4ba5941ba8a0aba5d.tar.gz
linux-4a0b75c7d02c2bd46ed227d4ba5941ba8a0aba5d.tar.bz2
linux-4a0b75c7d02c2bd46ed227d4ba5941ba8a0aba5d.zip
block, cfq: fix empty queue crash caused by request merge
All requests of a queue could be merged to other requests of other queue. Such queue will not have request in it, but it's in service tree. This will cause kernel oops. I encounter a BUG_ON() in cfq_dispatch_request() with next patch, but the issue should exist without the patch. Signed-off-by: Shaohua Li <shaohua.li@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r--block/cfq-iosched.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c
index f3b44c394e6d..163263ddd381 100644
--- a/block/cfq-iosched.c
+++ b/block/cfq-iosched.c
@@ -1656,6 +1656,8 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
struct request *next)
{
struct cfq_queue *cfqq = RQ_CFQQ(rq);
+ struct cfq_data *cfqd = q->elevator->elevator_data;
+
/*
* reposition in fifo if next is older than rq
*/
@@ -1670,6 +1672,16 @@ cfq_merged_requests(struct request_queue *q, struct request *rq,
cfq_remove_request(next);
cfq_blkiocg_update_io_merged_stats(&(RQ_CFQG(rq))->blkg,
rq_data_dir(next), rq_is_sync(next));
+
+ cfqq = RQ_CFQQ(next);
+ /*
+ * all requests of this queue are merged to other queues, delete it
+ * from the service tree. If it's the active_queue,
+ * cfq_dispatch_requests() will choose to expire it or do idle
+ */
+ if (cfq_cfqq_on_rr(cfqq) && RB_EMPTY_ROOT(&cfqq->sort_list) &&
+ cfqq != cfqd->active_queue)
+ cfq_del_cfqq_rr(cfqd, cfqq);
}
static int cfq_allow_merge(struct request_queue *q, struct request *rq,