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.

291 lines
7.2 KiB

  1. /*++ BUILD Version: 0000 // Increment this if a change has global effects
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. LfsDisk.h
  5. Abstract:
  6. This module defines the on-disk structures present in the log file.
  7. Author:
  8. Brian Andrew [BrianAn] 13-June-1991
  9. Revision History:
  10. IMPORTANT NOTE:
  11. The Log File Service will by used on systems that require that on-disk
  12. structures guarantee the natural alignment of all arithmetic quantities
  13. up to and including quad-word (64-bit) numbers. Therefore, all Lfs
  14. on-disk structures are quad-word aligned, etc.
  15. --*/
  16. #ifndef _LFSDISK_
  17. #define _LFSDISK_
  18. #define MINIMUM_LFS_PAGES 0x00000030
  19. #define MINIMUM_LFS_CLIENTS 1
  20. //
  21. // The following macros are used to set and query with respect to the
  22. // update sequence arrays.
  23. //
  24. #define UpdateSequenceStructureSize( MSH ) \
  25. ((((PMULTI_SECTOR_HEADER) (MSH))->UpdateSequenceArraySize - 1) * SEQUENCE_NUMBER_STRIDE)
  26. #define UpdateSequenceArraySize( STRUCT_SIZE ) \
  27. ((STRUCT_SIZE) / SEQUENCE_NUMBER_STRIDE + 1)
  28. #define FIRST_STRIDE \
  29. (SEQUENCE_NUMBER_STRIDE - sizeof( UPDATE_SEQUENCE_NUMBER ))
  30. //
  31. // Log client ID. This is used to uniquely identify a client for a
  32. // particular log file.
  33. //
  34. typedef struct _LFS_CLIENT_ID {
  35. USHORT SeqNumber;
  36. USHORT ClientIndex;
  37. } LFS_CLIENT_ID, *PLFS_CLIENT_ID;
  38. //
  39. // Log Record Header. This is the header that begins every Log Record in
  40. // the log file.
  41. //
  42. typedef struct _LFS_RECORD_HEADER {
  43. //
  44. // Log File Sequence Number of this log record.
  45. //
  46. LSN ThisLsn;
  47. //
  48. // The following fields are used to back link Lsn's. The ClientPrevious
  49. // and ClientUndoNextLsn fields are used by a client to link his log
  50. // records.
  51. //
  52. LSN ClientPreviousLsn;
  53. LSN ClientUndoNextLsn;
  54. //
  55. // The following field is the size of data area for this record. The
  56. // log record header will be padded if necessary to fill to a 64-bit
  57. // boundary, so the client data will begin on a 64-bit boundary to
  58. // insure that all of his data is 64-bit aligned. The below value
  59. // has not been padded to 64 bits however.
  60. //
  61. ULONG ClientDataLength;
  62. //
  63. // Client ID. This identifies the owner of this log record. The owner
  64. // is uniquely identified by his offset in the client array and the
  65. // sequence number associated with that client record.
  66. //
  67. LFS_CLIENT_ID ClientId;
  68. //
  69. // This the Log Record type. This could be a commit protocol record,
  70. // a client restart area or a client update record.
  71. //
  72. LFS_RECORD_TYPE RecordType;
  73. //
  74. // Transaction ID. This is used externally by a client (Transaction
  75. // Manager) to group log file entries.
  76. //
  77. TRANSACTION_ID TransactionId;
  78. //
  79. // Log record flags.
  80. //
  81. USHORT Flags;
  82. //
  83. // Alignment field.
  84. //
  85. USHORT AlignWord;
  86. } LFS_RECORD_HEADER, *PLFS_RECORD_HEADER;
  87. #define LOG_RECORD_MULTI_PAGE (0x0001)
  88. #define LFS_RECORD_HEADER_SIZE QuadAlign( sizeof( LFS_RECORD_HEADER ))
  89. //
  90. // Following are the version specific fields in the record page header.
  91. //
  92. typedef struct _LFS_UNPACKED_RECORD_PAGE {
  93. //
  94. // This gives us the offset of the free space in the page.
  95. //
  96. USHORT NextRecordOffset;
  97. USHORT WordAlign;
  98. //
  99. // Reserved. The following array is reserved for possible future use.
  100. //
  101. USHORT Reserved;
  102. //
  103. // Update Sequence Array. Used to protect the page block.
  104. //
  105. UPDATE_SEQUENCE_ARRAY UpdateSequenceArray;
  106. } LFS_UNPACKED_RECORD_PAGE, *PLFS_UNPACKED_RECORD_PAGE;
  107. typedef struct _LFS_PACKED_RECORD_PAGE {
  108. //
  109. // This gives us the offset of the free space in the page.
  110. //
  111. USHORT NextRecordOffset;
  112. USHORT WordAlign;
  113. ULONG DWordAlign;
  114. //
  115. // The following is the Lsn for the last log record which ends on the page.
  116. //
  117. LSN LastEndLsn;
  118. //
  119. // Update Sequence Array. Used to protect the page block.
  120. //
  121. UPDATE_SEQUENCE_ARRAY UpdateSequenceArray;
  122. } LFS_PACKED_RECORD_PAGE, *PLFS_PACKED_RECORD_PAGE;
  123. //
  124. // Log Record Page Header. This structure is present at the beginning of each
  125. // log file page in the client record section.
  126. //
  127. typedef struct _LFS_RECORD_PAGE_HEADER {
  128. //
  129. // Cache multisector protection header.
  130. //
  131. MULTI_SECTOR_HEADER MultiSectorHeader;
  132. union {
  133. //
  134. // Highest Lsn in this log file page. This field is only for
  135. // regular log pages.
  136. //
  137. LSN LastLsn;
  138. //
  139. // Log file offset. This is for the tail copies and indicates the
  140. // location in the file where the original lays. In this case the
  141. // LastLsn field above can be obtained from the last ending Lsn
  142. // field in the PACKED_RECORD_PAGE structure.
  143. //
  144. LONGLONG FileOffset;
  145. } Copy;
  146. //
  147. // Page Header Flags. These are the same flags that are stored in the
  148. // Lbcb->Flags field.
  149. //
  150. // LOG_PAGE_LOG_RECORD_END - Page contains the end of a log record
  151. //
  152. ULONG Flags;
  153. //
  154. // I/O Page Position. The following fields are used to determine
  155. // where this log page resides within a Lfs I/O transfer.
  156. //
  157. USHORT PageCount;
  158. USHORT PagePosition;
  159. //
  160. // The following is the difference between version 1.1 and earlier.
  161. //
  162. union {
  163. LFS_UNPACKED_RECORD_PAGE Unpacked;
  164. LFS_PACKED_RECORD_PAGE Packed;
  165. } Header;
  166. } LFS_RECORD_PAGE_HEADER, *PLFS_RECORD_PAGE_HEADER;
  167. #define LOG_PAGE_LOG_RECORD_END (0x00000001)
  168. #define LFS_UNPACKED_RECORD_PAGE_HEADER_SIZE ( \
  169. FIELD_OFFSET( LFS_RECORD_PAGE_HEADER, Header.Unpacked.UpdateSequenceArray ) \
  170. )
  171. #define LFS_PACKED_RECORD_PAGE_HEADER_SIZE ( \
  172. FIELD_OFFSET( LFS_RECORD_PAGE_HEADER, Header.Packed.UpdateSequenceArray ) \
  173. )
  174. //
  175. // Id strings for the page headers.
  176. //
  177. #define LFS_SIGNATURE_RESTART_PAGE "RSTR"
  178. #define LFS_SIGNATURE_RESTART_PAGE_ULONG 0x52545352
  179. #define LFS_SIGNATURE_RECORD_PAGE "RCRD"
  180. #define LFS_SIGNATURE_RECORD_PAGE_ULONG 0x44524352
  181. #define LFS_SIGNATURE_BAD_USA "BAAD"
  182. #define LFS_SIGNATURE_BAD_USA_ULONG 0x44414142
  183. #define LFS_SIGNATURE_MODIFIED "CHKD"
  184. #define LFS_SIGNATURE_MODIFIED_ULONG 0x444b4843
  185. #define LFS_SIGNATURE_UNINITIALIZED "\377\377\377\377"
  186. #define LFS_SIGNATURE_UNINITIALIZED_ULONG 0xffffffff
  187. //
  188. // Log Client Record. A log client record exists for each client user of
  189. // the log file. One of these is in each Lfs restart area.
  190. //
  191. #define LFS_NO_CLIENT 0xffff
  192. #define LFS_CLIENT_NAME_MAX 64
  193. #define RESTART_SINGLE_PAGE_IO (0x0001)
  194. #define LFS_RESTART_AREA_SIZE (FIELD_OFFSET( LFS_RESTART_AREA, LogClientArray ))
  195. #endif // _LFSDISK_