zfs_context.h revision 260763
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25/*
26 * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
27 * Copyright (c) 2013 by Delphix. All rights reserved.
28 */
29
30#ifndef _SYS_ZFS_CONTEXT_H
31#define	_SYS_ZFS_CONTEXT_H
32
33#ifdef	__cplusplus
34extern "C" {
35#endif
36
37#include <sys/param.h>
38#include <sys/stdint.h>
39#include <sys/note.h>
40#include <sys/kernel.h>
41#include <sys/debug.h>
42#include <sys/systm.h>
43#include <sys/proc.h>
44#include <sys/sysmacros.h>
45#include <sys/bitmap.h>
46#include <sys/cmn_err.h>
47#include <sys/kmem.h>
48#include <sys/taskq.h>
49#include <sys/taskqueue.h>
50#include <sys/systm.h>
51#include <sys/conf.h>
52#include <sys/mutex.h>
53#include <sys/rwlock.h>
54#include <sys/kcondvar.h>
55#include <sys/random.h>
56#include <sys/byteorder.h>
57#include <sys/systm.h>
58#include <sys/list.h>
59#include <sys/zfs_debug.h>
60#include <sys/sysevent.h>
61#include <sys/uio.h>
62#include <sys/dirent.h>
63#include <sys/time.h>
64#include <sys/uio.h>
65#include <sys/fcntl.h>
66#include <sys/limits.h>
67#include <sys/string.h>
68#include <sys/bio.h>
69#include <sys/buf.h>
70#include <sys/cred.h>
71#include <sys/sdt.h>
72#include <sys/file.h>
73#include <sys/vfs.h>
74#include <sys/sysctl.h>
75#include <sys/sbuf.h>
76#include <sys/priv.h>
77#include <sys/kdb.h>
78#include <sys/ktr.h>
79#include <sys/stack.h>
80#include <sys/lockf.h>
81#include <sys/pathname.h>
82#include <sys/policy.h>
83#include <sys/refstr.h>
84#include <sys/zone.h>
85#include <sys/eventhandler.h>
86#include <sys/extattr.h>
87#include <sys/misc.h>
88#include <sys/sig.h>
89#include <sys/osd.h>
90#include <sys/sysevent/dev.h>
91#include <sys/sysevent/eventdefs.h>
92#include <sys/u8_textprep.h>
93#include <sys/fm/util.h>
94#include <sys/sunddi.h>
95#ifdef illumos
96#include <sys/cyclic.h>
97#include <sys/callo.h>
98#else	/* FreeBSD */
99#include <sys/callout.h>
100#endif
101#include <sys/disp.h>
102#include <machine/stdarg.h>
103
104#include <vm/vm.h>
105#include <vm/vm_page.h>
106#include <vm/vm_object.h>
107#include <vm/vm_kern.h>
108#include <vm/vm_map.h>
109/* There is clash. vm_map.h defines the two below and vdev_cache.c use them. */
110#ifdef min_offset
111#undef min_offset
112#endif
113#ifdef max_offset
114#undef max_offset
115#endif
116#include <vm/vm_extern.h>
117#include <vm/vnode_pager.h>
118
119#define	CPU_SEQID	(curcpu)
120
121#define	tsd_create(keyp, destructor)	do {				\
122	*(keyp) = osd_thread_register((destructor));			\
123	KASSERT(*(keyp) > 0, ("cannot register OSD"));			\
124} while (0)
125#define	tsd_destroy(keyp)		osd_thread_deregister(*(keyp))
126#define	tsd_get(key)			osd_thread_get(curthread, (key))
127#define	tsd_set(key, value)		osd_thread_set(curthread, (key), (value))
128
129#ifdef	__cplusplus
130}
131#endif
132
133extern int zfs_debug_level;
134extern struct mtx zfs_debug_mtx;
135#define	ZFS_LOG(lvl, ...)	do {					\
136	if (((lvl) & 0xff) <= zfs_debug_level) {			\
137		mtx_lock(&zfs_debug_mtx);				\
138		printf("%s:%u[%d]: ", __func__, __LINE__, (lvl));	\
139		printf(__VA_ARGS__);					\
140		printf("\n");						\
141		if ((lvl) & 0x100)					\
142			kdb_backtrace();				\
143		mtx_unlock(&zfs_debug_mtx);				\
144	}								\
145} while (0)
146
147#define	sys_shutdown	rebooting
148
149#endif	/* _SYS_ZFS_CONTEXT_H */
150