From: Jens Axboe Date: Fri, 22 Dec 2006 08:38:53 +0000 (+0100) Subject: [PATCH] cfq-iosched: tighten allow merge criteria X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=719d34027e1a186e46a3952e8a24bf91ecc33837;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git [PATCH] cfq-iosched: tighten allow merge criteria The logic in cfq_allow_merge() wasn't clear enough - basically allow merging for the same queues only. Do a fast check for 'rq and bio both sync/async' before doing the cfqq hash lookup. This is verified to work with the fixed elv_try_merge() from commit bb4067e34159648d394943d5e2a011f838bff22f. Signed-off-by: Jens Axboe Signed-off-by: Linus Torvalds --- diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 9fc5eafa6c0e..4b4217d9be78 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c @@ -577,25 +577,20 @@ static int cfq_allow_merge(request_queue_t *q, struct request *rq, pid_t key; /* - * If bio is async or a write, always allow merge + * Disallow merge, if bio and rq aren't both sync or async */ - if (!bio_sync(bio) || rw == WRITE) - return 1; - - /* - * bio is sync. if request is not, disallow. - */ - if (!rq_is_sync(rq)) + if (!!bio_sync(bio) != !!rq_is_sync(rq)) return 0; /* - * Ok, both bio and request are sync. Allow merge if they are - * from the same queue. + * Lookup the cfqq that this bio will be queued with. Allow + * merge only if rq is queued there. */ - key = cfq_queue_pid(current, rw, 1); + key = cfq_queue_pid(current, rw, bio_sync(bio)); cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio); - if (cfqq != RQ_CFQQ(rq)) - return 0; + + if (cfqq == RQ_CFQQ(rq)) + return 1; return 1; }