]>
Commit | Line | Data |
---|---|---|
716154c5 BB |
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>. | |
715f6251 | 6 | * UCRL-CODE-235197 |
7 | * | |
716154c5 | 8 | * This file is part of the SPL, Solaris Porting Layer. |
3d6af2dd | 9 | * For details, see <http://zfsonlinux.org/>. |
716154c5 BB |
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. | |
715f6251 | 15 | * |
716154c5 | 16 | * The SPL is distributed in the hope that it will be useful, but WITHOUT |
715f6251 | 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 | |
716154c5 BB |
22 | * with the SPL. If not, see <http://www.gnu.org/licenses/>. |
23 | \*****************************************************************************/ | |
715f6251 | 24 | |
7c50328b | 25 | #ifndef _SPLAT_INTERNAL_H |
26 | #define _SPLAT_INTERNAL_H | |
27 | ||
596e65b4 | 28 | #include "splat-ctl.h" |
10946b02 AX |
29 | #include <sys/mutex.h> |
30 | #include <linux/file_compat.h> | |
f6188ddd | 31 | #include <linux/version.h> |
7c50328b | 32 | |
7c50328b | 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 | ||
ec06701b AX |
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 | ||
7c50328b | 52 | #define SPLAT_INFO_BUFFER_SIZE 65536 |
53 | #define SPLAT_INFO_BUFFER_REDZONE 256 | |
54 | ||
55 | typedef struct splat_info { | |
10946b02 | 56 | kmutex_t info_lock; |
7c50328b | 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...) \ | |
d6a26c6a | 65 | ({ splat_info_t *_info_ = (splat_info_t *)file->private_data; \ |
7c50328b | 66 | int _rc_; \ |
67 | \ | |
68 | ASSERT(_info_); \ | |
69 | ASSERT(_info_->info_buffer); \ | |
70 | \ | |
10946b02 | 71 | mutex_enter(&_info_->info_lock); \ |
7c50328b | 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 | \ | |
10946b02 | 83 | mutex_exit(&_info_->info_lock); \ |
7c50328b | 84 | _rc_; \ |
85 | }) | |
86 | ||
d6a26c6a | 87 | #define splat_vprint(file, test, format, args...) \ |
7c50328b | 88 | splat_print(file, "%*s: " format, SPLAT_NAME_SIZE, test, args) |
89 | ||
e811949a BB |
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 | ||
d702c04f BB |
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); | |
b871b8cd | 111 | splat_subsystem_t *splat_generic_init(void); |
ec7d53e9 | 112 | splat_subsystem_t *splat_cred_init(void); |
19c1eb82 | 113 | splat_subsystem_t *splat_zlib_init(void); |
bf0c60c0 | 114 | splat_subsystem_t *splat_linux_init(void); |
7c50328b | 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 *); | |
4b171585 | 124 | void splat_vnode_fini(splat_subsystem_t *); |
9490c148 | 125 | void splat_kobj_fini(splat_subsystem_t *); |
9f4c835a | 126 | void splat_atomic_fini(splat_subsystem_t *); |
d702c04f | 127 | void splat_list_fini(splat_subsystem_t *); |
b871b8cd | 128 | void splat_generic_fini(splat_subsystem_t *); |
ec7d53e9 | 129 | void splat_cred_fini(splat_subsystem_t *); |
19c1eb82 | 130 | void splat_zlib_fini(splat_subsystem_t *); |
bf0c60c0 | 131 | void splat_linux_fini(splat_subsystem_t *); |
7c50328b | 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); | |
4b171585 | 141 | int splat_vnode_id(void); |
9490c148 | 142 | int splat_kobj_id(void); |
9f4c835a | 143 | int splat_atomic_id(void); |
d702c04f | 144 | int splat_list_id(void); |
b871b8cd | 145 | int splat_generic_id(void); |
ec7d53e9 | 146 | int splat_cred_id(void); |
19c1eb82 | 147 | int splat_zlib_id(void); |
bf0c60c0 | 148 | int splat_linux_id(void); |
7c50328b | 149 | |
150 | #endif /* _SPLAT_INTERNAL_H */ |