/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
- * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright (c) 2012, 2014 by Delphix. All rights reserved.
*/
#ifndef _SYS_ZFS_CONTEXT_H
#include <sys/bitmap.h>
#include <sys/cmn_err.h>
#include <sys/kmem.h>
+#include <sys/kmem_cache.h>
+#include <sys/vmem.h>
#include <sys/taskq.h>
#include <sys/buf.h>
#include <sys/param.h>
#include <sys/sunddi.h>
#include <sys/ctype.h>
#include <sys/disp.h>
+#include <sys/trace.h>
#include <linux/dcache_compat.h>
+#include <linux/utsname_compat.h>
#else /* _KERNEL */
#include <string.h>
#include <strings.h>
#include <pthread.h>
+#include <synch.h>
#include <assert.h>
#include <alloca.h>
#include <umem.h>
#include <sys/fm/fs/zfs.h>
#include <sys/sunddi.h>
#include <sys/debug.h>
+#include <sys/utsname.h>
/*
* Stack
#define CE_PANIC 3 /* panic */
#define CE_IGNORE 4 /* print nothing */
-extern int aok;
-
/*
* ZFS debugging
*/
extern void dprintf_setup(int *argc, char **argv);
-extern void __dprintf(const char *file, const char *func,
- int line, const char *fmt, ...);
+
extern void cmn_err(int, const char *, ...);
-extern void vcmn_err(int, const char *, __va_list);
+extern void vcmn_err(int, const char *, va_list);
extern void panic(const char *, ...);
-extern void vpanic(const char *, __va_list);
+extern void vpanic(const char *, va_list);
#define fm_panic panic
-#ifdef __sun
+extern int aok;
+
/*
* DTrace SDT probes have different signatures in userland than they do in
* kernel. If they're being used in kernel code, re-define them out of
* "return (SET_ERROR(log_error(EINVAL, info)));" would log the error twice).
*/
#define SET_ERROR(err) (ZFS_SET_ERROR(err), err)
-#else
-#define SET_ERROR(err) (err)
-#endif
+
/*
- * Threads
+ * Threads. TS_STACK_MIN is dictated by the minimum allowed pthread stack
+ * size. While TS_STACK_MAX is somewhat arbitrary, it was selected to be
+ * large enough for the expected stack depth while small enough to avoid
+ * exhausting address space with high thread counts.
*/
#define TS_MAGIC 0x72f158ab4261e538ull
#define TS_RUN 0x00000002
-#ifdef __linux__
-#define STACK_SIZE 8192 /* Linux x86 and amd64 */
-#else
-#define STACK_SIZE 24576 /* Solaris */
-#endif
+#define TS_STACK_MIN PTHREAD_STACK_MIN
+#define TS_STACK_MAX (256 * 1024)
/* in libzpool, p0 exists only to have its address taken */
typedef struct proc {
#define KM_SLEEP UMEM_NOFAIL
#define KM_PUSHPAGE KM_SLEEP
#define KM_NOSLEEP UMEM_DEFAULT
-#define KM_NODEBUG 0x0
#define KMC_NODEBUG UMC_NODEBUG
#define KMC_KMEM 0x0
#define KMC_VMEM 0x0
#define TQ_SLEEP KM_SLEEP /* Can block for memory */
#define TQ_NOSLEEP KM_NOSLEEP /* cannot block for memory; may fail */
-#define TQ_PUSHPAGE KM_PUSHPAGE /* Cannot perform I/O */
#define TQ_NOQUEUE 0x02 /* Do not enqueue if can't dispatch */
#define TQ_FRONT 0x08 /* Queue in front */
#define ddi_get_lbolt64() (gethrtime() >> 23)
#define hz 119 /* frequency when using gethrtime() >> 23 for lbolt */
+#define ddi_time_before(a, b) (a < b)
+#define ddi_time_after(a, b) ddi_time_before(b, a)
+#define ddi_time_before_eq(a, b) (!ddi_time_after(a, b))
+#define ddi_time_after_eq(a, b) ddi_time_before_eq(b, a)
+
+#define ddi_time_before64(a, b) (a < b)
+#define ddi_time_after64(a, b) ddi_time_before64(b, a)
+#define ddi_time_before_eq64(a, b) (!ddi_time_after64(a, b))
+#define ddi_time_after_eq64(a, b) ddi_time_before_eq64(b, a)
+
extern void delay(clock_t ticks);
#define SEC_TO_TICK(sec) ((sec) * hz)
extern uint64_t physmem;
-extern int highbit(ulong_t i);
+extern int highbit64(uint64_t i);
extern int random_get_bytes(uint8_t *ptr, size_t len);
extern int random_get_pseudo_bytes(uint8_t *ptr, size_t len);
extern int ddi_strtoull(const char *str, char **nptr, int base,
u_longlong_t *result);
+typedef struct utsname utsname_t;
+extern utsname_t *utsname(void);
+
/* ZFS Boot Related stuff. */
struct _buf {
(void) nanosleep(&ts, NULL); \
} while (0)
-#endif /* _KERNEL */
+typedef int fstrans_cookie_t;
+
+extern fstrans_cookie_t spl_fstrans_mark(void);
+extern void spl_fstrans_unmark(fstrans_cookie_t);
+extern int spl_fstrans_check(void);
+#endif /* _KERNEL */
#endif /* _SYS_ZFS_CONTEXT_H */