Source code of Windows XP (NT5)
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.

326 lines
9.5 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. // Define constant for time rounding.
  77. //
  78. #define TenMSec (10*1000*10)
  79. #define TwoSeconds (2*1000*1000*10)
  80. #define AlmostTenMSec (TenMSec - 1)
  81. #define AlmostTwoSeconds (TwoSeconds - 1)
  82. // too big #define HighPartPerDay (24*60*60*1000*1000*10 >> 32)
  83. #define HighPartPerDay (52734375 >> 18)
  84. //
  85. // The global Fat debug level variable, its values are:
  86. //
  87. // 0x00000000 Always gets printed (used when about to bug check)
  88. //
  89. // 0x00000001 Error conditions
  90. // 0x00000002 Debug hooks
  91. // 0x00000004 Catch exceptions before completing Irp
  92. // 0x00000008
  93. //
  94. // 0x00000010
  95. // 0x00000020
  96. // 0x00000040
  97. // 0x00000080
  98. //
  99. // 0x00000100
  100. // 0x00000200
  101. // 0x00000400
  102. // 0x00000800
  103. //
  104. // 0x00001000
  105. // 0x00002000
  106. // 0x00004000
  107. // 0x00008000
  108. //
  109. // 0x00010000
  110. // 0x00020000
  111. // 0x00040000
  112. // 0x00080000
  113. //
  114. // 0x00100000
  115. // 0x00200000
  116. // 0x00400000
  117. // 0x00800000
  118. //
  119. // 0x01000000
  120. // 0x02000000
  121. // 0x04000000
  122. // 0x08000000
  123. //
  124. // 0x10000000
  125. // 0x20000000
  126. // 0x40000000
  127. // 0x80000000
  128. //
  129. #ifdef FASTFATDBG
  130. #define DEBUG_TRACE_ERROR (0x00000001)
  131. #define DEBUG_TRACE_DEBUG_HOOKS (0x00000002)
  132. #define DEBUG_TRACE_CATCH_EXCEPTIONS (0x00000004)
  133. #define DEBUG_TRACE_UNWIND (0x00000008)
  134. #define DEBUG_TRACE_CLEANUP (0x00000010)
  135. #define DEBUG_TRACE_CLOSE (0x00000020)
  136. #define DEBUG_TRACE_CREATE (0x00000040)
  137. #define DEBUG_TRACE_DIRCTRL (0x00000080)
  138. #define DEBUG_TRACE_EA (0x00000100)
  139. #define DEBUG_TRACE_FILEINFO (0x00000200)
  140. #define DEBUG_TRACE_FSCTRL (0x00000400)
  141. #define DEBUG_TRACE_LOCKCTRL (0x00000800)
  142. #define DEBUG_TRACE_READ (0x00001000)
  143. #define DEBUG_TRACE_VOLINFO (0x00002000)
  144. #define DEBUG_TRACE_WRITE (0x00004000)
  145. #define DEBUG_TRACE_FLUSH (0x00008000)
  146. #define DEBUG_TRACE_DEVCTRL (0x00010000)
  147. #define DEBUG_TRACE_SHUTDOWN (0x00020000)
  148. #define DEBUG_TRACE_FATDATA (0x00040000)
  149. #define DEBUG_TRACE_PNP (0x00080000)
  150. #define DEBUG_TRACE_ACCHKSUP (0x00100000)
  151. #define DEBUG_TRACE_ALLOCSUP (0x00200000)
  152. #define DEBUG_TRACE_DIRSUP (0x00400000)
  153. #define DEBUG_TRACE_FILOBSUP (0x00800000)
  154. #define DEBUG_TRACE_NAMESUP (0x01000000)
  155. #define DEBUG_TRACE_VERFYSUP (0x02000000)
  156. #define DEBUG_TRACE_CACHESUP (0x04000000)
  157. #define DEBUG_TRACE_SPLAYSUP (0x08000000)
  158. #define DEBUG_TRACE_DEVIOSUP (0x10000000)
  159. #define DEBUG_TRACE_STRUCSUP (0x20000000)
  160. #define DEBUG_TRACE_FSP_DISPATCHER (0x40000000)
  161. #define DEBUG_TRACE_FSP_DUMP (0x80000000)
  162. extern LONG FatDebugTraceLevel;
  163. extern LONG FatDebugTraceIndent;
  164. #define DebugTrace(INDENT,LEVEL,X,Y) { \
  165. LONG _i; \
  166. if (((LEVEL) == 0) || (FatDebugTraceLevel & (LEVEL))) { \
  167. _i = (ULONG)PsGetCurrentThread(); \
  168. DbgPrint("%08lx:",_i); \
  169. if ((INDENT) < 0) { \
  170. FatDebugTraceIndent += (INDENT); \
  171. } \
  172. if (FatDebugTraceIndent < 0) { \
  173. FatDebugTraceIndent = 0; \
  174. } \
  175. for (_i = 0; _i < FatDebugTraceIndent; _i += 1) { \
  176. DbgPrint(" "); \
  177. } \
  178. DbgPrint(X,Y); \
  179. if ((INDENT) > 0) { \
  180. FatDebugTraceIndent += (INDENT); \
  181. } \
  182. } \
  183. }
  184. #define DebugDump(STR,LEVEL,PTR) { \
  185. ULONG _i; \
  186. VOID FatDump(IN PVOID Ptr); \
  187. if (((LEVEL) == 0) || (FatDebugTraceLevel & (LEVEL))) { \
  188. _i = (ULONG)PsGetCurrentThread(); \
  189. DbgPrint("%08lx:",_i); \
  190. DbgPrint(STR); \
  191. if (PTR != NULL) {FatDump(PTR);} \
  192. DbgBreakPoint(); \
  193. } \
  194. }
  195. #define DebugUnwind(X) { \
  196. if (AbnormalTermination()) { \
  197. DebugTrace(0, DEBUG_TRACE_UNWIND, #X ", Abnormal termination.\n", 0); \
  198. } \
  199. }
  200. //
  201. // The following variables are used to keep track of the total amount
  202. // of requests processed by the file system, and the number of requests
  203. // that end up being processed by the Fsp thread. The first variable
  204. // is incremented whenever an Irp context is created (which is always
  205. // at the start of an Fsd entry point) and the second is incremented
  206. // by read request.
  207. //
  208. extern ULONG FatFsdEntryCount;
  209. extern ULONG FatFspEntryCount;
  210. extern ULONG FatIoCallDriverCount;
  211. extern ULONG FatTotalTicks[];
  212. #define DebugDoit(X) {X;}
  213. extern LONG FatPerformanceTimerLevel;
  214. #define TimerStart(LEVEL) { \
  215. LARGE_INTEGER TStart, TEnd; \
  216. LARGE_INTEGER TElapsed; \
  217. TStart = KeQueryPerformanceCounter( NULL ); \
  218. #define TimerStop(LEVEL,s) \
  219. TEnd = KeQueryPerformanceCounter( NULL ); \
  220. TElapsed.QuadPart = TEnd.QuadPart - TStart.QuadPart; \
  221. FatTotalTicks[FatLogOf(LEVEL)] += TElapsed.LowPart; \
  222. if (FlagOn( FatPerformanceTimerLevel, (LEVEL))) { \
  223. DbgPrint("Time of %s %ld\n", (s), TElapsed.LowPart ); \
  224. } \
  225. }
  226. //
  227. // I need this because C can't support conditional compilation within
  228. // a macro.
  229. //
  230. extern PVOID FatNull;
  231. #else
  232. #define DebugTrace(INDENT,LEVEL,X,Y) {NOTHING;}
  233. #define DebugDump(STR,LEVEL,PTR) {NOTHING;}
  234. #define DebugUnwind(X) {NOTHING;}
  235. #define DebugDoit(X) {NOTHING;}
  236. #define TimerStart(LEVEL)
  237. #define TimerStop(LEVEL,s)
  238. #define FatNull NULL
  239. #endif // FASTFATDBG
  240. //
  241. // The following macro is for all people who compile with the DBG switch
  242. // set, not just fastfat dbg users
  243. //
  244. #if DBG
  245. #define DbgDoit(X) {X;}
  246. #else
  247. #define DbgDoit(X) {NOTHING;}
  248. #endif // DBG
  249. #if DBG
  250. extern NTSTATUS FatAssertNotStatus;
  251. extern BOOLEAN FatTestRaisedStatus;
  252. #endif
  253. #endif // _FATDATA_