Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

336 lines
10 KiB

  1. /*++
  2. Copyright (c) 1989-2000 Microsoft Corporation
  3. Module Name:
  4. FatData.c
  5. Abstract:
  6. This module declares the global data used by the Fat file system.
  7. // @@BEGIN_DDKSPLIT
  8. Author:
  9. Gary Kimura [GaryKi] 28-Dec-1989
  10. Revision History:
  11. // @@END_DDKSPLIT
  12. --*/
  13. #ifndef _FATDATA_
  14. #define _FATDATA_
  15. //
  16. // The global fsd data record, and a global zero large integer
  17. //
  18. extern FAT_DATA FatData;
  19. extern IO_STATUS_BLOCK FatGarbageIosb;
  20. extern NPAGED_LOOKASIDE_LIST FatIrpContextLookasideList;
  21. extern NPAGED_LOOKASIDE_LIST FatNonPagedFcbLookasideList;
  22. extern NPAGED_LOOKASIDE_LIST FatEResourceLookasideList;
  23. extern PAGED_LOOKASIDE_LIST FatFcbLookasideList;
  24. extern PAGED_LOOKASIDE_LIST FatCcbLookasideList;
  25. extern SLIST_HEADER FatCloseContextSList;
  26. extern FAST_MUTEX FatCloseQueueMutex;
  27. extern PDEVICE_OBJECT FatDiskFileSystemDeviceObject;
  28. extern PDEVICE_OBJECT FatCdromFileSystemDeviceObject;
  29. extern LARGE_INTEGER FatLargeZero;
  30. extern LARGE_INTEGER FatMaxLarge;
  31. extern LARGE_INTEGER Fat30Milliseconds;
  32. extern LARGE_INTEGER Fat100Milliseconds;
  33. extern LARGE_INTEGER FatOneSecond;
  34. extern LARGE_INTEGER FatOneDay;
  35. extern LARGE_INTEGER FatJanOne1980;
  36. extern LARGE_INTEGER FatDecThirtyOne1979;
  37. extern FAT_TIME_STAMP FatTimeJanOne1980;
  38. extern LARGE_INTEGER FatMagic10000;
  39. #define FAT_SHIFT10000 13
  40. extern LARGE_INTEGER FatMagic86400000;
  41. #define FAT_SHIFT86400000 26
  42. #define FatConvert100nsToMilliseconds(LARGE_INTEGER) ( \
  43. RtlExtendedMagicDivide( (LARGE_INTEGER), FatMagic10000, FAT_SHIFT10000 )\
  44. )
  45. #define FatConvertMillisecondsToDays(LARGE_INTEGER) ( \
  46. RtlExtendedMagicDivide( (LARGE_INTEGER), FatMagic86400000, FAT_SHIFT86400000 ) \
  47. )
  48. #define FatConvertDaysToMilliseconds(DAYS) ( \
  49. Int32x32To64( (DAYS), 86400000 ) \
  50. )
  51. //
  52. // Reserve MDL for paging file io forward progress.
  53. //
  54. #define FAT_RESERVE_MDL_SIZE 16
  55. extern PMDL FatReserveMdl;
  56. extern KEVENT FatReserveEvent;
  57. //
  58. // The global structure used to contain our fast I/O callbacks
  59. //
  60. extern FAST_IO_DISPATCH FatFastIoDispatch;
  61. //
  62. // Read ahead amount used for normal data files
  63. //
  64. #define READ_AHEAD_GRANULARITY (0x10000)
  65. //
  66. // Define maximum number of parallel Reads or Writes that will be generated
  67. // per one request.
  68. //
  69. #define FAT_MAX_IO_RUNS_ON_STACK ((ULONG) 5)
  70. //
  71. // Define the maximum number of delayed closes.
  72. //
  73. #define FAT_MAX_DELAYED_CLOSES ((ULONG)16)
  74. extern ULONG FatMaxDelayedCloseCount;
  75. //
  76. // This is the number of times a mounted Vcb will be referenced on behalf
  77. // of the system. The counts include the following references.
  78. //
  79. // 1 reference - shows the volume is mounted
  80. // 1 reference - 1 for the Root Directory
  81. //
  82. #define FAT_RESIDUAL_USER_REFERENCE (2)
  83. //
  84. // Define constant for time rounding.
  85. //
  86. #define TenMSec (10*1000*10)
  87. #define TwoSeconds (2*1000*1000*10)
  88. #define AlmostTenMSec (TenMSec - 1)
  89. #define AlmostTwoSeconds (TwoSeconds - 1)
  90. // too big #define HighPartPerDay (24*60*60*1000*1000*10 >> 32)
  91. #define HighPartPerDay (52734375 >> 18)
  92. //
  93. // The global Fat debug level variable, its values are:
  94. //
  95. // 0x00000000 Always gets printed (used when about to bug check)
  96. //
  97. // 0x00000001 Error conditions
  98. // 0x00000002 Debug hooks
  99. // 0x00000004 Catch exceptions before completing Irp
  100. // 0x00000008
  101. //
  102. // 0x00000010
  103. // 0x00000020
  104. // 0x00000040
  105. // 0x00000080
  106. //
  107. // 0x00000100
  108. // 0x00000200
  109. // 0x00000400
  110. // 0x00000800
  111. //
  112. // 0x00001000
  113. // 0x00002000
  114. // 0x00004000
  115. // 0x00008000
  116. //
  117. // 0x00010000
  118. // 0x00020000
  119. // 0x00040000
  120. // 0x00080000
  121. //
  122. // 0x00100000
  123. // 0x00200000
  124. // 0x00400000
  125. // 0x00800000
  126. //
  127. // 0x01000000
  128. // 0x02000000
  129. // 0x04000000
  130. // 0x08000000
  131. //
  132. // 0x10000000
  133. // 0x20000000
  134. // 0x40000000
  135. // 0x80000000
  136. //
  137. #ifdef FASTFATDBG
  138. #define DEBUG_TRACE_ERROR (0x00000001)
  139. #define DEBUG_TRACE_DEBUG_HOOKS (0x00000002)
  140. #define DEBUG_TRACE_CATCH_EXCEPTIONS (0x00000004)
  141. #define DEBUG_TRACE_UNWIND (0x00000008)
  142. #define DEBUG_TRACE_CLEANUP (0x00000010)
  143. #define DEBUG_TRACE_CLOSE (0x00000020)
  144. #define DEBUG_TRACE_CREATE (0x00000040)
  145. #define DEBUG_TRACE_DIRCTRL (0x00000080)
  146. #define DEBUG_TRACE_EA (0x00000100)
  147. #define DEBUG_TRACE_FILEINFO (0x00000200)
  148. #define DEBUG_TRACE_FSCTRL (0x00000400)
  149. #define DEBUG_TRACE_LOCKCTRL (0x00000800)
  150. #define DEBUG_TRACE_READ (0x00001000)
  151. #define DEBUG_TRACE_VOLINFO (0x00002000)
  152. #define DEBUG_TRACE_WRITE (0x00004000)
  153. #define DEBUG_TRACE_FLUSH (0x00008000)
  154. #define DEBUG_TRACE_DEVCTRL (0x00010000)
  155. #define DEBUG_TRACE_SHUTDOWN (0x00020000)
  156. #define DEBUG_TRACE_FATDATA (0x00040000)
  157. #define DEBUG_TRACE_PNP (0x00080000)
  158. #define DEBUG_TRACE_ACCHKSUP (0x00100000)
  159. #define DEBUG_TRACE_ALLOCSUP (0x00200000)
  160. #define DEBUG_TRACE_DIRSUP (0x00400000)
  161. #define DEBUG_TRACE_FILOBSUP (0x00800000)
  162. #define DEBUG_TRACE_NAMESUP (0x01000000)
  163. #define DEBUG_TRACE_VERFYSUP (0x02000000)
  164. #define DEBUG_TRACE_CACHESUP (0x04000000)
  165. #define DEBUG_TRACE_SPLAYSUP (0x08000000)
  166. #define DEBUG_TRACE_DEVIOSUP (0x10000000)
  167. #define DEBUG_TRACE_STRUCSUP (0x20000000)
  168. #define DEBUG_TRACE_FSP_DISPATCHER (0x40000000)
  169. #define DEBUG_TRACE_FSP_DUMP (0x80000000)
  170. extern LONG FatDebugTraceLevel;
  171. extern LONG FatDebugTraceIndent;
  172. #define DebugTrace(INDENT,LEVEL,X,Y) { \
  173. LONG _i; \
  174. if (((LEVEL) == 0) || (FatDebugTraceLevel & (LEVEL))) { \
  175. _i = (ULONG)PsGetCurrentThread(); \
  176. DbgPrint("%08lx:",_i); \
  177. if ((INDENT) < 0) { \
  178. FatDebugTraceIndent += (INDENT); \
  179. } \
  180. if (FatDebugTraceIndent < 0) { \
  181. FatDebugTraceIndent = 0; \
  182. } \
  183. for (_i = 0; _i < FatDebugTraceIndent; _i += 1) { \
  184. DbgPrint(" "); \
  185. } \
  186. DbgPrint(X,Y); \
  187. if ((INDENT) > 0) { \
  188. FatDebugTraceIndent += (INDENT); \
  189. } \
  190. } \
  191. }
  192. #define DebugDump(STR,LEVEL,PTR) { \
  193. ULONG _i; \
  194. VOID FatDump(IN PVOID Ptr); \
  195. if (((LEVEL) == 0) || (FatDebugTraceLevel & (LEVEL))) { \
  196. _i = (ULONG)PsGetCurrentThread(); \
  197. DbgPrint("%08lx:",_i); \
  198. DbgPrint(STR); \
  199. if (PTR != NULL) {FatDump(PTR);} \
  200. DbgBreakPoint(); \
  201. } \
  202. }
  203. #define DebugUnwind(X) { \
  204. if (AbnormalTermination()) { \
  205. DebugTrace(0, DEBUG_TRACE_UNWIND, #X ", Abnormal termination.\n", 0); \
  206. } \
  207. }
  208. //
  209. // The following variables are used to keep track of the total amount
  210. // of requests processed by the file system, and the number of requests
  211. // that end up being processed by the Fsp thread. The first variable
  212. // is incremented whenever an Irp context is created (which is always
  213. // at the start of an Fsd entry point) and the second is incremented
  214. // by read request.
  215. //
  216. extern ULONG FatFsdEntryCount;
  217. extern ULONG FatFspEntryCount;
  218. extern ULONG FatIoCallDriverCount;
  219. extern ULONG FatTotalTicks[];
  220. #define DebugDoit(X) {X;}
  221. extern LONG FatPerformanceTimerLevel;
  222. #define TimerStart(LEVEL) { \
  223. LARGE_INTEGER TStart, TEnd; \
  224. LARGE_INTEGER TElapsed; \
  225. TStart = KeQueryPerformanceCounter( NULL ); \
  226. #define TimerStop(LEVEL,s) \
  227. TEnd = KeQueryPerformanceCounter( NULL ); \
  228. TElapsed.QuadPart = TEnd.QuadPart - TStart.QuadPart; \
  229. FatTotalTicks[FatLogOf(LEVEL)] += TElapsed.LowPart; \
  230. if (FlagOn( FatPerformanceTimerLevel, (LEVEL))) { \
  231. DbgPrint("Time of %s %ld\n", (s), TElapsed.LowPart ); \
  232. } \
  233. }
  234. //
  235. // I need this because C can't support conditional compilation within
  236. // a macro.
  237. //
  238. extern PVOID FatNull;
  239. #else
  240. #define DebugTrace(INDENT,LEVEL,X,Y) {NOTHING;}
  241. #define DebugDump(STR,LEVEL,PTR) {NOTHING;}
  242. #define DebugUnwind(X) {NOTHING;}
  243. #define DebugDoit(X) {NOTHING;}
  244. #define TimerStart(LEVEL)
  245. #define TimerStop(LEVEL,s)
  246. #define FatNull NULL
  247. #endif // FASTFATDBG
  248. //
  249. // The following macro is for all people who compile with the DBG switch
  250. // set, not just fastfat dbg users
  251. //
  252. #if DBG
  253. #define DbgDoit(X) {X;}
  254. #else
  255. #define DbgDoit(X) {NOTHING;}
  256. #endif // DBG
  257. #if DBG
  258. extern NTSTATUS FatAssertNotStatus;
  259. extern BOOLEAN FatTestRaisedStatus;
  260. #endif
  261. #endif // _FATDATA_