From: Jens Axboe The 'unplug on queued exceeding unplug threshold' logic only works for file system requests currently, since it's in __make_request(). Move it where it belongs, in elv_add_request(). This way it works for queued block sg requests as well. Signed-Off-By: Jens Axboe Signed-off-by: Andrew Morton --- 25-akpm/drivers/block/elevator.c | 8 ++++++++ 25-akpm/drivers/block/ll_rw_blk.c | 11 ++++------- 25-akpm/include/linux/blkdev.h | 1 + 3 files changed, 13 insertions(+), 7 deletions(-) diff -puN drivers/block/elevator.c~blk-move-threshold-unplugging drivers/block/elevator.c --- 25/drivers/block/elevator.c~blk-move-threshold-unplugging Wed Jun 9 14:27:19 2004 +++ 25-akpm/drivers/block/elevator.c Wed Jun 9 14:27:19 2004 @@ -181,6 +181,14 @@ void __elv_add_request(request_queue_t * rq->q = q; q->elevator.elevator_add_req_fn(q, rq, where); + + if (blk_queue_plugged(q)) { + int nrq = q->rq.count[READ] + q->rq.count[WRITE] - q->in_flight; + + if (nrq == q->unplug_thresh) + __generic_unplug_device(q); + } + } void elv_add_request(request_queue_t *q, struct request *rq, int where, diff -puN drivers/block/ll_rw_blk.c~blk-move-threshold-unplugging drivers/block/ll_rw_blk.c --- 25/drivers/block/ll_rw_blk.c~blk-move-threshold-unplugging Wed Jun 9 14:27:19 2004 +++ 25-akpm/drivers/block/ll_rw_blk.c Wed Jun 9 14:27:19 2004 @@ -1162,7 +1162,7 @@ EXPORT_SYMBOL(blk_remove_plug); /* * remove the plug and let it rip.. */ -static inline void __generic_unplug_device(request_queue_t *q) +inline void __generic_unplug_device(request_queue_t *q) { if (test_bit(QUEUE_FLAG_STOPPED, &q->queue_flags)) return; @@ -1176,6 +1176,7 @@ static inline void __generic_unplug_devi if (elv_next_request(q)) q->request_fn(q); } +EXPORT_SYMBOL(__generic_unplug_device); /** * generic_unplug_device - fire a request queue @@ -2389,13 +2390,9 @@ get_rq: out: if (freereq) __blk_put_request(q, freereq); + if (bio_sync(bio)) + __generic_unplug_device(q); - if (blk_queue_plugged(q)) { - int nrq = q->rq.count[READ] + q->rq.count[WRITE] - q->in_flight; - - if (nrq == q->unplug_thresh || bio_sync(bio)) - __generic_unplug_device(q); - } spin_unlock_irq(q->queue_lock); return 0; diff -puN include/linux/blkdev.h~blk-move-threshold-unplugging include/linux/blkdev.h --- 25/include/linux/blkdev.h~blk-move-threshold-unplugging Wed Jun 9 14:27:19 2004 +++ 25-akpm/include/linux/blkdev.h Wed Jun 9 14:27:19 2004 @@ -614,6 +614,7 @@ extern int blkdev_scsi_issue_flush_fn(re extern int blk_rq_map_sg(request_queue_t *, struct request *, struct scatterlist *); extern void blk_dump_rq_flags(struct request *, char *); extern void generic_unplug_device(request_queue_t *); +extern inline void __generic_unplug_device(request_queue_t *); extern long nr_blockdev_pages(void); int blk_get_queue(request_queue_t *); _