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.

224 lines
6.6 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. pagefile.h
  5. Abstract:
  6. Session Manager page file related private types and prototypes.
  7. Author:
  8. Silviu Calinoiu (silviuc) 12-Apr-2001
  9. Revision History:
  10. --*/
  11. #ifndef _PAGEFILE_H_
  12. #define _PAGEFILE_H_
  13. /*++
  14. General algorithm for creating paging files.
  15. Possible paging file specifiers (in registry) are:
  16. a. ?:\pagefile.sys
  17. b. ?:\pagefile.sys MIN MAX
  18. c. x:\pagefile.sys
  19. d. x:\pagefile.sys MIN MAX
  20. e. multiple paging file specifiers
  21. f. no paging file specifier
  22. If MIN or MAX are zero or not present this is a specifier of
  23. a system managed paging file.
  24. If we cannot convert a size (MIN or MAX) to a decimal number
  25. the specifier will be ignored.
  26. If we did not manage to create a single paging file but there
  27. were specifiers (although invalid) we will assume one specifier
  28. of type `?:\pagefile.sys'.
  29. A specifier of type `?:\pagefile.sys' must be alone.
  30. Algorithm for `?:\pagefile.sys'.
  31. 1. Query all volumes and sort them in decreasing order of
  32. available free space.
  33. 2. Determine the ideal paging file size based on RAM, etc. We will
  34. use either this size or the maximum free space available on a
  35. volume as the size of the paging file.
  36. 3. Iterate all volumes and try to create a paging file with
  37. the ideal size. If successful exit.
  38. 4. Iterate all volumes and try to create a paging file with
  39. a size smaller than the ideal size. On each volume we loop
  40. trying with smaller and smaller sizes. If successful exit.
  41. 5. Bail out.
  42. Note that in 99% of the cases algorithm will stop on the first volume
  43. from step (3).
  44. Algorithm for `?:\pagefile.sys MIN MAX'.
  45. 1. Query all volumes and sort them in decreasing order of
  46. available free space.
  47. 2. Iterate all volumes and try to create a paging file with
  48. the specified size or maximum free space available.
  49. On each volume we loop trying with smaller and smaller sizes.
  50. If successful exit.
  51. 3. Iterate all volumes and try to create a paging file with
  52. a size smaller than the ideal size. On each volume we loop
  53. trying with smaller and smaller sizes. If successful exit.
  54. 4. Bail out.
  55. Note that in 99% of the cases algorithm will stop on the first volume
  56. from step (2).
  57. Algorithm for creating a paging file for `x:\pagefile.sys'.
  58. 1. Determine the ideal paging file size based on RAM, etc.
  59. 2. Try to create it with ideal size or free space available
  60. on the specified drive. Try with smaller and smaller sizes if needed.
  61. 3. If after processing all specifiers we did not manage to create
  62. even a single paging file treat this as if a `?:\pagefile.sys'
  63. descriptor was specified in the registry.
  64. Algorithm for creating a paging file for `x:\pagefile.sys MIN MAX'.
  65. 1. Try to create it on that particular drive with the specified sizes
  66. or the available free space on the specified volume.
  67. 2. If unsuccessfull use smaller sizes.
  68. 3. If after processing all specifiers we did not manage to create
  69. even a single paging file treat this as if a `?:\pagefile.sys'
  70. descriptor was specified in the registry.
  71. Algorithm for creating a paging file for `multiple page files' descriptor.
  72. 1. Try to create it on the particular drives with the specified sizes.
  73. We assume this is an advanced user and we do not overwrite the
  74. settings at all.
  75. 2. If we did not manage to create even a single paging file we
  76. will treat this as a `?:\pagefile.sys' descriptor.
  77. Algorithm for creating a paging file for `null' descriptor.
  78. 1. No work. User requested to boot without a paging file.
  79. --*/
  80. //
  81. // PAGING_FILE_DESCRIPTOR
  82. //
  83. // Name - name of the pagefile. The format is `X:\pagefile.sys' where X is
  84. // either a drive letter or `?'.
  85. //
  86. // Specifier - the registry string specifier for the paging file.
  87. //
  88. // Created - true if we managed to create a paging file for this descriptor.
  89. //
  90. // DefaultSize - true if we created the paging file based on a default descriptor.
  91. // This is used for emergency situations.
  92. //
  93. // SystemManaged - true if we need to create a system managed paging file using
  94. // this descriptor (we will decide what is the ideal size).
  95. //
  96. // SizeTrimmed - true if while validating the paging file sizes we trimmed them
  97. // for any reason.
  98. //
  99. // AnyDrive - true if the registry specifier starts with `?:\'.
  100. //
  101. // CrashdumpChecked - true if we checked for a crashdump in this paging file.
  102. //
  103. typedef struct _PAGING_FILE_DESCRIPTOR {
  104. LIST_ENTRY List;
  105. UNICODE_STRING Name;
  106. UNICODE_STRING Specifier;
  107. LARGE_INTEGER MinSize;
  108. LARGE_INTEGER MaxSize;
  109. LARGE_INTEGER RealMinSize;
  110. LARGE_INTEGER RealMaxSize;
  111. struct {
  112. ULONG Created : 1;
  113. ULONG DefaultSize : 1;
  114. ULONG SystemManaged : 1;
  115. ULONG SizeTrimmed : 1;
  116. ULONG AnyDrive : 1;
  117. ULONG Emergency : 1;
  118. ULONG CrashdumpChecked : 1;
  119. };
  120. } PAGING_FILE_DESCRIPTOR, * PPAGING_FILE_DESCRIPTOR;
  121. //
  122. // VOLUME_DESCRIPTOR
  123. //
  124. // Initialized - true if this volume descriptor was completely initialized
  125. // (e.g. free space computed, crash dump processing, etc.).
  126. //
  127. // PagingFileCreated - true if during this boot session we have create
  128. // a paging file on this volume.
  129. //
  130. // PagingFilePresent - true if this volume contains a stale paging file
  131. // for which we need to do crashdump processing.
  132. //
  133. // BootVolume - true if this is the boot volume.
  134. //
  135. // PagingFileCount - number of paging files created on this volume.
  136. //
  137. typedef struct _VOLUME_DESCRIPTOR {
  138. LIST_ENTRY List;
  139. struct {
  140. ULONG Initialized : 1;
  141. ULONG PagingFilePresent : 1;
  142. ULONG PagingFileCreated : 1;
  143. ULONG BootVolume : 1;
  144. ULONG PagingFileCount : 4; // based on MAXIMUM_NUMBER_OF_PAGING_FILES
  145. };
  146. WCHAR DriveLetter;
  147. LARGE_INTEGER FreeSpace;
  148. FILE_FS_DEVICE_INFORMATION DeviceInfo;
  149. } VOLUME_DESCRIPTOR, * PVOLUME_DESCRIPTOR;
  150. //
  151. // Exported (out of module) functions.
  152. //
  153. VOID
  154. SmpPagingFileInitialize (
  155. VOID
  156. );
  157. NTSTATUS
  158. SmpCreatePagingFileDescriptor(
  159. IN PUNICODE_STRING PagingFileSpecifier
  160. );
  161. NTSTATUS
  162. SmpCreatePagingFiles (
  163. VOID
  164. );
  165. ULONG
  166. SmpPagingFileExceptionFilter (
  167. ULONG ExceptionCode,
  168. PVOID ExceptionRecord
  169. );
  170. #endif // _PAGEFILE_H_