History

When cfq I/O scheduler is selected, get_request() in __make_request() calls __cfq_get_queue(). __cfq_get_queue() finds an existing queue (struct cfq_queue) of the current process for the device and returns it. If it's not found, __cfq_get_queue() creates and returns a new one if __cfq_get_queue() is called with __GFP_WAIT flag, or __cfq_get_queue() returns NULL (this means that get_request() fails) if no __GFP_WAIT flag.

On the other hand, in __make_request(), get_request() is called without __GFP_WAIT flag at the first time. Thus, the get_request() fails when there is no existing queue, typically when it's called for the first I/O request of the process to the device. Though it will be followed by get_request_wait() for general case, __make_request() will just end the I/O with an error (EWOULDBLOCK) when the request was for read-ahead.

Kiyoshi Ueda committed 21 years ago

Commit db3b5841 parent c374f121 file · +6 −3Browse files

Unified · Split

drivers/block/cfq-iosched.c+6−3
@@ -1202,13 +1202,16 @@ retry: · 1201 unmodified lines
12021202 if (new_cfqq) {
12031203 cfqq = new_cfqq;
12041204 new_cfqq = NULL;
1205− } else if (gfp_mask & __GFP_WAIT) {
1205+ } else {
12061206 spin_unlock_irq(cfqd->queue->queue_lock);
12071207 new_cfqq = kmem_cache_alloc(cfq_pool, gfp_mask);
12081208 spin_lock_irq(cfqd->queue->queue_lock);
1209+
1210+ if (!new_cfqq && !(gfp_mask & __GFP_WAIT))
1211+ goto out;
1212+
12091213 goto retry;
1210− } else
1211− goto out;
1214+ }
12121215
12131216 memset(cfqq, 0, sizeof(*cfqq));
12141217