mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-11-18 02:20:59 +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
e28635396a
commit
a1e03186fd
@ -56,7 +56,7 @@
|
|||||||
*
|
*
|
||||||
* == ZTHR creation
|
* == 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
|
* 1] A user-defined checker function (checkfunc) that decides whether
|
||||||
* the zthr should start working or go to sleep. The function should
|
* 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
|
* 3] A void args pointer that will be passed to checkfunc and func
|
||||||
* implicitly by the infrastructure.
|
* 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,
|
* The reason why the above API needs two different functions,
|
||||||
* instead of one that both checks and does the work, has to do with
|
* 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
|
* the zthr's internal state lock (zthr_state_lock) and the allowed
|
||||||
@ -221,6 +224,7 @@ struct zthr {
|
|||||||
zthr_checkfunc_t *zthr_checkfunc;
|
zthr_checkfunc_t *zthr_checkfunc;
|
||||||
zthr_func_t *zthr_func;
|
zthr_func_t *zthr_func;
|
||||||
void *zthr_arg;
|
void *zthr_arg;
|
||||||
|
const char *zthr_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -291,6 +295,7 @@ zthr_create_timer(const char *zthr_name, zthr_checkfunc_t *checkfunc,
|
|||||||
t->zthr_func = func;
|
t->zthr_func = func;
|
||||||
t->zthr_arg = arg;
|
t->zthr_arg = arg;
|
||||||
t->zthr_sleep_timeout = max_sleep;
|
t->zthr_sleep_timeout = max_sleep;
|
||||||
|
t->zthr_name = zthr_name;
|
||||||
|
|
||||||
t->zthr_thread = thread_create_named(zthr_name, NULL, 0,
|
t->zthr_thread = thread_create_named(zthr_name, NULL, 0,
|
||||||
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
|
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
|
||||||
@ -417,8 +422,8 @@ zthr_resume(zthr_t *t)
|
|||||||
* no-op.
|
* no-op.
|
||||||
*/
|
*/
|
||||||
if (t->zthr_thread == NULL) {
|
if (t->zthr_thread == NULL) {
|
||||||
t->zthr_thread = thread_create(NULL, 0, zthr_procedure, t,
|
t->zthr_thread = thread_create_named(t->zthr_name, NULL, 0,
|
||||||
0, &p0, TS_RUN, minclsyspri);
|
zthr_procedure, t, 0, &p0, TS_RUN, minclsyspri);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_exit(&t->zthr_state_lock);
|
mutex_exit(&t->zthr_state_lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user