diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/sys/Makefile.am | 3 | ||||
-rw-r--r-- | include/sys/spa_impl.h | 3 | ||||
-rw-r--r-- | include/sys/vdev_removal.h | 2 | ||||
-rw-r--r-- | include/sys/zthr.h | 52 |
4 files changed, 57 insertions, 3 deletions
diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index f30c9427e..e73be52f3 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -125,7 +125,8 @@ COMMON_H = \ $(top_srcdir)/include/sys/zio.h \ $(top_srcdir)/include/sys/zio_impl.h \ $(top_srcdir)/include/sys/zio_priority.h \ - $(top_srcdir)/include/sys/zrlock.h + $(top_srcdir)/include/sys/zrlock.h \ + $(top_srcdir)/include/sys/zthr.h KERNEL_H = \ $(top_srcdir)/include/sys/zfs_ioctl.h \ diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h index 1741eb9e5..f49138d0f 100644 --- a/include/sys/spa_impl.h +++ b/include/sys/spa_impl.h @@ -45,6 +45,7 @@ #include <sys/bpobj.h> #include <sys/dsl_crypt.h> #include <sys/zfeature.h> +#include <sys/zthr.h> #include <zfeature_common.h> #ifdef __cplusplus @@ -268,7 +269,7 @@ struct spa { spa_condensing_indirect_phys_t spa_condensing_indirect_phys; spa_condensing_indirect_t *spa_condensing_indirect; - kthread_t *spa_condense_thread; /* thread doing condense. */ + zthr_t *spa_condense_zthr; /* zthr doing condense. */ char *spa_root; /* alternate root directory */ uint64_t spa_ena; /* spa-wide ereport ENA */ diff --git a/include/sys/vdev_removal.h b/include/sys/vdev_removal.h index 80ee09456..fb6c8c0ce 100644 --- a/include/sys/vdev_removal.h +++ b/include/sys/vdev_removal.h @@ -76,7 +76,7 @@ extern int spa_remove_init(spa_t *); extern void spa_restart_removal(spa_t *); extern int spa_condense_init(spa_t *); extern void spa_condense_fini(spa_t *); -extern void spa_condense_indirect_restart(spa_t *); +extern void spa_start_indirect_condensing_thread(spa_t *); extern void spa_vdev_condense_suspend(spa_t *); extern int spa_vdev_remove(spa_t *, uint64_t, boolean_t); extern void free_from_removing_vdev(vdev_t *, uint64_t, uint64_t, uint64_t); diff --git a/include/sys/zthr.h b/include/sys/zthr.h new file mode 100644 index 000000000..6bfb6b6c0 --- /dev/null +++ b/include/sys/zthr.h @@ -0,0 +1,52 @@ +/* + * CDDL HEADER START + * + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + * + * CDDL HEADER END + */ + + +/* + * Copyright (c) 2017 by Delphix. All rights reserved. + */ + +#ifndef _SYS_ZTHR_H +#define _SYS_ZTHR_H + +typedef struct zthr zthr_t; +typedef int (zthr_func_t)(void *, zthr_t *); +typedef boolean_t (zthr_checkfunc_t)(void *, zthr_t *); + +struct zthr { + kthread_t *zthr_thread; + kmutex_t zthr_lock; + kcondvar_t zthr_cv; + boolean_t zthr_cancel; + + zthr_checkfunc_t *zthr_checkfunc; + zthr_func_t *zthr_func; + void *zthr_arg; + int zthr_rc; +}; + +extern zthr_t *zthr_create(zthr_checkfunc_t checkfunc, + zthr_func_t *func, void *arg); +extern void zthr_exit(zthr_t *t, int rc); +extern void zthr_destroy(zthr_t *t); + +extern void zthr_wakeup(zthr_t *t); +extern int zthr_cancel(zthr_t *t); +extern void zthr_resume(zthr_t *t); + +extern boolean_t zthr_iscancelled(zthr_t *t); +extern boolean_t zthr_isrunning(zthr_t *t); + +#endif /* _SYS_ZTHR_H */ |