From e39eecab49d83e4bd5a567b34b5298faf278dc52 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Sat, 7 Mar 2020 15:22:30 -0500 Subject: [PATCH 1/2] Don't try to stop non running thread If _cas_create_thread() thread failed, queue should be stopped by ocf. One of steps done during queue stop is stopping kernel thread. To avoid stopping thread which is not running, additional check was added in _cas_stop_thread(). Signed-off-by: Michal Mielewczyk --- modules/cas_cache/threads.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/cas_cache/threads.c b/modules/cas_cache/threads.c index 8c610c2..36b3a4e 100644 --- a/modules/cas_cache/threads.c +++ b/modules/cas_cache/threads.c @@ -207,7 +207,7 @@ static void _cas_start_thread(struct cas_thread_info *info) static void _cas_stop_thread(struct cas_thread_info *info) { - if (info->running && info->thread) { + if (info && info->running && info->thread) { reinit_completion(&info->compl); atomic_set(&info->stop, 1); wake_up(&info->wq); From 917577480fdabf92a3996133cecae8c64ddd07e2 Mon Sep 17 00:00:00 2001 From: Michal Mielewczyk Date: Sat, 7 Mar 2020 16:10:36 -0500 Subject: [PATCH 2/2] Remove `running` field from cas thread info Signed-off-by: Michal Mielewczyk --- modules/cas_cache/threads.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/cas_cache/threads.c b/modules/cas_cache/threads.c index 36b3a4e..2513fd5 100644 --- a/modules/cas_cache/threads.c +++ b/modules/cas_cache/threads.c @@ -17,7 +17,6 @@ struct cas_thread_info { atomic_t kicked; struct task_struct *thread; char name[MAX_THREAD_NAME_SIZE]; - bool running; }; static int _cas_io_queue_thread(void *data) @@ -200,14 +199,12 @@ static void _cas_start_thread(struct cas_thread_info *info) wake_up_process(info->thread); wait_for_completion(&info->compl); - info->running = true; - printk(KERN_DEBUG "Thread %s started\n", info->name); } static void _cas_stop_thread(struct cas_thread_info *info) { - if (info && info->running && info->thread) { + if (info && info->thread) { reinit_completion(&info->compl); atomic_set(&info->stop, 1); wake_up(&info->wq);