Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cfq-iosched: fix alias + front merge bug

There's a really rare and obscure bug in CFQ, that causes a crash in
cfq_dispatch_insert() due to rq == NULL. One example of the resulting
oops is seen here:

http://lkml.org/lkml/2007/4/15/41

Neil correctly diagnosed the situation for how this can happen: if two
concurrent requests with the exact same sector number (due to direct IO
or aliasing between MD and the raw device access), the alias handling
will add the request to the sortlist, but next_rq remains NULL.

Read the more complete analysis at:

http://lkml.org/lkml/2007/4/25/57

This looks like it requires md to trigger, even though it should
potentially be possible to due with O_DIRECT (at least if you edit the
kernel and doctor some of the unplug calls).

The fix is to move the ->next_rq update to when we add a request to the
rbtree. Then we remove the possibility for a request to exist in the
rbtree code, but not have ->next_rq correctly updated.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Jens Axboe and committed by
Linus Torvalds
5044eed4 a23cf14b

+6 -6
+6 -6
block/cfq-iosched.c
··· 532 532 533 533 if (!cfq_cfqq_on_rr(cfqq)) 534 534 cfq_add_cfqq_rr(cfqd, cfqq); 535 + 536 + /* 537 + * check if this request is a better next-serve candidate 538 + */ 539 + cfqq->next_rq = cfq_choose_req(cfqd, cfqq->next_rq, rq); 540 + BUG_ON(!cfqq->next_rq); 535 541 } 536 542 537 543 static inline void ··· 1643 1637 1644 1638 if (rq_is_meta(rq)) 1645 1639 cfqq->meta_pending++; 1646 - 1647 - /* 1648 - * check if this request is a better next-serve candidate)) { 1649 - */ 1650 - cfqq->next_rq = cfq_choose_req(cfqd, cfqq->next_rq, rq); 1651 - BUG_ON(!cfqq->next_rq); 1652 1640 1653 1641 /* 1654 1642 * we never wait for an async request and we don't allow preemption