[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 <jens.axboe@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Jens Axboe and committed by Linus Torvalds 719d3402 c2fda5fe

+8 -13
+8 -13
block/cfq-iosched.c
··· 577 pid_t key; 578 579 /* 580 - * If bio is async or a write, always allow merge 581 */ 582 - if (!bio_sync(bio) || rw == WRITE) 583 - return 1; 584 - 585 - /* 586 - * bio is sync. if request is not, disallow. 587 - */ 588 - if (!rq_is_sync(rq)) 589 return 0; 590 591 /* 592 - * Ok, both bio and request are sync. Allow merge if they are 593 - * from the same queue. 594 */ 595 - key = cfq_queue_pid(current, rw, 1); 596 cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio); 597 - if (cfqq != RQ_CFQQ(rq)) 598 - return 0; 599 600 return 1; 601 }
··· 577 pid_t key; 578 579 /* 580 + * Disallow merge, if bio and rq aren't both sync or async 581 */ 582 + if (!!bio_sync(bio) != !!rq_is_sync(rq)) 583 return 0; 584 585 /* 586 + * Lookup the cfqq that this bio will be queued with. Allow 587 + * merge only if rq is queued there. 588 */ 589 + key = cfq_queue_pid(current, rw, bio_sync(bio)); 590 cfqq = cfq_find_cfq_hash(cfqd, key, current->ioprio); 591 + 592 + if (cfqq == RQ_CFQQ(rq)) 593 + return 1; 594 595 return 1; 596 }