Hold reference to module for each thread

To prevent removing cas_cache module when not all thread were stopped yet, each
of them should keep reference.

Signed-off-by: Michal Mielewczyk <michal.mielewczyk@intel.com>
This commit is contained in:
Michal Mielewczyk
2020-03-16 06:20:37 -04:00
parent 55d53867cc
commit f93019165f
2 changed files with 31 additions and 13 deletions

View File

@@ -54,7 +54,7 @@ static int _cas_io_queue_thread(void *data)
wait_for_completion(&info->compl);
printk(KERN_DEBUG "Thread %s stopped\n", info->name);
kfree(info);
do_exit(0);
module_put_and_exit(0);
return 0;
}
@@ -115,7 +115,7 @@ static int _cas_cleaner_thread(void *data)
wait_for_completion(&info->compl);
kfree(info);
do_exit(0);
module_put_and_exit(0);
return 0;
}
@@ -149,7 +149,7 @@ static int _cas_metadata_updater_thread(void *data)
wait_for_completion(&info->compl);
kfree(info);
do_exit(0);
module_put_and_exit(0);
return 0;
}
@@ -183,6 +183,8 @@ static int _cas_create_thread(struct cas_thread_info **pinfo,
}
info->thread = thread;
BUG_ON(!try_module_get(THIS_MODULE));
/* Affinitize thread to core */
if (cpu != CAS_CPUS_ALL)
kthread_bind(thread, cpu);