github.com/dennwc/btrfs@v0.0.0-20221026161108-3097362dc072/btrfs_tree_hc.go (about) 1 package btrfs 2 3 // This code was auto-generated; DO NOT EDIT! 4 5 type treeKeyType uint32 6 7 type objectID uint64 8 9 type fileType int 10 11 type fileExtentType int 12 13 type devReplaceItemState int 14 15 type blockGroup uint64 16 17 // This header contains the structure definitions and constants used 18 // by file system objects that can be retrieved using 19 // the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that 20 // is needed to describe a leaf node's key or item contents. 21 22 const ( 23 // Holds pointers to all of the tree roots 24 rootTreeObjectid objectID = 1 25 26 // Stores information about which extents are in use, and reference counts 27 extentTreeObjectid objectID = 2 28 29 // Chunk tree stores translations from logical -> physical block numbering 30 // the super block points to the chunk tree 31 chunkTreeObjectid objectID = 3 32 33 // Stores information about which areas of a given device are in use. 34 // one per device. The tree of tree roots points to the device tree 35 devTreeObjectid objectID = 4 36 37 // One per subvolume, storing files and directories 38 fsTreeObjectid objectID = 5 39 40 // Directory objectid inside the root tree 41 rootTreeDirObjectid objectID = 6 42 43 // Holds checksums of all the data extents 44 csumTreeObjectid objectID = 7 45 46 // Holds quota configuration and tracking 47 quotaTreeObjectid objectID = 8 48 49 // For storing items that use the BTRFS_UUID_KEY* types 50 uuidTreeObjectid objectID = 9 51 52 // Tracks free space in block groups. 53 freeSpaceTreeObjectid objectID = 10 54 55 // Device stats in the device tree 56 devStatsObjectid objectID = 0 57 58 // For storing balance parameters in the root tree 59 balanceObjectid objectID = (1<<64 - 4) 60 61 // Orhpan objectid for tracking unlinked/truncated files 62 orphanObjectid objectID = (1<<64 - 5) 63 64 // Does write ahead logging to speed up fsyncs 65 treeLogObjectid objectID = (1<<64 - 6) 66 treeLogFixupObjectid objectID = (1<<64 - 7) 67 68 // For space balancing 69 treeRelocObjectid objectID = (1<<64 - 8) 70 dataRelocTreeObjectid objectID = (1<<64 - 9) 71 72 // Extent checksums all have this objectid 73 // this allows them to share the logging tree 74 // for fsyncs 75 extentCsumObjectid objectID = (1<<64 - 10) 76 77 // For storing free space cache 78 freeSpaceObjectid objectID = (1<<64 - 11) 79 80 // The inode number assigned to the special inode for storing 81 // free ino cache 82 freeInoObjectid objectID = (1<<64 - 12) 83 84 // Dummy objectid represents multiple objectids 85 multipleObjectids = (1<<64 - 255) 86 87 // All files have objectids in this range. 88 firstFreeObjectid objectID = 256 89 lastFreeObjectid objectID = (1<<64 - 256) 90 firstChunkTreeObjectid objectID = 256 91 92 // The device items go into the chunk tree. The key is in the form 93 // [ 1 BTRFS_DEV_ITEM_KEY device_id ] 94 devItemsObjectid objectID = 1 95 96 btreeInodeObjectid objectID = 1 97 98 emptySubvolDirObjectid objectID = 2 99 100 devReplaceDevid = 0 101 102 // Inode items have the data typically returned from stat and store other 103 // info about object characteristics. There is one for every file and dir in 104 // the FS 105 inodeItemKey treeKeyType = 1 106 inodeRefKey treeKeyType = 12 107 inodeExtrefKey treeKeyType = 13 108 xattrItemKey treeKeyType = 24 109 orphanItemKey treeKeyType = 48 110 // Reserve 2-15 close to the inode for later flexibility 111 112 // Dir items are the name -> inode pointers in a directory. There is one 113 // for every name in a directory. 114 dirLogItemKey treeKeyType = 60 115 dirLogIndexKey treeKeyType = 72 116 dirItemKey treeKeyType = 84 117 dirIndexKey treeKeyType = 96 118 // Extent data is for file data 119 extentDataKey treeKeyType = 108 120 121 // Extent csums are stored in a separate tree and hold csums for 122 // an entire extent on disk. 123 extentCsumKey treeKeyType = 128 124 125 // Root items point to tree roots. They are typically in the root 126 // tree used by the super block to find all the other trees 127 rootItemKey treeKeyType = 132 128 129 // Root backrefs tie subvols and snapshots to the directory entries that 130 // reference them 131 rootBackrefKey treeKeyType = 144 132 133 // Root refs make a fast index for listing all of the snapshots and 134 // subvolumes referenced by a given root. They point directly to the 135 // directory item in the root that references the subvol 136 rootRefKey treeKeyType = 156 137 138 // Extent items are in the extent map tree. These record which blocks 139 // are used, and how many references there are to each block 140 extentItemKey treeKeyType = 168 141 142 // The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know 143 // the length, so we save the level in key->offset instead of the length. 144 metadataItemKey treeKeyType = 169 145 146 treeBlockRefKey treeKeyType = 176 147 148 extentDataRefKey treeKeyType = 178 149 150 extentRefV0Key treeKeyType = 180 151 152 sharedBlockRefKey treeKeyType = 182 153 154 sharedDataRefKey treeKeyType = 184 155 156 // Block groups give us hints into the extent allocation trees. Which 157 // blocks are free etc etc 158 blockGroupItemKey treeKeyType = 192 159 160 // Every block group is represented in the free space tree by a free space info 161 // item, which stores some accounting information. It is keyed on 162 // (block_group_start, FREE_SPACE_INFO, block_group_length). 163 freeSpaceInfoKey treeKeyType = 198 164 165 // A free space extent tracks an extent of space that is free in a block group. 166 // It is keyed on (start, FREE_SPACE_EXTENT, length). 167 freeSpaceExtentKey treeKeyType = 199 168 169 // When a block group becomes very fragmented, we convert it to use bitmaps 170 // instead of extents. A free space bitmap is keyed on 171 // (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with 172 // (length / sectorsize) bits. 173 freeSpaceBitmapKey treeKeyType = 200 174 175 devExtentKey treeKeyType = 204 176 devItemKey treeKeyType = 216 177 chunkItemKey treeKeyType = 228 178 179 // Records the overall state of the qgroups. 180 // There's only one instance of this key present, 181 // (0, BTRFS_QGROUP_STATUS_KEY, 0) 182 qgroupStatusKey treeKeyType = 240 183 // Records the currently used space of the qgroup. 184 // One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid). 185 qgroupInfoKey treeKeyType = 242 186 // Contains the user configured limits for the qgroup. 187 // One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid). 188 qgroupLimitKey treeKeyType = 244 189 // Records the child-parent relationship of qgroups. For 190 // each relation, 2 keys are present: 191 // (childid, BTRFS_QGROUP_RELATION_KEY, parentid) 192 // (parentid, BTRFS_QGROUP_RELATION_KEY, childid) 193 qgroupRelationKey treeKeyType = 246 194 195 // Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY. 196 balanceItemKey treeKeyType = 248 197 198 // The key type for tree items that are stored persistently, but do not need to 199 // exist for extended period of time. The items can exist in any tree. 200 // [subtype, BTRFS_TEMPORARY_ITEM_KEY, data] 201 // Existing items: 202 // - balance status item 203 // (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0) 204 temporaryItemKey treeKeyType = 248 205 206 // Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY 207 devStatsKey treeKeyType = 249 208 209 // The key type for tree items that are stored persistently and usually exist 210 // for a long period, eg. filesystem lifetime. The item kinds can be status 211 // information, stats or preference values. The item can exist in any tree. 212 // [subtype, BTRFS_PERSISTENT_ITEM_KEY, data] 213 // Existing items: 214 // - device statistics, store IO stats in the device tree, one key for all 215 // stats 216 // (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0) 217 persistentItemKey treeKeyType = 249 218 219 // Persistantly stores the device replace state in the device tree. 220 // The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0). 221 devReplaceKey treeKeyType = 250 222 223 // Stores items that allow to quickly map UUIDs to something else. 224 // These items are part of the filesystem UUID tree. 225 // The key is built like this: 226 // (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits). 227 uuidKeySubvol = 251 228 uuidKeyReceivedSubvol = 252 229 230 // String items are for debugging. They just store a short string of 231 // data in the FS 232 stringItemKey treeKeyType = 253 233 234 // 32 bytes in various csum fields 235 csumSize = 32 236 237 // Csum types 238 csumTypeCrc32 = 0 239 240 // Flags definitions for directory entry item type 241 // Used by: 242 // struct btrfs_dir_item.type 243 ftUnknown fileType = 0 244 ftRegFile fileType = 1 245 ftDir fileType = 2 246 ftChrdev fileType = 3 247 ftBlkdev fileType = 4 248 ftFifo fileType = 5 249 ftSock fileType = 6 250 ftSymlink fileType = 7 251 ftXattr fileType = 8 252 ftMax fileType = 9 253 254 // The key defines the order in the tree, and so it also defines (optimal) 255 // block layout. 256 // objectid corresponds to the inode number. 257 // type tells us things about the object, and is a kind of stream selector. 258 // so for a given inode, keys with type of 1 might refer to the inode data, 259 // type of 2 may point to file data in the btree and type == 3 may point to 260 // extents. 261 // offset is the starting byte offset for this key in the stream. 262 // btrfs_disk_key is in disk byte order. struct btrfs_key is always 263 // in cpu native order. Otherwise they are identical and their sizes 264 // should be the same (ie both packed) 265 266 // The internal btrfs device id 267 268 // Size of the device 269 270 // Bytes used 271 272 // Optimal io alignment for this device 273 274 // Optimal io width for this device 275 276 // Minimal io size for this device 277 278 // Type and info about this device 279 280 // Expected generation for this device 281 282 // Starting byte of this partition on the device, 283 // to allow for stripe alignment in the future 284 285 // Grouping information for allocation decisions 286 287 // Seek speed 0-100 where 100 is fastest 288 289 // Bandwidth 0-100 where 100 is fastest 290 291 // Btrfs generated uuid for this device 292 293 // Uuid of FS who owns this device 294 295 // Size of this chunk in bytes 296 297 // Objectid of the root referencing this chunk 298 299 // Optimal io alignment for this chunk 300 301 // Optimal io width for this chunk 302 303 // Minimal io size for this chunk 304 305 // 2^16 stripes is quite a lot, a second limit is the size of a single 306 // item in the btree 307 308 // Sub stripes only matter for raid10 309 // Additional stripes go here 310 311 freeSpaceExtent = 1 312 freeSpaceBitmap = 2 313 314 headerFlagWritten = (1 << 0) 315 headerFlagReloc = (1 << 1) 316 317 // Super block flags 318 // Errors detected 319 superFlagError = (1 << 2) 320 321 superFlagSeeding = (1 << 32) 322 superFlagMetadump = (1 << 33) 323 324 // Items in the extent btree are used to record the objectid of the 325 // owner of the block and the number of references 326 327 extentFlagData = (1 << 0) 328 extentFlagTreeBlock = (1 << 1) 329 330 // Following flags only apply to tree blocks 331 332 // Use full backrefs for extent pointers in the block 333 blockFlagFullBackref = (1 << 8) 334 335 // This flag is only used internally by scrub and may be changed at any time 336 // it is only declared here to avoid collisions 337 extentFlagSuper = (1 << 48) 338 339 // Old style backrefs item 340 341 // Dev extents record free space on individual devices. The owner 342 // field points back to the chunk allocation mapping tree that allocated 343 // the extent. The chunk tree uuid field is a way to double check the owner 344 345 // Name goes here 346 347 // Name goes here 348 349 // Nfs style generation number 350 // Transid that last touched this inode 351 352 // Modification sequence number for NFS 353 354 // A little future expansion, for more than this we can 355 // just grow the inode item and version it 356 357 rootSubvolRdonly = (1 << 0) 358 359 // Internal in-memory flag that a subvolume has been marked for deletion but 360 // still visible as a directory 361 rootSubvolDead = (1 << 48) 362 363 // The following fields appear after subvol_uuids+subvol_times 364 // were introduced. 365 366 // This generation number is used to test if the new fields are valid 367 // and up to date while reading the root item. Every time the root item 368 // is written out, the "generation" field is copied into this field. If 369 // anyone ever mounted the fs with an older kernel, we will have 370 // mismatching generation values here and thus must invalidate the 371 // new fields. See btrfs_update_root and btrfs_find_last_root for 372 // details. 373 // the offset of generation_v2 is also used as the start for the memset 374 // when invalidating the fields. 375 376 // This is used for both forward and backward root refs 377 378 // Profiles to operate on, single is denoted by 379 // BTRFS_AVAIL_ALLOC_BIT_SINGLE 380 381 // Usage filter 382 // BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N' 383 // BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max 384 385 // Devid filter 386 387 // Devid subset filter [pstart..pend) 388 389 // Btrfs virtual address space subset filter [vstart..vend) 390 391 // Profile to convert to, single is denoted by 392 // BTRFS_AVAIL_ALLOC_BIT_SINGLE 393 394 // BTRFS_BALANCE_ARGS_* 395 396 // BTRFS_BALANCE_ARGS_LIMIT with value 'limit' 397 // BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum 398 // and maximum 399 400 // Process chunks that cross stripes_min..stripes_max devices, 401 // BTRFS_BALANCE_ARGS_STRIPES_RANGE 402 403 // Store balance parameters to disk so that balance can be properly 404 // resumed after crash or unmount 405 // BTRFS_BALANCE_* 406 407 fileExtentInline fileExtentType = 0 408 fileExtentReg fileExtentType = 1 409 fileExtentPrealloc fileExtentType = 2 410 411 // Transaction id that created this extent 412 // Max number of bytes to hold this extent in ram 413 // when we split a compressed extent we can't know how big 414 // each of the resulting pieces will be. So, this is 415 // an upper limit on the size of the extent in ram instead of 416 // an exact limit. 417 418 // 32 bits for the various ways we might encode the data, 419 // including compression and encryption. If any of these 420 // are set to something a given disk format doesn't understand 421 // it is treated like an incompat flag for reading and writing, 422 // but not for stat. 423 424 // Are we inline data or a real extent? 425 426 // Disk space consumed by the extent, checksum blocks are included 427 // in these numbers 428 // At this offset in the structure, the inline extent data start. 429 // The logical offset in file blocks (no csums) 430 // this extent record is for. This allows a file extent to point 431 // into the middle of an existing extent on disk, sharing it 432 // between two snapshots (useful if some bytes in the middle of the 433 // extent have changed 434 // The logical number of file blocks (no csums included). This 435 // always reflects the size uncompressed and without encoding. 436 437 // Grow this item struct at the end for future enhancements and keep 438 // the existing values unchanged 439 440 devReplaceItemContReadingFromSrcdevModeAlways = 0 441 devReplaceItemContReadingFromSrcdevModeAvoid = 1 442 devReplaceItemStateNeverStarted devReplaceItemState = 0 443 devReplaceItemStateStarted devReplaceItemState = 1 444 devReplaceItemStateSuspended devReplaceItemState = 2 445 devReplaceItemStateFinished devReplaceItemState = 3 446 devReplaceItemStateCanceled devReplaceItemState = 4 447 448 // Grow this item struct at the end for future enhancements and keep 449 // the existing values unchanged 450 451 // Different types of block groups (and chunks) 452 blockGroupData blockGroup = (1 << 0) 453 blockGroupSystem blockGroup = (1 << 1) 454 blockGroupMetadata blockGroup = (1 << 2) 455 blockGroupRaid0 blockGroup = (1 << 3) 456 blockGroupRaid1 blockGroup = (1 << 4) 457 blockGroupDup blockGroup = (1 << 5) 458 blockGroupRaid10 blockGroup = (1 << 6) 459 blockGroupRaid5 blockGroup = (1 << 7) 460 blockGroupRaid6 blockGroup = (1 << 8) 461 462 // We need a bit for restriper to be able to tell when chunks of type 463 // SINGLE are available. This "extended" profile format is used in 464 // fs_info->avail_*_alloc_bits (in-memory) and balance item fields 465 // (on-disk). The corresponding on-disk bit in chunk.type is reserved 466 // to avoid remappings between two formats in future. 467 availAllocBitSingle = (1 << 48) 468 469 // A fake block group type that is used to communicate global block reserve 470 // size to userspace via the SPACE_INFO ioctl. 471 spaceInfoGlobalRsv = (1 << 49) 472 473 freeSpaceUsingBitmaps = (1 << 0) 474 475 qgroupLevelShift = 48 476 477 // Is subvolume quota turned on? 478 qgroupStatusFlagOn = (1 << 0) 479 // RESCAN is set during the initialization phase 480 qgroupStatusFlagRescan = (1 << 1) 481 // Some qgroup entries are known to be out of date, 482 // either because the configuration has changed in a way that 483 // makes a rescan necessary, or because the fs has been mounted 484 // with a non-qgroup-aware version. 485 // Turning qouta off and on again makes it inconsistent, too. 486 qgroupStatusFlagInconsistent = (1 << 2) 487 488 qgroupStatusVersion = 1 489 490 // The generation is updated during every commit. As older 491 // versions of btrfs are not aware of qgroups, it will be 492 // possible to detect inconsistencies by checking the 493 // generation on mount time 494 495 // Flag definitions see above 496 497 // Only used during scanning to record the progress 498 // of the scan. It contains a logical address 499 500 // Only updated when any of the other values change 501 502 )