fsimage.proto 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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; // legacy generation stamp
  65. optional uint64 genstampV2 = 3; // generation stamp of latest version
  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 AclFeatureProto {
  88. /**
  89. * An ACL entry is represented by a 32-bit integer in Big Endian
  90. * format. The bits can be divided in four segments:
  91. * [0:2) || [2:26) || [26:27) || [27:29) || [29:32)
  92. *
  93. * [0:2) -- reserved for futute uses.
  94. * [2:26) -- the name of the entry, which is an ID that points to a
  95. * string in the StringTableSection.
  96. * [26:27) -- the scope of the entry (AclEntryScopeProto)
  97. * [27:29) -- the type of the entry (AclEntryTypeProto)
  98. * [29:32) -- the permission of the entry (FsActionProto)
  99. *
  100. */
  101. repeated fixed32 entries = 2 [packed = true];
  102. }
  103. message XAttrCompactProto {
  104. /**
  105. *
  106. * [0:2) -- the namespace of XAttr (XAttrNamespaceProto)
  107. * [2:26) -- the name of the entry, which is an ID that points to a
  108. * string in the StringTableSection.
  109. * [26:27) -- namespace extension. Originally there were only 4 namespaces
  110. * so only 2 bits were needed. At that time, this bit was reserved. When a
  111. * 5th namespace was created (raw) this bit became used as a 3rd namespace
  112. * bit.
  113. * [27:32) -- reserved for future uses.
  114. */
  115. required fixed32 name = 1;
  116. optional bytes value = 2;
  117. }
  118. message XAttrFeatureProto {
  119. repeated XAttrCompactProto xAttrs = 1;
  120. }
  121. message INodeFile {
  122. optional uint32 replication = 1;
  123. optional uint64 modificationTime = 2;
  124. optional uint64 accessTime = 3;
  125. optional uint64 preferredBlockSize = 4;
  126. optional fixed64 permission = 5;
  127. repeated BlockProto blocks = 6;
  128. optional FileUnderConstructionFeature fileUC = 7;
  129. optional AclFeatureProto acl = 8;
  130. optional XAttrFeatureProto xAttrs = 9;
  131. optional uint32 storagePolicyID = 10;
  132. optional BlockTypeProto blockType = 11;
  133. optional uint32 erasureCodingPolicyID = 12;
  134. }
  135. message QuotaByStorageTypeEntryProto {
  136. required StorageTypeProto storageType = 1;
  137. required uint64 quota = 2;
  138. }
  139. message QuotaByStorageTypeFeatureProto {
  140. repeated QuotaByStorageTypeEntryProto quotas = 1;
  141. }
  142. message INodeDirectory {
  143. optional uint64 modificationTime = 1;
  144. // namespace quota
  145. optional uint64 nsQuota = 2;
  146. // diskspace quota
  147. optional uint64 dsQuota = 3;
  148. optional fixed64 permission = 4;
  149. optional AclFeatureProto acl = 5;
  150. optional XAttrFeatureProto xAttrs = 6;
  151. optional QuotaByStorageTypeFeatureProto typeQuotas = 7;
  152. }
  153. message INodeSymlink {
  154. optional fixed64 permission = 1;
  155. optional bytes target = 2;
  156. optional uint64 modificationTime = 3;
  157. optional uint64 accessTime = 4;
  158. }
  159. message INode {
  160. enum Type {
  161. FILE = 1;
  162. DIRECTORY = 2;
  163. SYMLINK = 3;
  164. };
  165. required Type type = 1;
  166. required uint64 id = 2;
  167. optional bytes name = 3;
  168. optional INodeFile file = 4;
  169. optional INodeDirectory directory = 5;
  170. optional INodeSymlink symlink = 6;
  171. }
  172. optional uint64 lastInodeId = 1;
  173. optional uint64 numInodes = 2;
  174. // repeated INodes..
  175. }
  176. /**
  177. * This section records information about under-construction files for
  178. * reconstructing the lease map.
  179. * NAME: FILES_UNDERCONSTRUCTION
  180. */
  181. message FilesUnderConstructionSection {
  182. message FileUnderConstructionEntry {
  183. optional uint64 inodeId = 1;
  184. optional string fullPath = 2;
  185. }
  186. // repeated FileUnderConstructionEntry...
  187. }
  188. /**
  189. * This section records the children of each directories
  190. * NAME: INODE_DIR
  191. */
  192. message INodeDirectorySection {
  193. /**
  194. * A single DirEntry needs to fit in the default PB max message size of
  195. * 64MB. Please be careful when adding more fields to a DirEntry!
  196. */
  197. message DirEntry {
  198. optional uint64 parent = 1;
  199. // children that are not reference nodes
  200. repeated uint64 children = 2 [packed = true];
  201. // children that are reference nodes, each element is a reference node id
  202. repeated uint32 refChildren = 3 [packed = true];
  203. }
  204. // repeated DirEntry, ended at the boundary of the section.
  205. }
  206. message INodeReferenceSection {
  207. message INodeReference {
  208. // id of the referred inode
  209. optional uint64 referredId = 1;
  210. // local name recorded in WithName
  211. optional bytes name = 2;
  212. // recorded in DstReference
  213. optional uint32 dstSnapshotId = 3;
  214. // recorded in WithName
  215. optional uint32 lastSnapshotId = 4;
  216. }
  217. // repeated INodeReference...
  218. }
  219. /**
  220. * This section records the information about snapshot
  221. * NAME: SNAPSHOT
  222. */
  223. message SnapshotSection {
  224. message Snapshot {
  225. optional uint32 snapshotId = 1;
  226. // Snapshot root
  227. optional INodeSection.INode root = 2;
  228. }
  229. optional uint32 snapshotCounter = 1;
  230. repeated uint64 snapshottableDir = 2 [packed = true];
  231. // total number of snapshots
  232. optional uint32 numSnapshots = 3;
  233. // repeated Snapshot...
  234. }
  235. /**
  236. * This section records information about snapshot diffs
  237. * NAME: SNAPSHOT_DIFF
  238. */
  239. message SnapshotDiffSection {
  240. message CreatedListEntry {
  241. optional bytes name = 1;
  242. }
  243. message DirectoryDiff {
  244. optional uint32 snapshotId = 1;
  245. optional uint32 childrenSize = 2;
  246. optional bool isSnapshotRoot = 3;
  247. optional bytes name = 4;
  248. optional INodeSection.INodeDirectory snapshotCopy = 5;
  249. optional uint32 createdListSize = 6;
  250. repeated uint64 deletedINode = 7 [packed = true]; // id of deleted inodes
  251. // id of reference nodes in the deleted list
  252. repeated uint32 deletedINodeRef = 8 [packed = true];
  253. // repeated CreatedListEntry (size is specified by createdListSize)
  254. }
  255. message FileDiff {
  256. optional uint32 snapshotId = 1;
  257. optional uint64 fileSize = 2;
  258. optional bytes name = 3;
  259. optional INodeSection.INodeFile snapshotCopy = 4;
  260. repeated BlockProto blocks = 5;
  261. }
  262. message DiffEntry {
  263. enum Type {
  264. FILEDIFF = 1;
  265. DIRECTORYDIFF = 2;
  266. }
  267. required Type type = 1;
  268. optional uint64 inodeId = 2;
  269. optional uint32 numOfDiff = 3;
  270. // repeated DirectoryDiff or FileDiff
  271. }
  272. // repeated DiffEntry
  273. }
  274. /**
  275. * This section maps string to id
  276. * NAME: STRING_TABLE
  277. */
  278. message StringTableSection {
  279. message Entry {
  280. optional uint32 id = 1;
  281. optional string str = 2;
  282. }
  283. optional uint32 numEntry = 1;
  284. // repeated Entry
  285. }
  286. message SecretManagerSection {
  287. message DelegationKey {
  288. optional uint32 id = 1;
  289. optional uint64 expiryDate = 2;
  290. optional bytes key = 3;
  291. }
  292. message PersistToken {
  293. optional uint32 version = 1;
  294. optional string owner = 2;
  295. optional string renewer = 3;
  296. optional string realUser = 4;
  297. optional uint64 issueDate = 5;
  298. optional uint64 maxDate = 6;
  299. optional uint32 sequenceNumber = 7;
  300. optional uint32 masterKeyId = 8;
  301. optional uint64 expiryDate = 9;
  302. }
  303. optional uint32 currentId = 1;
  304. optional uint32 tokenSequenceNumber = 2;
  305. optional uint32 numKeys = 3;
  306. optional uint32 numTokens = 4;
  307. // repeated DelegationKey keys
  308. // repeated PersistToken tokens
  309. }
  310. message CacheManagerSection {
  311. required uint64 nextDirectiveId = 1;
  312. required uint32 numPools = 2;
  313. required uint32 numDirectives = 3;
  314. // repeated CachePoolInfoProto pools
  315. // repeated CacheDirectiveInfoProto directives
  316. }