Skip to content

Commit

Permalink
block: avoid infinite loop in get_task_io_context()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Alan Cox <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Eric Dumazet authored and axboe committed May 31, 2012
1 parent b77874c commit 3c9c708
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion block/blk-ioc.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ void ioc_clear_queue(struct request_queue *q)
int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
{
struct io_context *ioc;
int ret;

ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO,
node);
Expand Down Expand Up @@ -262,9 +263,12 @@ int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
task->io_context = ioc;
else
kmem_cache_free(iocontext_cachep, ioc);

ret = task->io_context ? 0 : -EBUSY;

task_unlock(task);

return 0;
return ret;
}

/**
Expand Down

0 comments on commit 3c9c708

Please sign in to comment.