diff options
| author | Martin Matuska <mm@FreeBSD.org> | 2013-03-01 21:01:45 +0000 |
|---|---|---|
| committer | Martin Matuska <mm@FreeBSD.org> | 2013-03-01 21:01:45 +0000 |
| commit | 577227be9d7e7e691365c6df7c2c70a0cd5c0d96 (patch) | |
| tree | 019ac6a39f50b650c1907965f081edb16c3479b4 /lib/libzpool | |
| parent | b9192d31aabb73ffd7d70eb6dd383aa9f924dc0a (diff) | |
Notes
Diffstat (limited to 'lib/libzpool')
| -rw-r--r-- | lib/libzpool/common/kernel.c | 5 | ||||
| -rw-r--r-- | lib/libzpool/common/sys/zfs_context.h | 15 |
2 files changed, 19 insertions, 1 deletions
diff --git a/lib/libzpool/common/kernel.c b/lib/libzpool/common/kernel.c index cc0d5428beeb..96280941a646 100644 --- a/lib/libzpool/common/kernel.c +++ b/lib/libzpool/common/kernel.c @@ -34,6 +34,7 @@ #include <sys/stat.h> #include <sys/processor.h> #include <sys/zfs_context.h> +#include <sys/rrwlock.h> #include <sys/zmod.h> #include <sys/utsname.h> #include <sys/systeminfo.h> @@ -859,6 +860,8 @@ umem_out_of_memory(void) void kernel_init(int mode) { + extern uint_t rrw_tsd_key; + umem_nofail_callback(umem_out_of_memory); physmem = sysconf(_SC_PHYS_PAGES); @@ -877,6 +880,8 @@ kernel_init(int mode) mutex_init(&cpu_lock, NULL, MUTEX_DEFAULT, NULL); spa_init(mode); + + tsd_create(&rrw_tsd_key, rrw_tsd_destroy); } void diff --git a/lib/libzpool/common/sys/zfs_context.h b/lib/libzpool/common/sys/zfs_context.h index bcb27cf1a5cd..7802da4e2b00 100644 --- a/lib/libzpool/common/sys/zfs_context.h +++ b/lib/libzpool/common/sys/zfs_context.h @@ -61,6 +61,8 @@ extern "C" { #include <dirent.h> #include <time.h> #include <procfs.h> +#include <pthread.h> +#include <sys/debug.h> #include <libsysevent.h> #include <sys/note.h> #include <sys/types.h> @@ -224,6 +226,9 @@ typedef int krw_t; #undef RW_WRITE_HELD #define RW_WRITE_HELD(x) _rw_write_held(&(x)->rw_lock) +#undef RW_LOCK_HELD +#define RW_LOCK_HELD(x) (RW_READ_HELD(x) || RW_WRITE_HELD(x)) + extern void rw_init(krwlock_t *rwlp, char *name, int type, void *arg); extern void rw_destroy(krwlock_t *rwlp); extern void rw_enter(krwlock_t *rwlp, krw_t rw); @@ -253,6 +258,14 @@ extern void cv_signal(kcondvar_t *cv); extern void cv_broadcast(kcondvar_t *cv); /* + * Thread-specific data + */ +#define tsd_get(k) pthread_getspecific(k) +#define tsd_set(k, v) pthread_setspecific(k, v) +#define tsd_create(kp, d) pthread_key_create(kp, d) +#define tsd_destroy(kp) /* nothing */ + +/* * kstat creation, installation and deletion */ extern kstat_t *kstat_create(const char *, int, @@ -519,7 +532,7 @@ typedef struct callb_cpr { #define INGLOBALZONE(z) (1) extern char *kmem_asprintf(const char *fmt, ...); -#define strfree(str) kmem_free((str), strlen(str)+1) +#define strfree(str) kmem_free((str), strlen(str) + 1) /* * Hostname information |
