fsimage.proto 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. option java_package = "org.apache.hadoop.hdfs.server.namenode";
  19. option java_outer_classname = "FsImageProto";
  20. package hadoop.hdfs.fsimage;
  21. import "hdfs.proto";
  22. import "acl.proto";
  23. import "xattr.proto";
  24. /**
  25. * This file defines the on-disk layout of the file system image. The
  26. * layout is defined by the following EBNF grammar, in which angle
  27. * brackets mark protobuf definitions. (e.g., <FileSummary>)
  28. *
  29. * FILE := MAGIC SECTION* <FileSummary> FileSummaryLength
  30. * MAGIC := 'HDFSIMG1'
  31. * SECTION := <NameSystemSection> | ...
  32. * FileSummaryLength := 4 byte int
  33. *
  34. * Some notes:
  35. *
  36. * The codec field in FileSummary describes the compression codec used
  37. * for all sections. The fileheader is always uncompressed.
  38. *
  39. * All protobuf messages are serialized in delimited form, which means
  40. * that there always will be an integer indicates the size of the
  41. * protobuf message.
  42. *
  43. */
  44. message FileSummary {
  45. // The version of the above EBNF grammars.
  46. required uint32 ondiskVersion = 1;
  47. // layoutVersion describes which features are available in the
  48. // FSImage.
  49. required uint32 layoutVersion = 2;
  50. optional string codec = 3;
  51. // index for each section
  52. message Section {
  53. optional string name = 1;
  54. optional uint64 length = 2;
  55. optional uint64 offset = 3;
  56. }
  57. repeated Section sections = 4;
  58. }
  59. /**
  60. * Name: NS_INFO
  61. */
  62. message NameSystemSection {
  63. optional uint32 namespaceId = 1;
  64. optional uint64 genstampV1 = 2;
  65. optional uint64 genstampV2 = 3;
  66. optional uint64 genstampV1Limit = 4;
  67. optional uint64 lastAllocatedBlockId = 5;
  68. optional uint64 transactionId = 6;
  69. optional uint64 rollingUpgradeStartTime = 7;
  70. optional uint64 lastAllocatedStripedBlockId = 8;
  71. }
  72. /**
  73. * Permission is serialized as a 64-bit long. [0:24):[25:48):[48:64) (in Big Endian).
  74. * The first and the second parts are the string ids of the user and
  75. * group name, and the last 16 bits are the permission bits.
  76. *
  77. * Name: INODE
  78. */
  79. message INodeSection {
  80. /**
  81. * under-construction feature for INodeFile
  82. */
  83. message FileUnderConstructionFeature {
  84. optional string clientName = 1;
  85. optional string clientMachine = 2;
  86. }
  87. message StripedBlocksFeature {
  88. repeated StripedBlockProto blocks = 1;
  89. }
  90. message AclFeatureProto {
  91. /**
  92. * An ACL entry is represented by a 32-bit integer in Big Endian
  93. * format. The bits can be divided in four segments:
  94. * [0:2) || [2:26) || [26:27) || [27:29) || [29:32)
  95. *
  96. * [0:2) -- reserved for futute uses.
  97. * [2:26) -- the name of the entry, which is an ID that points to a
  98. * string in the StringTableSection.
  99. * [26:27) -- the scope of the entry (AclEntryScopeProto)
  100. * [27:29) -- the type of the entry (AclEntryTypeProto)
  101. * [29:32) -- the permission of the entry (FsActionProto)
  102. *
  103. */
  104. repeated fixed32 entries = 2 [packed = true];
  105. }
  106. message XAttrCompactProto {
  107. /**
  108. *
  109. * [0:2) -- the namespace of XAttr (XAttrNamespaceProto)
  110. * [2:26) -- the name of the entry, which is an ID that points to a
  111. * string in the StringTableSection.
  112. * [26:27) -- namespace extension. Originally there were only 4 namespaces
  113. * so only 2 bits were needed. At that time, this bit was reserved. When a
  114. * 5th namespace was created (raw) this bit became used as a 3rd namespace
  115. * bit.
  116. * [27:32) -- reserved for future uses.
  117. */
  118. required fixed32 name = 1;
  119. optional bytes value = 2;
  120. }
  121. message XAttrFeatureProto {
  122. repeated XAttrCompactProto xAttrs = 1;
  123. }
  124. message INodeFile {
  125. optional uint32 replication = 1;
  126. optional uint64 modificationTime = 2;
  127. optional uint64 accessTime = 3;
  128. optional uint64 preferredBlockSize = 4;
  129. optional fixed64 permission = 5;
  130. repeated BlockProto blocks = 6;
  131. optional FileUnderConstructionFeature fileUC = 7;
  132. optional AclFeatureProto acl = 8;
  133. optional XAttrFeatureProto xAttrs = 9;
  134. optional uint32 storagePolicyID = 10;
  135. optional StripedBlocksFeature stripedBlocks = 11;
  136. }
  137. message QuotaByStorageTypeEntryProto {
  138. required StorageTypeProto storageType = 1;
  139. required uint64 quota = 2;
  140. }
  141. message QuotaByStorageTypeFeatureProto {
  142. repeated QuotaByStorageTypeEntryProto quotas = 1;
  143. }
  144. message INodeDirectory {
  145. optional uint64 modificationTime = 1;
  146. // namespace quota
  147. optional uint64 nsQuota = 2;
  148. // diskspace quota
  149. optional uint64 dsQuota = 3;
  150. optional fixed64 permission = 4;
  151. optional AclFeatureProto acl = 5;
  152. optional XAttrFeatureProto xAttrs = 6;
  153. optional QuotaByStorageTypeFeatureProto typeQuotas = 7;
  154. }
  155. message INodeSymlink {
  156. optional fixed64 permission = 1;
  157. optional bytes target = 2;
  158. optional uint64 modificationTime = 3;
  159. optional uint64 accessTime = 4;
  160. }
  161. message INode {
  162. enum Type {
  163. FILE = 1;
  164. DIRECTORY = 2;
  165. SYMLINK = 3;
  166. };
  167. required Type type = 1;
  168. required uint64 id = 2;
  169. optional bytes name = 3;
  170. optional INodeFile file = 4;
  171. optional INodeDirectory directory = 5;
  172. optional INodeSymlink symlink = 6;
  173. }
  174. optional uint64 lastInodeId = 1;
  175. optional uint64 numInodes = 2;
  176. // repeated INodes..
  177. }
  178. /**
  179. * This section records information about under-construction files for
  180. * reconstructing the lease map.
  181. * NAME: FILES_UNDERCONSTRUCTION
  182. */
  183. message FilesUnderConstructionSection {
  184. message FileUnderConstructionEntry {
  185. optional uint64 inodeId = 1;
  186. optional string fullPath = 2;
  187. }
  188. // repeated FileUnderConstructionEntry...
  189. }
  190. /**
  191. * This section records the children of each directories
  192. * NAME: INODE_DIR
  193. */
  194. message INodeDirectorySection {
  195. /**
  196. * A single DirEntry needs to fit in the default PB max message size of
  197. * 64MB. Please be careful when adding more fields to a DirEntry!
  198. */
  199. message DirEntry {
  200. optional uint64 parent = 1;
  201. // children that are not reference nodes
  202. repeated uint64 children = 2 [packed = true];
  203. // children that are reference nodes, each element is a reference node id
  204. repeated uint32 refChildren = 3 [packed = true];
  205. }
  206. // repeated DirEntry, ended at the boundary of the section.
  207. }
  208. message INodeReferenceSection {
  209. message INodeReference {
  210. // id of the referred inode
  211. optional uint64 referredId = 1;
  212. // local name recorded in WithName
  213. optional bytes name = 2;
  214. // recorded in DstReference
  215. optional uint32 dstSnapshotId = 3;
  216. // recorded in WithName
  217. optional uint32 lastSnapshotId = 4;
  218. }
  219. // repeated INodeReference...
  220. }
  221. /**
  222. * This section records the information about snapshot
  223. * NAME: SNAPSHOT
  224. */
  225. message SnapshotSection {
  226. message Snapshot {
  227. optional uint32 snapshotId = 1;
  228. // Snapshot root
  229. optional INodeSection.INode root = 2;
  230. }
  231. optional uint32 snapshotCounter = 1;
  232. repeated uint64 snapshottableDir = 2 [packed = true];
  233. // total number of snapshots
  234. optional uint32 numSnapshots = 3;
  235. // repeated Snapshot...
  236. }
  237. /**
  238. * This section records information about snapshot diffs
  239. * NAME: SNAPSHOT_DIFF
  240. */
  241. message SnapshotDiffSection {
  242. message CreatedListEntry {
  243. optional bytes name = 1;
  244. }
  245. message DirectoryDiff {
  246. optional uint32 snapshotId = 1;
  247. optional uint32 childrenSize = 2;
  248. optional bool isSnapshotRoot = 3;
  249. optional bytes name = 4;
  250. optional INodeSection.INodeDirectory snapshotCopy = 5;
  251. optional uint32 createdListSize = 6;
  252. repeated uint64 deletedINode = 7 [packed = true]; // id of deleted inodes
  253. // id of reference nodes in the deleted list
  254. repeated uint32 deletedINodeRef = 8 [packed = true];
  255. // repeated CreatedListEntry (size is specified by createdListSize)
  256. }
  257. message FileDiff {
  258. optional uint32 snapshotId = 1;
  259. optional uint64 fileSize = 2;
  260. optional bytes name = 3;
  261. optional INodeSection.INodeFile snapshotCopy = 4;
  262. repeated BlockProto blocks = 5;
  263. }
  264. message DiffEntry {
  265. enum Type {
  266. FILEDIFF = 1;
  267. DIRECTORYDIFF = 2;
  268. }
  269. required Type type = 1;
  270. optional uint64 inodeId = 2;
  271. optional uint32 numOfDiff = 3;
  272. // repeated DirectoryDiff or FileDiff
  273. }
  274. // repeated DiffEntry
  275. }
  276. /**
  277. * This section maps string to id
  278. * NAME: STRING_TABLE
  279. */
  280. message StringTableSection {
  281. message Entry {
  282. optional uint32 id = 1;
  283. optional string str = 2;
  284. }
  285. optional uint32 numEntry = 1;
  286. // repeated Entry
  287. }
  288. message SecretManagerSection {
  289. message DelegationKey {
  290. optional uint32 id = 1;
  291. optional uint64 expiryDate = 2;
  292. optional bytes key = 3;
  293. }
  294. message PersistToken {
  295. optional uint32 version = 1;
  296. optional string owner = 2;
  297. optional string renewer = 3;
  298. optional string realUser = 4;
  299. optional uint64 issueDate = 5;
  300. optional uint64 maxDate = 6;
  301. optional uint32 sequenceNumber = 7;
  302. optional uint32 masterKeyId = 8;
  303. optional uint64 expiryDate = 9;
  304. }
  305. optional uint32 currentId = 1;
  306. optional uint32 tokenSequenceNumber = 2;
  307. optional uint32 numKeys = 3;
  308. optional uint32 numTokens = 4;
  309. // repeated DelegationKey keys
  310. // repeated PersistToken tokens
  311. }
  312. message CacheManagerSection {
  313. required uint64 nextDirectiveId = 1;
  314. required uint32 numPools = 2;
  315. required uint32 numDirectives = 3;
  316. // repeated CachePoolInfoProto pools
  317. // repeated CacheDirectiveInfoProto directives
  318. }