aboutsummaryrefslogtreecommitdiffstats
path: root/block/blk-ioc.c
diff options
context:
space:
mode:
authorEric Dumazet <edumazet@google.com>2012-05-31 07:39:05 -0400
committerJens Axboe <axboe@kernel.dk>2012-05-31 07:39:05 -0400
commit3c9c708c9fc967e389f85bc735e4c1f65d67334e (patch)
tree946eeefd4599bb1adafd87ad8f46d52382935001 /block/blk-ioc.c
parentb77874c9699522540e65aa4291e37a7e43533bf3 (diff)
block: avoid infinite loop in get_task_io_context()
Calling get_task_io_context() on a exiting task which isn't %current can loop forever. This triggers at boot time on my dev machine. BUG: soft lockup - CPU#3 stuck for 22s ! [mountall.1603] Fix this by making create_task_io_context() returns -EBUSY in this case to break the loop. Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Tejun Heo <tj@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Alan Cox <alan@linux.intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block/blk-ioc.c')
-rw-r--r--block/blk-ioc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/block/blk-ioc.c b/block/blk-ioc.c
index 1e2d53b04858..893b8007c657 100644
--- a/block/blk-ioc.c
+++ b/block/blk-ioc.c
@@ -235,6 +235,7 @@ void ioc_clear_queue(struct request_queue *q)
235int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node) 235int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
236{ 236{
237 struct io_context *ioc; 237 struct io_context *ioc;
238 int ret;
238 239
239 ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO, 240 ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO,
240 node); 241 node);
@@ -262,9 +263,12 @@ int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
262 task->io_context = ioc; 263 task->io_context = ioc;
263 else 264 else
264 kmem_cache_free(iocontext_cachep, ioc); 265 kmem_cache_free(iocontext_cachep, ioc);
266
267 ret = task->io_context ? 0 : -EBUSY;
268
265 task_unlock(task); 269 task_unlock(task);
266 270
267 return 0; 271 return ret;
268} 272}
269 273
270/** 274/**