Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c9c708c authored by Eric Dumazet's avatar Eric Dumazet Committed by Jens Axboe
Browse files

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: default avatarEric 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: default avatarJens Axboe <axboe@kernel.dk>
parent b77874c9
Loading
Loading
Loading
Loading
+5 −1
Original line number Original line Diff line number Diff line
@@ -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)
int create_task_io_context(struct task_struct *task, gfp_t gfp_flags, int node)
{
{
	struct io_context *ioc;
	struct io_context *ioc;
	int ret;


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

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

	task_unlock(task);
	task_unlock(task);


	return 0;
	return ret;
}
}


/**
/**