mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
Retain thread name when resuming a zthr
When created, a zthr is given a name to identify it by. This name is lost when a cancelled zthr is resumed. Retain the name of a zthr so it can be used when resuming. Reviewed-by: Serapheim Dimitropoulos <serapheim@delphix.com> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@iXsystems.com> Closes #10881
This commit is contained in:
parent
f3064162ba
commit
cd80273909
@ -56,7 +56,7 @@
|
||||
*
|
||||
* == ZTHR creation
|
||||
*
|
||||
* Every zthr needs three inputs to start running:
|
||||
* Every zthr needs four inputs to start running:
|
||||
*
|
||||
* 1] A user-defined checker function (checkfunc) that decides whether
|
||||
* the zthr should start working or go to sleep. The function should
|
||||
@ -72,6 +72,9 @@
|
||||
* 3] A void args pointer that will be passed to checkfunc and func
|
||||
* implicitly by the infrastructure.
|
||||
*
|
||||
* 4] A name for the thread. This string must be valid for the lifetime
|
||||
* of the zthr.
|
||||
*
|
||||
* The reason why the above API needs two different functions,
|
||||
* instead of one that both checks and does the work, has to do with
|
||||
* the zthr's internal state lock (zthr_state_lock) and the allowed
|
||||
@ -221,6 +224,7 @@ struct zthr {
|
||||
zthr_checkfunc_t *zthr_checkfunc;
|
||||
zthr_func_t *zthr_func;
|
||||
void *zthr_arg;
|
||||
const char *zthr_name;
|
||||
};
|
||||
|
||||
static void
|
||||
@ -291,6 +295,7 @@ zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc,
|
||||
t->zthr_func = func;
|
||||
t->zthr_arg = arg;
|
||||
t->zthr_sleep_timeout = max_sleep;
|
||||
t->zthr_name = zthr_name;
|
||||
|
||||
t->zthr_thread = thread_create_named(zthr_name, NULL, 0,
|
||||
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
|
||||
@ -417,8 +422,8 @@ zthr_resume(zthr_t *t)
|
||||
* no-op.
|
||||
*/
|
||||
if (t->zthr_thread == NULL) {
|
||||
t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t,
|
||||
0, &p0, TS_RUN, minclsyspri);
|
||||
t->zthr_thread = thread_create_named(t->zthr_name, NULL, 0,
|
||||
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
|
||||
}
|
||||
|
||||
mutex_exit(&t->zthr_state_lock);
|
||||
|
Loading…
Reference in New Issue
Block a user