Skip to content

Commit 3c9c708

Browse files
edumazetaxboe
authored andcommitted
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 <[email protected]> Cc: Tejun Heo <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Alan Cox <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b77874c commit 3c9c708

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

block/blk-ioc.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ void ioc_clear_queue(struct request_queue *q)
235235
int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
236236
{
237237
struct io_context *ioc;
238+
int ret;
238239

239240
ioc = kmem_cache_alloc_node(iocontext_cachep, gfp_flags | __GFP_ZERO,
240241
node);
@@ -262,9 +263,12 @@ int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
262263
task->io_context = ioc;
263264
else
264265
kmem_cache_free(iocontext_cachep, ioc);
266+
267+
ret = task->io_context ? 0 : -EBUSY;
268+
265269
task_unlock(task);
266270

267-
return 0;
271+
return ret;
268272
}
269273

270274
/**

0 commit comments

Comments
 (0)