]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/zfs_context.h
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / sys / cddl / contrib / opensolaris / uts / common / fs / zfs / sys / zfs_context.h
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 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25
26 #ifndef _SYS_ZFS_CONTEXT_H
27 #define _SYS_ZFS_CONTEXT_H
28
29 #pragma ident   "%Z%%M% %I%     %E% SMI"
30
31 #ifdef  __cplusplus
32 extern "C" {
33 #endif
34
35 #include <sys/param.h>
36 #include <sys/stdint.h>
37 #include <sys/note.h>
38 #include <sys/kernel.h>
39 #include <sys/debug.h>
40 #include <sys/systm.h>
41 #include <sys/proc.h>
42 #include <sys/sysmacros.h>
43 #include <sys/bitmap.h>
44 #include <sys/cmn_err.h>
45 #include <sys/kmem.h>
46 #include <sys/taskq.h>
47 #include <sys/taskqueue.h>
48 #include <sys/systm.h>
49 #include <sys/conf.h>
50 #include <sys/mutex.h>
51 #include <sys/rwlock.h>
52 #include <sys/kcondvar.h>
53 #include <sys/random.h>
54 #include <sys/byteorder.h>
55 #include <sys/systm.h>
56 #include <sys/list.h>
57 #include <sys/uio.h>
58 #include <sys/dirent.h>
59 #include <sys/time.h>
60 #include <sys/uio.h>
61 #include <sys/fcntl.h>
62 #include <sys/limits.h>
63 #include <sys/string.h>
64 #include <sys/bio.h>
65 #include <sys/buf.h>
66 #include <sys/cred.h>
67 #include <sys/sdt.h>
68 #include <sys/file.h>
69 #include <sys/vfs.h>
70 #include <sys/sysctl.h>
71 #include <sys/sbuf.h>
72 #include <sys/priv.h>
73 #include <sys/kdb.h>
74 #include <sys/ktr.h>
75 #include <sys/stack.h>
76 #include <sys/lockf.h>
77 #include <sys/pathname.h>
78 #include <sys/policy.h>
79 #include <sys/refstr.h>
80 #include <sys/zone.h>
81 #include <sys/eventhandler.h>
82 #include <sys/extattr.h>
83 #include <sys/misc.h>
84 #include <sys/sig.h>
85 #include <sys/osd.h>
86 #include <sys/zfs_debug.h>
87 #include <sys/sysevent/eventdefs.h>
88 #include <sys/u8_textprep.h>
89 #include <sys/fm/util.h>
90
91 #include <machine/stdarg.h>
92
93 #include <vm/vm.h>
94 #include <vm/vm_page.h>
95 #include <vm/vm_object.h>
96 #include <vm/vm_pager.h>
97 #include <vm/vm_kern.h>
98 #include <vm/vm_map.h>
99 /* There is clash. vm_map.h defines the two below and vdev_cache.c use them. */
100 #ifdef min_offset
101 #undef min_offset
102 #endif
103 #ifdef max_offset
104 #undef max_offset
105 #endif
106 #include <vm/vm_extern.h>
107 #include <vm/vnode_pager.h>
108
109 #define CPU_SEQID       (curcpu)
110
111 #define tsd_create(keyp, destructor)    do {                            \
112         *(keyp) = osd_thread_register((destructor));                    \
113         KASSERT(*(keyp) > 0, ("cannot register OSD"));                  \
114 } while (0)
115 #define tsd_destroy(keyp)               osd_thread_deregister(*(keyp))
116 #define tsd_get(key)                    osd_thread_get(curthread, (key))
117 #define tsd_set(key, value)             osd_thread_set(curthread, (key), (value))
118
119 #ifdef  __cplusplus
120 }
121 #endif
122
123 extern int zfs_debug_level;
124 extern struct mtx zfs_debug_mtx;
125 #define ZFS_LOG(lvl, ...)       do {                                    \
126         if (((lvl) & 0xff) <= zfs_debug_level) {                        \
127                 mtx_lock(&zfs_debug_mtx);                               \
128                 printf("%s:%u[%d]: ", __func__, __LINE__, (lvl));       \
129                 printf(__VA_ARGS__);                                    \
130                 printf("\n");                                           \
131                 if ((lvl) & 0x100)                                      \
132                         kdb_backtrace();                                \
133                 mtx_unlock(&zfs_debug_mtx);                             \
134         }                                                               \
135 } while (0)
136
137 #endif  /* _SYS_ZFS_CONTEXT_H */