Windows: Avoid deadlock in invalidation path
[openafs.git] / src / WINNT / afsrdr / common / AFSRedirCommonDefines.h
1 /*
2  * Copyright (c) 2008-2011 Kernel Drivers, LLC.
3  * Copyright (c) 2009-2011 Your File System, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * - Redistributions of source code must retain the above copyright notice,
11  *   this list of conditions and the following disclaimer.
12  * - Redistributions in binary form must reproduce the above copyright
13  *   notice,
14  *   this list of conditions and the following disclaimer in the
15  *   documentation
16  *   and/or other materials provided with the distribution.
17  * - Neither the name of Kernel Drivers, LLC nor the names of its
18  *   contributors may be
19  *   used to endorse or promote products derived from this software without
20  *   specific prior written permission from Kernel Drivers, LLC
21  *   and Your File System, Inc.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
25  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
26  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
27  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
29  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
31  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
32  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34  */
35
36 #ifndef _AFS_REDIR_COMMON_DEFINES_H
37 #define _AFS_REDIR_COMMON_DEFINES_H
38
39 //
40 // Allocation defines
41 //
42
43 #define AFS_GENERIC_MEMORY_1_TAG     '1GFA'
44 #define AFS_GENERIC_MEMORY_2_TAG     '2GFA'
45 #define AFS_GENERIC_MEMORY_3_TAG     '3GFA'
46 #define AFS_GENERIC_MEMORY_4_TAG     '4GFA'
47 #define AFS_GENERIC_MEMORY_5_TAG     '5GFA'
48 #define AFS_GENERIC_MEMORY_6_TAG     '6GFA'
49 #define AFS_GENERIC_MEMORY_7_TAG     '7GFA'
50 #define AFS_GENERIC_MEMORY_8_TAG     '8GFA'
51 #define AFS_GENERIC_MEMORY_9_TAG     '9GFA'
52 #define AFS_GENERIC_MEMORY_10_TAG    'AGFA'
53 #define AFS_GENERIC_MEMORY_11_TAG    'BGFA'
54 #define AFS_GENERIC_MEMORY_12_TAG    'CGFA'
55 #define AFS_GENERIC_MEMORY_13_TAG    'DGFA'
56 #define AFS_GENERIC_MEMORY_14_TAG    'EGFA'
57 #define AFS_GENERIC_MEMORY_15_TAG    'FGFA'
58 #define AFS_GENERIC_MEMORY_16_TAG    'GGFA'
59 #define AFS_GENERIC_MEMORY_17_TAG    'HGFA'
60 #define AFS_GENERIC_MEMORY_18_TAG    'IGFA'
61 #define AFS_GENERIC_MEMORY_19_TAG    'JGFA'
62 #define AFS_GENERIC_MEMORY_20_TAG    'KGFA'
63 #define AFS_GENERIC_MEMORY_21_TAG    'LGFA'
64 #define AFS_GENERIC_MEMORY_22_TAG    'MGFA'
65 #define AFS_GENERIC_MEMORY_23_TAG    'NGFA'
66 #define AFS_GENERIC_MEMORY_24_TAG    'OGFA'
67 #define AFS_GENERIC_MEMORY_25_TAG    'PGFA'
68 #define AFS_GENERIC_MEMORY_26_TAG    'QGFA'
69 #define AFS_GENERIC_MEMORY_27_TAG    'RGFA'
70 #define AFS_GENERIC_MEMORY_28_TAG    'SGFA'
71 #define AFS_GENERIC_MEMORY_29_TAG    'TGFA'
72 #define AFS_GENERIC_MEMORY_30_TAG    'UGFA'
73 #define AFS_GENERIC_MEMORY_31_TAG    'VGFA'
74 #define AFS_GENERIC_MEMORY_32_TAG    'WGFA'
75 #define AFS_FCB_ALLOCATION_TAG       'AFFA'
76 #define AFS_FCB_NP_ALLOCATION_TAG    'NFFA'
77 #define AFS_VCB_ALLOCATION_TAG       'CVFA'
78 #define AFS_VCB_NP_ALLOCATION_TAG    'NVFA'
79 #define AFS_CCB_ALLOCATION_TAG       'CCFA'
80 #define AFS_WORKER_CB_TAG            'CWFA'
81 #define AFS_WORK_ITEM_TAG            'IWFA'
82 #define AFS_POOL_ENTRY_TAG           'EPFA'
83 #define AFS_PROCESS_CB_TAG           'CPFA'
84 #define AFS_DIR_BUFFER_TAG           'BDFA'
85 #define AFS_DIR_ENTRY_TAG            'EDFA'
86 #define AFS_NAME_BUFFER_ONE_TAG      '1NFA'
87 #define AFS_NAME_BUFFER_TWO_TAG      '2NFA'
88 #define AFS_NAME_BUFFER_THREE_TAG    '3NFA'
89 #define AFS_NAME_BUFFER_FOUR_TAG     '4NFA'
90 #define AFS_NAME_BUFFER_FIVE_TAG     '5NFA'
91 #define AFS_NAME_BUFFER_SIX_TAG      '6NFA'
92 #define AFS_NAME_BUFFER_SEVEN_TAG    '7NFA'
93 #define AFS_NAME_BUFFER_EIGHT_TAG    '8NFA'
94 #define AFS_NAME_BUFFER_NINE_TAG     '9NFA'
95 #define AFS_NAME_BUFFER_TEN_TAG      'ANFA'
96 #define AFS_SUBST_BUFFER_TAG         'SBFA'
97 #define AFS_FILE_CREATE_BUFFER_TAG   'CFFA'
98 #define AFS_RENAME_REQUEST_TAG       'RFFA'
99 #define AFS_DIR_ENTRY_NP_TAG         'NDFA'
100 #define AFS_PROVIDER_CB              'PNFA'
101 #define AFS_EXTENT_TAG               'xSFA'
102 #define AFS_EXTENT_REQUEST_TAG       'XSFA'
103 #define AFS_EXTENT_RELEASE_TAG       'LSFA'
104 #define AFS_IO_RUN_TAG               'iSFA'
105 #define AFS_GATHER_TAG               'gSFA'
106 #define AFS_UPDATE_RESULT_TAG        'RUFA'
107 #define AFS_EXTENTS_RESULT_TAG       'XEFA'
108 #define AFS_SYS_NAME_NODE_TAG        'NSFA'
109 #define AFS_REPARSE_NAME_TAG         'NRFA'
110 #define AFS_NAME_ARRAY_TAG           'ANFA'
111 #define AFS_OBJECT_INFO_TAG          'IOFA'
112 #define AFS_NP_OBJECT_INFO_TAG       'ONFA'
113 #define AFS_DIR_SNAPSHOT_TAG         'SSFA'
114 #define AFS_LIBRARY_QUEUE_TAG        'QLFA'
115 #define AFS_NETWORK_PROVIDER_1_TAG   '1ZFA'
116 #define AFS_NETWORK_PROVIDER_2_TAG   '2ZFA'
117 #define AFS_NETWORK_PROVIDER_3_TAG   '3ZFA'
118 #define AFS_NETWORK_PROVIDER_4_TAG   '4ZFA'
119 #define AFS_NETWORK_PROVIDER_5_TAG   '5ZFA'
120 #define AFS_NETWORK_PROVIDER_6_TAG   '6ZFA'
121 #define AFS_NETWORK_PROVIDER_7_TAG   '7ZFA'
122 #define AFS_NETWORK_PROVIDER_8_TAG   '8ZFA'
123 #define AFS_NETWORK_PROVIDER_9_TAG   '9ZFA'
124 #define AFS_NETWORK_PROVIDER_10_TAG  'AZFA'
125 #define AFS_NETWORK_PROVIDER_11_TAG  'BZFA'
126 #define AFS_AG_ENTRY_CB_TAG          'GAFA'
127 #define AFS_PROCESS_AG_CB_TAG        'APFA'
128 #define AFS_BYTERANGE_TAG            '_RBA'
129 #define __Enter
130
131 #define try_return(S) { S; goto try_exit; }
132
133 //
134 // Object types allocated
135 //
136
137 #define AFS_FILE_FCB                            0x0001
138 #define AFS_DIRECTORY_FCB                       0x0002
139 #define AFS_NON_PAGED_FCB                       0x0003
140 #define AFS_CCB                                 0x0004
141 #define AFS_ROOT_FCB                            0x0006
142 #define AFS_VCB                                 0x0007
143 #define AFS_NON_PAGED_VCB                       0x0008
144 #define AFS_ROOT_ALL                            0x0009
145 #define AFS_IOCTL_FCB                           0x000A
146 #define AFS_MOUNT_POINT_FCB                     0x000B
147 #define AFS_SYMBOLIC_LINK_FCB                   0x000C
148 #define AFS_SPECIAL_SHARE_FCB                   0x000D
149 #define AFS_DFS_LINK_FCB                        0x000E
150 #define AFS_REDIRECTOR_FCB                      0x000F
151
152 #define AFS_INVALID_FCB                         0x00FF
153
154 //
155 // Debug information
156 //
157
158 #define AFS_DBG_FLAG_BREAK_ON_ENTRY     0x00000001   // Only enabled in checked build
159 #define AFS_DBG_TRACE_TO_DEBUGGER       0x00000002
160 #define AFS_DBG_FLAG_ENABLE_FORCE_CRASH 0x00000004   // Only enabled in checked build
161 #define AFS_DBG_BUGCHECK_EXCEPTION      0x00000008
162 #define AFS_DBG_CLEAN_SHUTDOWN          0x00000010
163 #define AFS_DBG_REQUIRE_CLEAN_SHUTDOWN  0x00000020
164
165 //
166 // Pool state
167 //
168
169 #define POOL_UNKNOWN            0
170 #define POOL_INACTIVE           1
171 #define POOL_ACTIVE             2
172
173 //
174 // Volume flags
175 //
176
177 #define AFS_VOLUME_FLAGS_OFFLINE                        0x00000001
178 #define AFS_VOLUME_PRIVATE_WOKER_INITIALIZED            0x00000002
179 #define AFS_VOLUME_INSERTED_HASH_TREE                   0x00000004
180 #define AFS_VOLUME_ACTIVE_GLOBAL_ROOT                   0x00000008
181
182 //
183 // Need this to handle the break point definition
184 //
185
186 typedef
187 void
188 (*PAFSDumpTraceFiles)( void);
189
190 extern PAFSDumpTraceFiles  AFSDumpTraceFilesFnc;
191
192 //
193 // Debug information
194 //
195
196 static inline void AFS_ASSERT() {
197     AFSDumpTraceFilesFnc();
198 }
199
200 #if DBG
201
202 //#define AFS_VALIDATE_EXTENTS            0
203
204 static inline void AFSBreakPoint() {
205     AFSDumpTraceFilesFnc();
206 #if !defined(KD_DEBUGGER_ENABLED)
207 #define KD_DEBUGGER_ENABLED DBG
208 #endif // KD_DEBUGGER_ENABLED
209
210 #if (NTDDI_VERSION >= NTDDI_WS03)
211     KdRefreshDebuggerNotPresent();
212 #endif
213
214 #if defined(KD_DEBUGGER_NOT_PRESENT)
215     if (KD_DEBUGGER_NOT_PRESENT == FALSE)
216         DbgBreakPoint();
217 #endif // KD_DEBUGGER_NOT_PRESENT
218 }
219
220 #define AFSPrint        DbgPrint
221
222 #else
223
224 static inline void AFSBreakPoint() {
225     AFSDumpTraceFilesFnc();
226 }
227
228 #define AFSPrint
229
230 #endif
231
232 //
233 // Library control device name
234 //
235
236 #define AFS_LIBRARY_CONTROL_DEVICE_NAME     L"\\Device\\AFSLibraryControlDevice"
237
238 #define AFS_REDIR_LIBRARY_SERVICE_ENTRY     L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\AFSLibrary"
239
240 #endif
241