diff options
author | Ryan Moeller <[email protected]> | 2020-09-03 23:09:52 -0400 |
---|---|---|
committer | GitHub <[email protected]> | 2020-09-03 20:09:52 -0700 |
commit | cd80273909184426d5f38050c3163de43031098f (patch) | |
tree | e17c41c2770c7398af7d2027c6240c3a2a912326 | |
parent | f3064162ba41778577b7fb72930d6c207743ec5c (diff) |
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 <[email protected]>
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Ryan Moeller <[email protected]>
Closes #10881
-rw-r--r-- | module/zfs/zthr.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/module/zfs/zthr.c b/module/zfs/zthr.c index e230cd2cb..5ac2e3046 100644 --- a/module/zfs/zthr.c +++ b/module/zfs/zthr.c @@ -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); |