diff options
author | Tejun Heo <tj@kernel.org> | 2012-03-05 16:15:24 -0500 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-03-06 15:27:24 -0500 |
commit | 24acfc34fba0b4f62ef9d5c2616eb0faa802b606 (patch) | |
tree | 42d07b0e4ad922b24853fe542cb9ab543aa8174c /block/blk-ioc.c | |
parent | b679281a6410676a41b175c5a185150a1ae42f9d (diff) |
block: interface update for ioc/icq creation functions
Make the following interface updates to prepare for future ioc related
changes.
* create_io_context() returning ioc only works for %current because it
doesn't increment ref on the ioc. Drop @task parameter from it and
always assume %current.
* Make create_io_context_slowpath() return 0 or -errno and rename it
to create_task_io_context().
* Make ioc_create_icq() take @ioc as parameter instead of assuming
that of %current. The caller, get_request(), is updated to create
ioc explicitly and then pass it into ioc_create_icq().
Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Vivek Goyal <vgoyal@redhat.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-ioc.c')
-rw-r--r-- | block/blk-ioc.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c index 92bf55540d87..10928740b5da 100644 --- a/block/blk-ioc.c +++ b/block/blk-ioc.c | |||
@@ -212,15 +212,14 @@ void ioc_clear_queue(struct request_queue *q) | |||
212 | } | 212 | } |
213 | } | 213 | } |
214 | 214 | ||
215 | void create_io_context_slowpath(struct task_struct *task, gfp_t gfp_flags, | 215 | int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node) |
216 | int node) | ||
217 | { | 216 | { |
218 | struct io_context *ioc; | 217 | struct io_context *ioc; |
219 | 218 | ||
220 | ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO, | 219 | ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO, |
221 | node); | 220 | node); |
222 | if (unlikely(!ioc)) | 221 | if (unlikely(!ioc)) |
223 | return; | 222 | return -ENOMEM; |
224 | 223 | ||
225 | /* initialize */ | 224 | /* initialize */ |
226 | atomic_long_set(&ioc->refcount, 1); | 225 | atomic_long_set(&ioc->refcount, 1); |
@@ -244,6 +243,8 @@ void create_io_context_slowpath(struct task_struct *task, gfp_t gfp_flags, | |||
244 | else | 243 | else |
245 | kmem_cache_free(iocontext_cachep, ioc); | 244 | kmem_cache_free(iocontext_cachep, ioc); |
246 | task_unlock(task); | 245 | task_unlock(task); |
246 | |||
247 | return 0; | ||
247 | } | 248 | } |
248 | 249 | ||
249 | /** | 250 | /** |
@@ -275,7 +276,7 @@ struct io_context *get_task_io_context(struct task_struct *task, | |||
275 | return ioc; | 276 | return ioc; |
276 | } | 277 | } |
277 | task_unlock(task); | 278 | task_unlock(task); |
278 | } while (create_io_context(task, gfp_flags, node)); | 279 | } while (!create_task_io_context(task, gfp_flags, node)); |
279 | 280 | ||
280 | return NULL; | 281 | return NULL; |
281 | } | 282 | } |
@@ -319,26 +320,23 @@ EXPORT_SYMBOL(ioc_lookup_icq); | |||
319 | 320 | ||
320 | /** | 321 | /** |
321 | * ioc_create_icq - create and link io_cq | 322 | * ioc_create_icq - create and link io_cq |
323 | * @ioc: io_context of interest | ||
322 | * @q: request_queue of interest | 324 | * @q: request_queue of interest |
323 | * @gfp_mask: allocation mask | 325 | * @gfp_mask: allocation mask |
324 | * | 326 | * |
325 | * Make sure io_cq linking %current->io_context and @q exists. If either | 327 | * Make sure io_cq linking @ioc and @q exists. If icq doesn't exist, they |
326 | * io_context and/or icq don't exist, they will be created using @gfp_mask. | 328 | * will be created using @gfp_mask. |
327 | * | 329 | * |
328 | * The caller is responsible for ensuring @ioc won't go away and @q is | 330 | * The caller is responsible for ensuring @ioc won't go away and @q is |
329 | * alive and will stay alive until this function returns. | 331 | * alive and will stay alive until this function returns. |
330 | */ | 332 | */ |
331 | struct io_cq *ioc_create_icq(struct request_queue *q, gfp_t gfp_mask) | 333 | struct io_cq *ioc_create_icq(struct io_context *ioc, struct request_queue *q, |
334 | gfp_t gfp_mask) | ||
332 | { | 335 | { |
333 | struct elevator_type *et = q->elevator->type; | 336 | struct elevator_type *et = q->elevator->type; |
334 | struct io_context *ioc; | ||
335 | struct io_cq *icq; | 337 | struct io_cq *icq; |
336 | 338 | ||
337 | /* allocate stuff */ | 339 | /* allocate stuff */ |
338 | ioc = create_io_context(current, gfp_mask, q->node); | ||
339 | if (!ioc) | ||
340 | return NULL; | ||
341 | |||
342 | icq = kmem_cache_alloc_node(et->icq_cache, gfp_mask | __GFP_ZERO, | 340 | icq = kmem_cache_alloc_node(et->icq_cache, gfp_mask | __GFP_ZERO, |
343 | q->node); | 341 | q->node); |
344 | if (!icq) | 342 | if (!icq) |