aboutsummaryrefslogtreecommitdiffstats
path: root/block/elevator.c
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2006-12-20 05:04:12 -0500
committerJens Axboe <jens.axboe@oracle.com>2006-12-20 05:04:12 -0500
commitda775265021b61d5eb81df155e36cb0810f6df53 (patch)
treef7b28991b281a8c581bd3ab0bb470e158ae2206f /block/elevator.c
parent8e5cfc45e7527eb5c8a9a22d56a7b9227e7c0913 (diff)
[PATCH] cfq-iosched: don't allow sync merges across queues
Currently we allow any merge, even if the io originates from different processes. This can cause really bad starvation and unfairness, if those ios happen to be synchronous (reads or direct writes). So add a allow_merge hook to the io scheduler ops, so an io scheduler can help decide whether a bio/process combination may be merged with an existing request. Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Diffstat (limited to 'block/elevator.c')
-rw-r--r--block/elevator.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/block/elevator.c b/block/elevator.c
index c0063f345c5..62c7a3069d3 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -51,6 +51,21 @@ static const int elv_hash_shift = 6;
51#define ELV_ON_HASH(rq) (!hlist_unhashed(&(rq)->hash)) 51#define ELV_ON_HASH(rq) (!hlist_unhashed(&(rq)->hash))
52 52
53/* 53/*
54 * Query io scheduler to see if the current process issuing bio may be
55 * merged with rq.
56 */
57static int elv_iosched_allow_merge(struct request *rq, struct bio *bio)
58{
59 request_queue_t *q = rq->q;
60 elevator_t *e = q->elevator;
61
62 if (e->ops->elevator_allow_merge_fn)
63 return e->ops->elevator_allow_merge_fn(q, rq, bio);
64
65 return 1;
66}
67
68/*
54 * can we safely merge with this request? 69 * can we safely merge with this request?
55 */ 70 */
56inline int elv_rq_merge_ok(struct request *rq, struct bio *bio) 71inline int elv_rq_merge_ok(struct request *rq, struct bio *bio)
@@ -65,12 +80,15 @@ inline int elv_rq_merge_ok(struct request *rq, struct bio *bio)
65 return 0; 80 return 0;
66 81
67 /* 82 /*
68 * same device and no special stuff set, merge is ok 83 * must be same device and not a special request
69 */ 84 */
70 if (rq->rq_disk == bio->bi_bdev->bd_disk && !rq->special) 85 if (rq->rq_disk != bio->bi_bdev->bd_disk || !rq->special)
71 return 1; 86 return 0;
72 87
73 return 0; 88 if (!elv_iosched_allow_merge(rq, bio))
89 return 0;
90
91 return 1;
74} 92}
75EXPORT_SYMBOL(elv_rq_merge_ok); 93EXPORT_SYMBOL(elv_rq_merge_ok);
76 94