diff options
author | Jens Axboe <axboe@suse.de> | 2006-06-08 02:49:06 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-06-08 18:14:23 -0400 |
commit | bc1c116974a5c3f498112a6f175d3e4a8cd5bdbc (patch) | |
tree | 69ea68db91fb871cd24a0a5c5045abbe9c77bd3a /block/cfq-iosched.c | |
parent | 26e780e8ef1cc3ef581a07aafe2346bb5a07b4f9 (diff) |
[PATCH] elevator switching race
There's a race between shutting down one io scheduler and firing up the
next, in which a new io could enter and cause the io scheduler to be
invoked with bad or NULL data.
To fix this, we need to maintain the queue lock for a bit longer.
Unfortunately we cannot do that, since the elevator init requires to be
run without the lock held. This isn't easily fixable, without also
changing the mempool API. So split the initialization into two parts,
and alloc-init operation and an attach operation. Then we can
preallocate the io scheduler and related structures, and run the attach
inside the lock after we detach the old one.
This patch has survived 30 minutes of 1 second io scheduler switching
with a very busy io load.
Signed-off-by: Jens Axboe <axboe@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'block/cfq-iosched.c')
-rw-r--r-- | block/cfq-iosched.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/block/cfq-iosched.c b/block/cfq-iosched.c index 8e9d84825e1c..a46d030e092a 100644 --- a/block/cfq-iosched.c +++ b/block/cfq-iosched.c | |||
@@ -2251,14 +2251,14 @@ static void cfq_exit_queue(elevator_t *e) | |||
2251 | kfree(cfqd); | 2251 | kfree(cfqd); |
2252 | } | 2252 | } |
2253 | 2253 | ||
2254 | static int cfq_init_queue(request_queue_t *q, elevator_t *e) | 2254 | static void *cfq_init_queue(request_queue_t *q, elevator_t *e) |
2255 | { | 2255 | { |
2256 | struct cfq_data *cfqd; | 2256 | struct cfq_data *cfqd; |
2257 | int i; | 2257 | int i; |
2258 | 2258 | ||
2259 | cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL); | 2259 | cfqd = kmalloc(sizeof(*cfqd), GFP_KERNEL); |
2260 | if (!cfqd) | 2260 | if (!cfqd) |
2261 | return -ENOMEM; | 2261 | return NULL; |
2262 | 2262 | ||
2263 | memset(cfqd, 0, sizeof(*cfqd)); | 2263 | memset(cfqd, 0, sizeof(*cfqd)); |
2264 | 2264 | ||
@@ -2288,8 +2288,6 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) | |||
2288 | for (i = 0; i < CFQ_QHASH_ENTRIES; i++) | 2288 | for (i = 0; i < CFQ_QHASH_ENTRIES; i++) |
2289 | INIT_HLIST_HEAD(&cfqd->cfq_hash[i]); | 2289 | INIT_HLIST_HEAD(&cfqd->cfq_hash[i]); |
2290 | 2290 | ||
2291 | e->elevator_data = cfqd; | ||
2292 | |||
2293 | cfqd->queue = q; | 2291 | cfqd->queue = q; |
2294 | 2292 | ||
2295 | cfqd->max_queued = q->nr_requests / 4; | 2293 | cfqd->max_queued = q->nr_requests / 4; |
@@ -2316,14 +2314,14 @@ static int cfq_init_queue(request_queue_t *q, elevator_t *e) | |||
2316 | cfqd->cfq_slice_async_rq = cfq_slice_async_rq; | 2314 | cfqd->cfq_slice_async_rq = cfq_slice_async_rq; |
2317 | cfqd->cfq_slice_idle = cfq_slice_idle; | 2315 | cfqd->cfq_slice_idle = cfq_slice_idle; |
2318 | 2316 | ||
2319 | return 0; | 2317 | return cfqd; |
2320 | out_crqpool: | 2318 | out_crqpool: |
2321 | kfree(cfqd->cfq_hash); | 2319 | kfree(cfqd->cfq_hash); |
2322 | out_cfqhash: | 2320 | out_cfqhash: |
2323 | kfree(cfqd->crq_hash); | 2321 | kfree(cfqd->crq_hash); |
2324 | out_crqhash: | 2322 | out_crqhash: |
2325 | kfree(cfqd); | 2323 | kfree(cfqd); |
2326 | return -ENOMEM; | 2324 | return NULL; |
2327 | } | 2325 | } |
2328 | 2326 | ||
2329 | static void cfq_slab_kill(void) | 2327 | static void cfq_slab_kill(void) |