fsimage.proto 10.0 KB

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