]> git.proxmox.com Git - mirror_spl.git/blob - module/splat/splat-internal.h
Make file headers conform to ZFS style standard
[mirror_spl.git] / module / splat / splat-internal.h
1 /*
2 * Copyright (C) 2007-2010 Lawrence Livermore National Security, LLC.
3 * Copyright (C) 2007 The Regents of the University of California.
4 * Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
5 * Written by Brian Behlendorf <behlendorf1@llnl.gov>.
6 * UCRL-CODE-235197
7 *
8 * This file is part of the SPL, Solaris Porting Layer.
9 * For details, see <http://zfsonlinux.org/>.
10 *
11 * The SPL is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
15 *
16 * The SPL is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19 * for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with the SPL. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25 #ifndef _SPLAT_INTERNAL_H
26 #define _SPLAT_INTERNAL_H
27
28 #include "splat-ctl.h"
29 #include <sys/mutex.h>
30 #include <linux/file_compat.h>
31 #include <linux/version.h>
32
33 typedef int (*splat_test_func_t)(struct file *, void *);
34
35 typedef struct splat_test {
36 struct list_head test_list;
37 splat_user_t desc;
38 splat_test_func_t test;
39 } splat_test_t;
40
41 typedef struct splat_subsystem {
42 struct list_head subsystem_list;/* List had to chain entries */
43 splat_user_t desc;
44 spinlock_t test_lock;
45 struct list_head test_list;
46 } splat_subsystem_t;
47
48 void splat_test_init(splat_subsystem_t *sub, const char *name,
49 const char *desc, unsigned int tid, splat_test_func_t func);
50 void splat_test_fini(splat_subsystem_t *sub, unsigned int tid);
51
52 #define SPLAT_INFO_BUFFER_SIZE 65536
53 #define SPLAT_INFO_BUFFER_REDZONE 256
54
55 typedef struct splat_info {
56 kmutex_t info_lock;
57 int info_size;
58 char *info_buffer;
59 char *info_head; /* Internal kernel use only */
60 } splat_info_t;
61
62 #define sym2str(sym) (char *)(#sym)
63
64 #define splat_print(file, format, args...) \
65 ({ splat_info_t *_info_ = (splat_info_t *)file->private_data; \
66 int _rc_; \
67 \
68 ASSERT(_info_); \
69 ASSERT(_info_->info_buffer); \
70 \
71 mutex_enter(&_info_->info_lock); \
72 \
73 /* Don't allow the kernel to start a write in the red zone */ \
74 if ((int)(_info_->info_head - _info_->info_buffer) > \
75 (SPLAT_INFO_BUFFER_SIZE - SPLAT_INFO_BUFFER_REDZONE)) { \
76 _rc_ = -EOVERFLOW; \
77 } else { \
78 _rc_ = sprintf(_info_->info_head, format, args); \
79 if (_rc_ >= 0) \
80 _info_->info_head += _rc_; \
81 } \
82 \
83 mutex_exit(&_info_->info_lock); \
84 _rc_; \
85 })
86
87 #define splat_vprint(file, test, format, args...) \
88 splat_print(file, "%*s: " format, SPLAT_NAME_SIZE, test, args)
89
90 #define splat_locked_test(lock, test) \
91 ({ \
92 int _rc_; \
93 spin_lock(lock); \
94 _rc_ = (test) ? 1 : 0; \
95 spin_unlock(lock); \
96 _rc_; \
97 })
98
99 splat_subsystem_t *splat_condvar_init(void);
100 splat_subsystem_t *splat_kmem_init(void);
101 splat_subsystem_t *splat_mutex_init(void);
102 splat_subsystem_t *splat_krng_init(void);
103 splat_subsystem_t *splat_rwlock_init(void);
104 splat_subsystem_t *splat_taskq_init(void);
105 splat_subsystem_t *splat_thread_init(void);
106 splat_subsystem_t *splat_time_init(void);
107 splat_subsystem_t *splat_vnode_init(void);
108 splat_subsystem_t *splat_kobj_init(void);
109 splat_subsystem_t *splat_atomic_init(void);
110 splat_subsystem_t *splat_list_init(void);
111 splat_subsystem_t *splat_generic_init(void);
112 splat_subsystem_t *splat_cred_init(void);
113 splat_subsystem_t *splat_zlib_init(void);
114 splat_subsystem_t *splat_linux_init(void);
115
116 void splat_condvar_fini(splat_subsystem_t *);
117 void splat_kmem_fini(splat_subsystem_t *);
118 void splat_mutex_fini(splat_subsystem_t *);
119 void splat_krng_fini(splat_subsystem_t *);
120 void splat_rwlock_fini(splat_subsystem_t *);
121 void splat_taskq_fini(splat_subsystem_t *);
122 void splat_thread_fini(splat_subsystem_t *);
123 void splat_time_fini(splat_subsystem_t *);
124 void splat_vnode_fini(splat_subsystem_t *);
125 void splat_kobj_fini(splat_subsystem_t *);
126 void splat_atomic_fini(splat_subsystem_t *);
127 void splat_list_fini(splat_subsystem_t *);
128 void splat_generic_fini(splat_subsystem_t *);
129 void splat_cred_fini(splat_subsystem_t *);
130 void splat_zlib_fini(splat_subsystem_t *);
131 void splat_linux_fini(splat_subsystem_t *);
132
133 int splat_condvar_id(void);
134 int splat_kmem_id(void);
135 int splat_mutex_id(void);
136 int splat_krng_id(void);
137 int splat_rwlock_id(void);
138 int splat_taskq_id(void);
139 int splat_thread_id(void);
140 int splat_time_id(void);
141 int splat_vnode_id(void);
142 int splat_kobj_id(void);
143 int splat_atomic_id(void);
144 int splat_list_id(void);
145 int splat_generic_id(void);
146 int splat_cred_id(void);
147 int splat_zlib_id(void);
148 int splat_linux_id(void);
149
150 #endif /* _SPLAT_INTERNAL_H */