1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _BTRFS_CTREE_H_ 3 #define _BTRFS_CTREE_H_ 4 5 #include <linux/btrfs.h> 6 #include <linux/types.h> 7 #ifdef __KERNEL__ 8 #include <linux/stddef.h> 9 #else 10 #include <stddef.h> 11 #endif 12 13 /* ASCII for _BHRfS_M, no terminating nul */ 14 #define BTRFS_MAGIC 0x4D5F53665248425FULL 15 16 #define BTRFS_MAX_LEVEL 8 17 18 /* 19 * We can actually store much bigger names, but lets not confuse the rest of 20 * linux. 21 */ 22 #define BTRFS_NAME_LEN 255 23 24 /* 25 * Theoretical limit is larger, but we keep this down to a sane value. That 26 * should limit greatly the possibility of collisions on inode ref items. 27 */ 28 #define BTRFS_LINK_MAX 65535U 29 30 /* 31 * This header contains the structure definitions and constants used 32 * by file system objects that can be retrieved using 33 * the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that 34 * is needed to describe a leaf node's key or item contents. 35 */ 36 37 /* holds pointers to all of the tree roots */ 38 #define BTRFS_ROOT_TREE_OBJECTID 1ULL 39 40 /* stores information about which extents are in use, and reference counts */ 41 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL 42 43 /* 44 * chunk tree stores translations from logical -> physical block numbering 45 * the super block points to the chunk tree 46 */ 47 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL 48 49 /* 50 * stores information about which areas of a given device are in use. 51 * one per device. The tree of tree roots points to the device tree 52 */ 53 #define BTRFS_DEV_TREE_OBJECTID 4ULL 54 55 /* one per subvolume, storing files and directories */ 56 #define BTRFS_FS_TREE_OBJECTID 5ULL 57 58 /* directory objectid inside the root tree */ 59 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL 60 61 /* holds checksums of all the data extents */ 62 #define BTRFS_CSUM_TREE_OBJECTID 7ULL 63 64 /* holds quota configuration and tracking */ 65 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL 66 67 /* for storing items that use the BTRFS_UUID_KEY* types */ 68 #define BTRFS_UUID_TREE_OBJECTID 9ULL 69 70 /* tracks free space in block groups. */ 71 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL 72 73 /* Holds the block group items for extent tree v2. */ 74 #define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL 75 76 /* Tracks RAID stripes in block groups. */ 77 #define BTRFS_RAID_STRIPE_TREE_OBJECTID 12ULL 78 79 /* Holds details of remapped addresses after relocation. */ 80 #define BTRFS_REMAP_TREE_OBJECTID 13ULL 81 82 /* device stats in the device tree */ 83 #define BTRFS_DEV_STATS_OBJECTID 0ULL 84 85 /* for storing balance parameters in the root tree */ 86 #define BTRFS_BALANCE_OBJECTID -4ULL 87 88 /* orphan objectid for tracking unlinked/truncated files */ 89 #define BTRFS_ORPHAN_OBJECTID -5ULL 90 91 /* does write ahead logging to speed up fsyncs */ 92 #define BTRFS_TREE_LOG_OBJECTID -6ULL 93 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL 94 95 /* for space balancing */ 96 #define BTRFS_TREE_RELOC_OBJECTID -8ULL 97 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL 98 99 /* 100 * extent checksums all have this objectid 101 * this allows them to share the logging tree 102 * for fsyncs 103 */ 104 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL 105 106 /* For storing free space cache */ 107 #define BTRFS_FREE_SPACE_OBJECTID -11ULL 108 109 /* 110 * The inode number assigned to the special inode for storing 111 * free ino cache 112 */ 113 #define BTRFS_FREE_INO_OBJECTID -12ULL 114 115 /* dummy objectid represents multiple objectids */ 116 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL 117 118 /* 119 * All files have objectids in this range. 120 */ 121 #define BTRFS_FIRST_FREE_OBJECTID 256ULL 122 #define BTRFS_LAST_FREE_OBJECTID -256ULL 123 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL 124 125 126 /* 127 * the device items go into the chunk tree. The key is in the form 128 * [ 1 BTRFS_DEV_ITEM_KEY device_id ] 129 */ 130 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL 131 132 #define BTRFS_BTREE_INODE_OBJECTID 1 133 134 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2 135 136 #define BTRFS_DEV_REPLACE_DEVID 0ULL 137 138 /* 139 * inode items have the data typically returned from stat and store other 140 * info about object characteristics. There is one for every file and dir in 141 * the FS 142 */ 143 #define BTRFS_INODE_ITEM_KEY 1 144 #define BTRFS_INODE_REF_KEY 12 145 #define BTRFS_INODE_EXTREF_KEY 13 146 #define BTRFS_XATTR_ITEM_KEY 24 147 148 /* 149 * fs verity items are stored under two different key types on disk. 150 * The descriptor items: 151 * [ inode objectid, BTRFS_VERITY_DESC_ITEM_KEY, offset ] 152 * 153 * At offset 0, we store a btrfs_verity_descriptor_item which tracks the size 154 * of the descriptor item and some extra data for encryption. 155 * Starting at offset 1, these hold the generic fs verity descriptor. The 156 * latter are opaque to btrfs, we just read and write them as a blob for the 157 * higher level verity code. The most common descriptor size is 256 bytes. 158 * 159 * The merkle tree items: 160 * [ inode objectid, BTRFS_VERITY_MERKLE_ITEM_KEY, offset ] 161 * 162 * These also start at offset 0, and correspond to the merkle tree bytes. When 163 * fsverity asks for page 0 of the merkle tree, we pull up one page starting at 164 * offset 0 for this key type. These are also opaque to btrfs, we're blindly 165 * storing whatever fsverity sends down. 166 */ 167 #define BTRFS_VERITY_DESC_ITEM_KEY 36 168 #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 169 170 #define BTRFS_ORPHAN_ITEM_KEY 48 171 /* reserve 2-15 close to the inode for later flexibility */ 172 173 /* 174 * dir items are the name -> inode pointers in a directory. There is one 175 * for every name in a directory. BTRFS_DIR_LOG_ITEM_KEY is no longer used 176 * but it's still defined here for documentation purposes and to help avoid 177 * having its numerical value reused in the future. 178 */ 179 #define BTRFS_DIR_LOG_ITEM_KEY 60 180 #define BTRFS_DIR_LOG_INDEX_KEY 72 181 #define BTRFS_DIR_ITEM_KEY 84 182 #define BTRFS_DIR_INDEX_KEY 96 183 /* 184 * extent data is for file data 185 */ 186 #define BTRFS_EXTENT_DATA_KEY 108 187 188 /* 189 * extent csums are stored in a separate tree and hold csums for 190 * an entire extent on disk. 191 */ 192 #define BTRFS_EXTENT_CSUM_KEY 128 193 194 /* 195 * root items point to tree roots. They are typically in the root 196 * tree used by the super block to find all the other trees 197 */ 198 #define BTRFS_ROOT_ITEM_KEY 132 199 200 /* 201 * root backrefs tie subvols and snapshots to the directory entries that 202 * reference them 203 */ 204 #define BTRFS_ROOT_BACKREF_KEY 144 205 206 /* 207 * root refs make a fast index for listing all of the snapshots and 208 * subvolumes referenced by a given root. They point directly to the 209 * directory item in the root that references the subvol 210 */ 211 #define BTRFS_ROOT_REF_KEY 156 212 213 /* 214 * extent items are in the extent map tree. These record which blocks 215 * are used, and how many references there are to each block 216 */ 217 #define BTRFS_EXTENT_ITEM_KEY 168 218 219 /* 220 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know 221 * the length, so we save the level in key->offset instead of the length. 222 */ 223 #define BTRFS_METADATA_ITEM_KEY 169 224 225 /* 226 * Special inline ref key which stores the id of the subvolume which originally 227 * created the extent. This subvolume owns the extent permanently from the 228 * perspective of simple quotas. Needed to know which subvolume to free quota 229 * usage from when the extent is deleted. 230 * 231 * Stored as an inline ref rather to avoid wasting space on a separate item on 232 * top of the existing extent item. However, unlike the other inline refs, 233 * there is one one owner ref per extent rather than one per extent. 234 * 235 * Because of this, it goes at the front of the list of inline refs, and thus 236 * must have a lower type value than any other inline ref type (to satisfy the 237 * disk format rule that inline refs have non-decreasing type). 238 */ 239 #define BTRFS_EXTENT_OWNER_REF_KEY 172 240 241 #define BTRFS_TREE_BLOCK_REF_KEY 176 242 243 #define BTRFS_EXTENT_DATA_REF_KEY 178 244 245 /* 246 * Obsolete key. Defintion removed in 6.6, value may be reused in the future. 247 * 248 * #define BTRFS_EXTENT_REF_V0_KEY 180 249 */ 250 251 #define BTRFS_SHARED_BLOCK_REF_KEY 182 252 253 #define BTRFS_SHARED_DATA_REF_KEY 184 254 255 /* 256 * block groups give us hints into the extent allocation trees. Which 257 * blocks are free etc etc 258 */ 259 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192 260 261 /* 262 * Every block group is represented in the free space tree by a free space info 263 * item, which stores some accounting information. It is keyed on 264 * (block_group_start, FREE_SPACE_INFO, block_group_length). 265 */ 266 #define BTRFS_FREE_SPACE_INFO_KEY 198 267 268 /* 269 * A free space extent tracks an extent of space that is free in a block group. 270 * It is keyed on (start, FREE_SPACE_EXTENT, length). 271 */ 272 #define BTRFS_FREE_SPACE_EXTENT_KEY 199 273 274 /* 275 * When a block group becomes very fragmented, we convert it to use bitmaps 276 * instead of extents. A free space bitmap is keyed on 277 * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with 278 * (length / sectorsize) bits. 279 */ 280 #define BTRFS_FREE_SPACE_BITMAP_KEY 200 281 282 #define BTRFS_DEV_EXTENT_KEY 204 283 #define BTRFS_DEV_ITEM_KEY 216 284 #define BTRFS_CHUNK_ITEM_KEY 228 285 286 #define BTRFS_RAID_STRIPE_KEY 230 287 288 #define BTRFS_IDENTITY_REMAP_KEY 234 289 #define BTRFS_REMAP_KEY 235 290 #define BTRFS_REMAP_BACKREF_KEY 236 291 292 /* 293 * Records the overall state of the qgroups. 294 * There's only one instance of this key present, 295 * (0, BTRFS_QGROUP_STATUS_KEY, 0) 296 */ 297 #define BTRFS_QGROUP_STATUS_KEY 240 298 /* 299 * Records the currently used space of the qgroup. 300 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid). 301 */ 302 #define BTRFS_QGROUP_INFO_KEY 242 303 /* 304 * Contains the user configured limits for the qgroup. 305 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid). 306 */ 307 #define BTRFS_QGROUP_LIMIT_KEY 244 308 /* 309 * Records the child-parent relationship of qgroups. For 310 * each relation, 2 keys are present: 311 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid) 312 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid) 313 */ 314 #define BTRFS_QGROUP_RELATION_KEY 246 315 316 /* 317 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY. 318 */ 319 #define BTRFS_BALANCE_ITEM_KEY 248 320 321 /* 322 * The key type for tree items that are stored persistently, but do not need to 323 * exist for extended period of time. The items can exist in any tree. 324 * 325 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data] 326 * 327 * Existing items: 328 * 329 * - balance status item 330 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0) 331 */ 332 #define BTRFS_TEMPORARY_ITEM_KEY 248 333 334 /* 335 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY 336 */ 337 #define BTRFS_DEV_STATS_KEY 249 338 339 /* 340 * The key type for tree items that are stored persistently and usually exist 341 * for a long period, eg. filesystem lifetime. The item kinds can be status 342 * information, stats or preference values. The item can exist in any tree. 343 * 344 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data] 345 * 346 * Existing items: 347 * 348 * - device statistics, store IO stats in the device tree, one key for all 349 * stats 350 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0) 351 */ 352 #define BTRFS_PERSISTENT_ITEM_KEY 249 353 354 /* 355 * Persistently stores the device replace state in the device tree. 356 * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0). 357 */ 358 #define BTRFS_DEV_REPLACE_KEY 250 359 360 /* 361 * Stores items that allow to quickly map UUIDs to something else. 362 * These items are part of the filesystem UUID tree. 363 * The key is built like this: 364 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits). 365 */ 366 #if BTRFS_UUID_SIZE != 16 367 #error "UUID items require BTRFS_UUID_SIZE == 16!" 368 #endif 369 #define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */ 370 #define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to 371 * received subvols */ 372 373 /* 374 * string items are for debugging. They just store a short string of 375 * data in the FS 376 */ 377 #define BTRFS_STRING_ITEM_KEY 253 378 379 /* Maximum metadata block size (nodesize) */ 380 #define BTRFS_MAX_METADATA_BLOCKSIZE 65536 381 382 /* 32 bytes in various csum fields */ 383 #define BTRFS_CSUM_SIZE 32 384 385 /* csum types */ 386 enum btrfs_csum_type { 387 BTRFS_CSUM_TYPE_CRC32 = 0, 388 BTRFS_CSUM_TYPE_XXHASH = 1, 389 BTRFS_CSUM_TYPE_SHA256 = 2, 390 BTRFS_CSUM_TYPE_BLAKE2 = 3, 391 }; 392 393 /* 394 * flags definitions for directory entry item type 395 * 396 * Used by: 397 * struct btrfs_dir_item.type 398 * 399 * Values 0..7 must match common file type values in fs_types.h. 400 */ 401 #define BTRFS_FT_UNKNOWN 0 402 #define BTRFS_FT_REG_FILE 1 403 #define BTRFS_FT_DIR 2 404 #define BTRFS_FT_CHRDEV 3 405 #define BTRFS_FT_BLKDEV 4 406 #define BTRFS_FT_FIFO 5 407 #define BTRFS_FT_SOCK 6 408 #define BTRFS_FT_SYMLINK 7 409 #define BTRFS_FT_XATTR 8 410 #define BTRFS_FT_MAX 9 411 /* Directory contains encrypted data */ 412 #define BTRFS_FT_ENCRYPTED 0x80 413 414 static inline __u8 btrfs_dir_flags_to_ftype(__u8 flags) 415 { 416 return flags & ~BTRFS_FT_ENCRYPTED; 417 } 418 419 /* 420 * Inode flags 421 */ 422 #define BTRFS_INODE_NODATASUM (1U << 0) 423 #define BTRFS_INODE_NODATACOW (1U << 1) 424 #define BTRFS_INODE_READONLY (1U << 2) 425 #define BTRFS_INODE_NOCOMPRESS (1U << 3) 426 #define BTRFS_INODE_PREALLOC (1U << 4) 427 #define BTRFS_INODE_SYNC (1U << 5) 428 #define BTRFS_INODE_IMMUTABLE (1U << 6) 429 #define BTRFS_INODE_APPEND (1U << 7) 430 #define BTRFS_INODE_NODUMP (1U << 8) 431 #define BTRFS_INODE_NOATIME (1U << 9) 432 #define BTRFS_INODE_DIRSYNC (1U << 10) 433 #define BTRFS_INODE_COMPRESS (1U << 11) 434 435 #define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31) 436 437 #define BTRFS_INODE_FLAG_MASK \ 438 (BTRFS_INODE_NODATASUM | \ 439 BTRFS_INODE_NODATACOW | \ 440 BTRFS_INODE_READONLY | \ 441 BTRFS_INODE_NOCOMPRESS | \ 442 BTRFS_INODE_PREALLOC | \ 443 BTRFS_INODE_SYNC | \ 444 BTRFS_INODE_IMMUTABLE | \ 445 BTRFS_INODE_APPEND | \ 446 BTRFS_INODE_NODUMP | \ 447 BTRFS_INODE_NOATIME | \ 448 BTRFS_INODE_DIRSYNC | \ 449 BTRFS_INODE_COMPRESS | \ 450 BTRFS_INODE_ROOT_ITEM_INIT) 451 452 #define BTRFS_INODE_RO_VERITY (1U << 0) 453 454 #define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY) 455 456 /* 457 * The key defines the order in the tree, and so it also defines (optimal) 458 * block layout. 459 * 460 * objectid corresponds to the inode number. 461 * 462 * type tells us things about the object, and is a kind of stream selector. 463 * so for a given inode, keys with type of 1 might refer to the inode data, 464 * type of 2 may point to file data in the btree and type == 3 may point to 465 * extents. 466 * 467 * offset is the starting byte offset for this key in the stream. 468 * 469 * btrfs_disk_key is in disk byte order. struct btrfs_key is always 470 * in cpu native order. Otherwise they are identical and their sizes 471 * should be the same (ie both packed) 472 */ 473 struct btrfs_disk_key { 474 __le64 objectid; 475 __u8 type; 476 __le64 offset; 477 } __attribute__ ((__packed__)); 478 479 struct btrfs_key { 480 __u64 objectid; 481 __u8 type; 482 __u64 offset; 483 } __attribute__ ((__packed__)); 484 485 /* 486 * Every tree block (leaf or node) starts with this header. 487 */ 488 struct btrfs_header { 489 /* These first four must match the super block */ 490 __u8 csum[BTRFS_CSUM_SIZE]; 491 /* FS specific uuid */ 492 __u8 fsid[BTRFS_FSID_SIZE]; 493 /* Which block this node is supposed to live in */ 494 __le64 bytenr; 495 __le64 flags; 496 497 /* Allowed to be different from the super from here on down */ 498 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; 499 __le64 generation; 500 __le64 owner; 501 __le32 nritems; 502 __u8 level; 503 } __attribute__ ((__packed__)); 504 505 /* 506 * This is a very generous portion of the super block, giving us room to 507 * translate 14 chunks with 3 stripes each. 508 */ 509 #define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048 510 511 /* 512 * Just in case we somehow lose the roots and are not able to mount, we store 513 * an array of the roots from previous transactions in the super. 514 */ 515 #define BTRFS_NUM_BACKUP_ROOTS 4 516 struct btrfs_root_backup { 517 __le64 tree_root; 518 __le64 tree_root_gen; 519 520 __le64 chunk_root; 521 __le64 chunk_root_gen; 522 523 __le64 extent_root; 524 __le64 extent_root_gen; 525 526 __le64 fs_root; 527 __le64 fs_root_gen; 528 529 __le64 dev_root; 530 __le64 dev_root_gen; 531 532 __le64 csum_root; 533 __le64 csum_root_gen; 534 535 __le64 total_bytes; 536 __le64 bytes_used; 537 __le64 num_devices; 538 /* future */ 539 __le64 unused_64[4]; 540 541 __u8 tree_root_level; 542 __u8 chunk_root_level; 543 __u8 extent_root_level; 544 __u8 fs_root_level; 545 __u8 dev_root_level; 546 __u8 csum_root_level; 547 /* future and to align */ 548 __u8 unused_8[10]; 549 } __attribute__ ((__packed__)); 550 551 /* 552 * A leaf is full of items. offset and size tell us where to find the item in 553 * the leaf (relative to the start of the data area) 554 */ 555 struct btrfs_item { 556 struct btrfs_disk_key key; 557 __le32 offset; 558 __le32 size; 559 } __attribute__ ((__packed__)); 560 561 /* 562 * Leaves have an item area and a data area: 563 * [item0, item1....itemN] [free space] [dataN...data1, data0] 564 * 565 * The data is separate from the items to get the keys closer together during 566 * searches. 567 */ 568 struct btrfs_leaf { 569 struct btrfs_header header; 570 struct btrfs_item items[]; 571 } __attribute__ ((__packed__)); 572 573 /* 574 * All non-leaf blocks are nodes, they hold only keys and pointers to other 575 * blocks. 576 */ 577 struct btrfs_key_ptr { 578 struct btrfs_disk_key key; 579 __le64 blockptr; 580 __le64 generation; 581 } __attribute__ ((__packed__)); 582 583 struct btrfs_node { 584 struct btrfs_header header; 585 struct btrfs_key_ptr ptrs[]; 586 } __attribute__ ((__packed__)); 587 588 struct btrfs_dev_item { 589 /* the internal btrfs device id */ 590 __le64 devid; 591 592 /* size of the device */ 593 __le64 total_bytes; 594 595 /* bytes used */ 596 __le64 bytes_used; 597 598 /* optimal io alignment for this device */ 599 __le32 io_align; 600 601 /* optimal io width for this device */ 602 __le32 io_width; 603 604 /* minimal io size for this device */ 605 __le32 sector_size; 606 607 /* type and info about this device */ 608 __le64 type; 609 610 /* expected generation for this device */ 611 __le64 generation; 612 613 /* 614 * starting byte of this partition on the device, 615 * to allow for stripe alignment in the future 616 */ 617 __le64 start_offset; 618 619 /* grouping information for allocation decisions */ 620 __le32 dev_group; 621 622 /* seek speed 0-100 where 100 is fastest */ 623 __u8 seek_speed; 624 625 /* bandwidth 0-100 where 100 is fastest */ 626 __u8 bandwidth; 627 628 /* btrfs generated uuid for this device */ 629 __u8 uuid[BTRFS_UUID_SIZE]; 630 631 /* uuid of FS who owns this device */ 632 __u8 fsid[BTRFS_UUID_SIZE]; 633 } __attribute__ ((__packed__)); 634 635 struct btrfs_stripe { 636 __le64 devid; 637 __le64 offset; 638 __u8 dev_uuid[BTRFS_UUID_SIZE]; 639 } __attribute__ ((__packed__)); 640 641 struct btrfs_chunk { 642 /* size of this chunk in bytes */ 643 __le64 length; 644 645 /* objectid of the root referencing this chunk */ 646 __le64 owner; 647 648 __le64 stripe_len; 649 __le64 type; 650 651 /* optimal io alignment for this chunk */ 652 __le32 io_align; 653 654 /* optimal io width for this chunk */ 655 __le32 io_width; 656 657 /* minimal io size for this chunk */ 658 __le32 sector_size; 659 660 /* 2^16 stripes is quite a lot, a second limit is the size of a single 661 * item in the btree 662 */ 663 __le16 num_stripes; 664 665 /* sub stripes only matter for raid10 */ 666 __le16 sub_stripes; 667 struct btrfs_stripe stripe; 668 /* additional stripes go here */ 669 } __attribute__ ((__packed__)); 670 671 /* 672 * The super block basically lists the main trees of the FS. 673 */ 674 struct btrfs_super_block { 675 /* The first 4 fields must match struct btrfs_header */ 676 __u8 csum[BTRFS_CSUM_SIZE]; 677 /* FS specific UUID, visible to user */ 678 __u8 fsid[BTRFS_FSID_SIZE]; 679 /* This block number */ 680 __le64 bytenr; 681 __le64 flags; 682 683 /* Allowed to be different from the btrfs_header from here own down */ 684 __le64 magic; 685 __le64 generation; 686 __le64 root; 687 __le64 chunk_root; 688 __le64 log_root; 689 690 /* 691 * This member has never been utilized since the very beginning, thus 692 * it's always 0 regardless of kernel version. We always use 693 * generation + 1 to read log tree root. So here we mark it deprecated. 694 */ 695 __le64 __unused_log_root_transid; 696 __le64 total_bytes; 697 __le64 bytes_used; 698 __le64 root_dir_objectid; 699 __le64 num_devices; 700 __le32 sectorsize; 701 __le32 nodesize; 702 __le32 __unused_leafsize; 703 __le32 stripesize; 704 __le32 sys_chunk_array_size; 705 __le64 chunk_root_generation; 706 __le64 compat_flags; 707 __le64 compat_ro_flags; 708 __le64 incompat_flags; 709 __le16 csum_type; 710 __u8 root_level; 711 __u8 chunk_root_level; 712 __u8 log_root_level; 713 struct btrfs_dev_item dev_item; 714 715 char label[BTRFS_LABEL_SIZE]; 716 717 __le64 cache_generation; 718 __le64 uuid_tree_generation; 719 720 /* The UUID written into btree blocks */ 721 __u8 metadata_uuid[BTRFS_FSID_SIZE]; 722 723 __u64 nr_global_roots; 724 __le64 remap_root; 725 __le64 remap_root_generation; 726 __u8 remap_root_level; 727 728 /* Future expansion */ 729 __u8 reserved[199]; 730 __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE]; 731 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS]; 732 733 /* Padded to 4096 bytes */ 734 __u8 padding[565]; 735 } __attribute__ ((__packed__)); 736 737 #define BTRFS_FREE_SPACE_EXTENT 1 738 #define BTRFS_FREE_SPACE_BITMAP 2 739 740 struct btrfs_free_space_entry { 741 __le64 offset; 742 __le64 bytes; 743 __u8 type; 744 } __attribute__ ((__packed__)); 745 746 struct btrfs_free_space_header { 747 struct btrfs_disk_key location; 748 __le64 generation; 749 __le64 num_entries; 750 __le64 num_bitmaps; 751 } __attribute__ ((__packed__)); 752 753 struct btrfs_raid_stride { 754 /* The id of device this raid extent lives on. */ 755 __le64 devid; 756 /* The physical location on disk. */ 757 __le64 physical; 758 } __attribute__ ((__packed__)); 759 760 struct btrfs_stripe_extent { 761 /* An array of raid strides this stripe is composed of. */ 762 __DECLARE_FLEX_ARRAY(struct btrfs_raid_stride, strides); 763 } __attribute__ ((__packed__)); 764 765 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0) 766 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1) 767 768 /* Super block flags */ 769 /* Errors detected */ 770 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2) 771 772 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) 773 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) 774 #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) 775 #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) 776 #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) 777 778 /* 779 * Those are temporaray flags utilized by btrfs-progs to do offline conversion. 780 * They are rejected by kernel. 781 * But still keep them all here to avoid conflicts. 782 */ 783 #define BTRFS_SUPER_FLAG_CHANGING_BG_TREE (1ULL << 38) 784 #define BTRFS_SUPER_FLAG_CHANGING_DATA_CSUM (1ULL << 39) 785 #define BTRFS_SUPER_FLAG_CHANGING_META_CSUM (1ULL << 40) 786 787 /* 788 * items in the extent btree are used to record the objectid of the 789 * owner of the block and the number of references 790 */ 791 792 struct btrfs_extent_item { 793 __le64 refs; 794 __le64 generation; 795 __le64 flags; 796 } __attribute__ ((__packed__)); 797 798 struct btrfs_extent_item_v0 { 799 __le32 refs; 800 } __attribute__ ((__packed__)); 801 802 803 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0) 804 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1) 805 806 /* following flags only apply to tree blocks */ 807 808 /* use full backrefs for extent pointers in the block */ 809 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) 810 811 #define BTRFS_BACKREF_REV_MAX 256 812 #define BTRFS_BACKREF_REV_SHIFT 56 813 #define BTRFS_BACKREF_REV_MASK (((u64)BTRFS_BACKREF_REV_MAX - 1) << \ 814 BTRFS_BACKREF_REV_SHIFT) 815 816 #define BTRFS_OLD_BACKREF_REV 0 817 #define BTRFS_MIXED_BACKREF_REV 1 818 819 /* 820 * this flag is only used internally by scrub and may be changed at any time 821 * it is only declared here to avoid collisions 822 */ 823 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48) 824 825 struct btrfs_tree_block_info { 826 struct btrfs_disk_key key; 827 __u8 level; 828 } __attribute__ ((__packed__)); 829 830 struct btrfs_extent_data_ref { 831 __le64 root; 832 __le64 objectid; 833 __le64 offset; 834 __le32 count; 835 } __attribute__ ((__packed__)); 836 837 struct btrfs_shared_data_ref { 838 __le32 count; 839 } __attribute__ ((__packed__)); 840 841 struct btrfs_extent_owner_ref { 842 __le64 root_id; 843 } __attribute__ ((__packed__)); 844 845 struct btrfs_extent_inline_ref { 846 __u8 type; 847 __le64 offset; 848 } __attribute__ ((__packed__)); 849 850 /* dev extents record free space on individual devices. The owner 851 * field points back to the chunk allocation mapping tree that allocated 852 * the extent. The chunk tree uuid field is a way to double check the owner 853 */ 854 struct btrfs_dev_extent { 855 __le64 chunk_tree; 856 __le64 chunk_objectid; 857 __le64 chunk_offset; 858 __le64 length; 859 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; 860 } __attribute__ ((__packed__)); 861 862 struct btrfs_inode_ref { 863 __le64 index; 864 __le16 name_len; 865 /* name goes here */ 866 } __attribute__ ((__packed__)); 867 868 struct btrfs_inode_extref { 869 __le64 parent_objectid; 870 __le64 index; 871 __le16 name_len; 872 __u8 name[]; 873 /* name goes here */ 874 } __attribute__ ((__packed__)); 875 876 struct btrfs_timespec { 877 __le64 sec; 878 __le32 nsec; 879 } __attribute__ ((__packed__)); 880 881 struct btrfs_inode_item { 882 /* nfs style generation number */ 883 __le64 generation; 884 /* transid that last touched this inode */ 885 __le64 transid; 886 __le64 size; 887 __le64 nbytes; 888 __le64 block_group; 889 __le32 nlink; 890 __le32 uid; 891 __le32 gid; 892 __le32 mode; 893 __le64 rdev; 894 __le64 flags; 895 896 /* modification sequence number for NFS */ 897 __le64 sequence; 898 899 /* 900 * a little future expansion, for more than this we can 901 * just grow the inode item and version it 902 */ 903 __le64 reserved[4]; 904 struct btrfs_timespec atime; 905 struct btrfs_timespec ctime; 906 struct btrfs_timespec mtime; 907 struct btrfs_timespec otime; 908 } __attribute__ ((__packed__)); 909 910 struct btrfs_dir_log_item { 911 __le64 end; 912 } __attribute__ ((__packed__)); 913 914 struct btrfs_dir_item { 915 struct btrfs_disk_key location; 916 __le64 transid; 917 __le16 data_len; 918 __le16 name_len; 919 __u8 type; 920 } __attribute__ ((__packed__)); 921 922 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0) 923 924 /* 925 * Internal in-memory flag that a subvolume has been marked for deletion but 926 * still visible as a directory 927 */ 928 #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48) 929 930 struct btrfs_root_item { 931 struct btrfs_inode_item inode; 932 __le64 generation; 933 __le64 root_dirid; 934 __le64 bytenr; 935 __le64 byte_limit; 936 __le64 bytes_used; 937 __le64 last_snapshot; 938 __le64 flags; 939 __le32 refs; 940 struct btrfs_disk_key drop_progress; 941 __u8 drop_level; 942 __u8 level; 943 944 /* 945 * The following fields appear after subvol_uuids+subvol_times 946 * were introduced. 947 */ 948 949 /* 950 * This generation number is used to test if the new fields are valid 951 * and up to date while reading the root item. Every time the root item 952 * is written out, the "generation" field is copied into this field. If 953 * anyone ever mounted the fs with an older kernel, we will have 954 * mismatching generation values here and thus must invalidate the 955 * new fields. See btrfs_update_root and btrfs_find_last_root for 956 * details. 957 * the offset of generation_v2 is also used as the start for the memset 958 * when invalidating the fields. 959 */ 960 __le64 generation_v2; 961 __u8 uuid[BTRFS_UUID_SIZE]; 962 __u8 parent_uuid[BTRFS_UUID_SIZE]; 963 __u8 received_uuid[BTRFS_UUID_SIZE]; 964 __le64 ctransid; /* updated when an inode changes */ 965 __le64 otransid; /* trans when created */ 966 __le64 stransid; /* trans when sent. non-zero for received subvol */ 967 __le64 rtransid; /* trans when received. non-zero for received subvol */ 968 struct btrfs_timespec ctime; 969 struct btrfs_timespec otime; 970 struct btrfs_timespec stime; 971 struct btrfs_timespec rtime; 972 __le64 reserved[8]; /* for future */ 973 } __attribute__ ((__packed__)); 974 975 /* 976 * Btrfs root item used to be smaller than current size. The old format ends 977 * at where member generation_v2 is. 978 */ 979 static inline __u32 btrfs_legacy_root_item_size(void) 980 { 981 return offsetof(struct btrfs_root_item, generation_v2); 982 } 983 984 /* 985 * this is used for both forward and backward root refs 986 */ 987 struct btrfs_root_ref { 988 __le64 dirid; 989 __le64 sequence; 990 __le16 name_len; 991 } __attribute__ ((__packed__)); 992 993 struct btrfs_disk_balance_args { 994 /* 995 * profiles to operate on, single is denoted by 996 * BTRFS_AVAIL_ALLOC_BIT_SINGLE 997 */ 998 __le64 profiles; 999 1000 /* 1001 * usage filter 1002 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N' 1003 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max 1004 */ 1005 union { 1006 __le64 usage; 1007 struct { 1008 __le32 usage_min; 1009 __le32 usage_max; 1010 }; 1011 }; 1012 1013 /* devid filter */ 1014 __le64 devid; 1015 1016 /* devid subset filter [pstart..pend) */ 1017 __le64 pstart; 1018 __le64 pend; 1019 1020 /* btrfs virtual address space subset filter [vstart..vend) */ 1021 __le64 vstart; 1022 __le64 vend; 1023 1024 /* 1025 * profile to convert to, single is denoted by 1026 * BTRFS_AVAIL_ALLOC_BIT_SINGLE 1027 */ 1028 __le64 target; 1029 1030 /* BTRFS_BALANCE_ARGS_* */ 1031 __le64 flags; 1032 1033 /* 1034 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit' 1035 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum 1036 * and maximum 1037 */ 1038 union { 1039 __le64 limit; 1040 struct { 1041 __le32 limit_min; 1042 __le32 limit_max; 1043 }; 1044 }; 1045 1046 /* 1047 * Process chunks that cross stripes_min..stripes_max devices, 1048 * BTRFS_BALANCE_ARGS_STRIPES_RANGE 1049 */ 1050 __le32 stripes_min; 1051 __le32 stripes_max; 1052 1053 __le64 unused[6]; 1054 } __attribute__ ((__packed__)); 1055 1056 /* 1057 * store balance parameters to disk so that balance can be properly 1058 * resumed after crash or unmount 1059 */ 1060 struct btrfs_balance_item { 1061 /* BTRFS_BALANCE_* */ 1062 __le64 flags; 1063 1064 struct btrfs_disk_balance_args data; 1065 struct btrfs_disk_balance_args meta; 1066 struct btrfs_disk_balance_args sys; 1067 1068 __le64 unused[4]; 1069 } __attribute__ ((__packed__)); 1070 1071 enum { 1072 BTRFS_FILE_EXTENT_INLINE = 0, 1073 BTRFS_FILE_EXTENT_REG = 1, 1074 BTRFS_FILE_EXTENT_PREALLOC = 2, 1075 BTRFS_NR_FILE_EXTENT_TYPES = 3, 1076 }; 1077 1078 struct btrfs_file_extent_item { 1079 /* 1080 * transaction id that created this extent 1081 */ 1082 __le64 generation; 1083 /* 1084 * max number of bytes to hold this extent in ram 1085 * when we split a compressed extent we can't know how big 1086 * each of the resulting pieces will be. So, this is 1087 * an upper limit on the size of the extent in ram instead of 1088 * an exact limit. 1089 */ 1090 __le64 ram_bytes; 1091 1092 /* 1093 * 32 bits for the various ways we might encode the data, 1094 * including compression and encryption. If any of these 1095 * are set to something a given disk format doesn't understand 1096 * it is treated like an incompat flag for reading and writing, 1097 * but not for stat. 1098 */ 1099 __u8 compression; 1100 __u8 encryption; 1101 __le16 other_encoding; /* spare for later use */ 1102 1103 /* are we inline data or a real extent? */ 1104 __u8 type; 1105 1106 /* 1107 * disk space consumed by the extent, checksum blocks are included 1108 * in these numbers 1109 * 1110 * At this offset in the structure, the inline extent data start. 1111 */ 1112 __le64 disk_bytenr; 1113 __le64 disk_num_bytes; 1114 /* 1115 * the logical offset in file blocks (no csums) 1116 * this extent record is for. This allows a file extent to point 1117 * into the middle of an existing extent on disk, sharing it 1118 * between two snapshots (useful if some bytes in the middle of the 1119 * extent have changed 1120 */ 1121 __le64 offset; 1122 /* 1123 * the logical number of file blocks (no csums included). This 1124 * always reflects the size uncompressed and without encoding. 1125 */ 1126 __le64 num_bytes; 1127 1128 } __attribute__ ((__packed__)); 1129 1130 struct btrfs_csum_item { 1131 __u8 csum; 1132 } __attribute__ ((__packed__)); 1133 1134 struct btrfs_dev_stats_item { 1135 /* 1136 * grow this item struct at the end for future enhancements and keep 1137 * the existing values unchanged 1138 */ 1139 __le64 values[BTRFS_DEV_STAT_VALUES_MAX]; 1140 } __attribute__ ((__packed__)); 1141 1142 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 1143 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 1144 1145 struct btrfs_dev_replace_item { 1146 /* 1147 * grow this item struct at the end for future enhancements and keep 1148 * the existing values unchanged 1149 */ 1150 __le64 src_devid; 1151 __le64 cursor_left; 1152 __le64 cursor_right; 1153 __le64 cont_reading_from_srcdev_mode; 1154 1155 __le64 replace_state; 1156 __le64 time_started; 1157 __le64 time_stopped; 1158 __le64 num_write_errors; 1159 __le64 num_uncorrectable_read_errors; 1160 } __attribute__ ((__packed__)); 1161 1162 /* different types of block groups (and chunks) */ 1163 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) 1164 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) 1165 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2) 1166 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3) 1167 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) 1168 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) 1169 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) 1170 #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) 1171 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) 1172 #define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9) 1173 #define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10) 1174 #define BTRFS_BLOCK_GROUP_REMAPPED (1ULL << 11) 1175 #define BTRFS_BLOCK_GROUP_METADATA_REMAP (1ULL << 12) 1176 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \ 1177 BTRFS_SPACE_INFO_GLOBAL_RSV) 1178 1179 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \ 1180 BTRFS_BLOCK_GROUP_SYSTEM | \ 1181 BTRFS_BLOCK_GROUP_METADATA | \ 1182 BTRFS_BLOCK_GROUP_METADATA_REMAP) 1183 1184 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \ 1185 BTRFS_BLOCK_GROUP_RAID1 | \ 1186 BTRFS_BLOCK_GROUP_RAID1C3 | \ 1187 BTRFS_BLOCK_GROUP_RAID1C4 | \ 1188 BTRFS_BLOCK_GROUP_RAID5 | \ 1189 BTRFS_BLOCK_GROUP_RAID6 | \ 1190 BTRFS_BLOCK_GROUP_DUP | \ 1191 BTRFS_BLOCK_GROUP_RAID10) 1192 #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \ 1193 BTRFS_BLOCK_GROUP_RAID6) 1194 1195 #define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | \ 1196 BTRFS_BLOCK_GROUP_RAID1C3 | \ 1197 BTRFS_BLOCK_GROUP_RAID1C4) 1198 1199 /* 1200 * We need a bit for restriper to be able to tell when chunks of type 1201 * SINGLE are available. This "extended" profile format is used in 1202 * fs_info->avail_*_alloc_bits (in-memory) and balance item fields 1203 * (on-disk). The corresponding on-disk bit in chunk.type is reserved 1204 * to avoid remappings between two formats in future. 1205 */ 1206 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) 1207 1208 /* 1209 * A fake block group type that is used to communicate global block reserve 1210 * size to userspace via the SPACE_INFO ioctl. 1211 */ 1212 #define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49) 1213 1214 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \ 1215 BTRFS_AVAIL_ALLOC_BIT_SINGLE) 1216 1217 static inline __u64 chunk_to_extended(__u64 flags) 1218 { 1219 if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0) 1220 flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; 1221 1222 return flags; 1223 } 1224 static inline __u64 extended_to_chunk(__u64 flags) 1225 { 1226 return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; 1227 } 1228 1229 struct btrfs_block_group_item { 1230 __le64 used; 1231 __le64 chunk_objectid; 1232 __le64 flags; 1233 } __attribute__ ((__packed__)); 1234 1235 struct btrfs_block_group_item_v2 { 1236 __le64 used; 1237 __le64 chunk_objectid; 1238 __le64 flags; 1239 __le64 remap_bytes; 1240 __le32 identity_remap_count; 1241 } __attribute__ ((__packed__)); 1242 1243 struct btrfs_free_space_info { 1244 __le32 extent_count; 1245 __le32 flags; 1246 } __attribute__ ((__packed__)); 1247 1248 #define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0) 1249 1250 #define BTRFS_QGROUP_LEVEL_SHIFT 48 1251 static inline __u16 btrfs_qgroup_level(__u64 qgroupid) 1252 { 1253 return (__u16)(qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT); 1254 } 1255 1256 /* 1257 * is subvolume quota turned on? 1258 */ 1259 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0) 1260 /* 1261 * RESCAN is set during the initialization phase 1262 */ 1263 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1) 1264 /* 1265 * Some qgroup entries are known to be out of date, 1266 * either because the configuration has changed in a way that 1267 * makes a rescan necessary, or because the fs has been mounted 1268 * with a non-qgroup-aware version. 1269 * Turning qouta off and on again makes it inconsistent, too. 1270 */ 1271 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2) 1272 1273 /* 1274 * Whether or not this filesystem is using simple quotas. Not exactly the 1275 * incompat bit, because we support using simple quotas, disabling it, then 1276 * going back to full qgroup quotas. 1277 */ 1278 #define BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE (1ULL << 3) 1279 1280 #define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | \ 1281 BTRFS_QGROUP_STATUS_FLAG_RESCAN | \ 1282 BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT | \ 1283 BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE) 1284 1285 #define BTRFS_QGROUP_STATUS_VERSION 1 1286 1287 struct btrfs_qgroup_status_item { 1288 __le64 version; 1289 /* 1290 * the generation is updated during every commit. As older 1291 * versions of btrfs are not aware of qgroups, it will be 1292 * possible to detect inconsistencies by checking the 1293 * generation on mount time 1294 */ 1295 __le64 generation; 1296 1297 /* flag definitions see above */ 1298 __le64 flags; 1299 1300 /* 1301 * only used during scanning to record the progress 1302 * of the scan. It contains a logical address 1303 */ 1304 __le64 rescan; 1305 1306 /* 1307 * The generation when quotas were last enabled. Used by simple quotas to 1308 * avoid decrementing when freeing an extent that was written before 1309 * enable. 1310 * 1311 * Set only if flags contain BTRFS_QGROUP_STATUS_FLAG_SIMPLE_MODE. 1312 */ 1313 __le64 enable_gen; 1314 } __attribute__ ((__packed__)); 1315 1316 struct btrfs_qgroup_info_item { 1317 __le64 generation; 1318 __le64 rfer; 1319 __le64 rfer_cmpr; 1320 __le64 excl; 1321 __le64 excl_cmpr; 1322 } __attribute__ ((__packed__)); 1323 1324 struct btrfs_qgroup_limit_item { 1325 /* 1326 * only updated when any of the other values change 1327 */ 1328 __le64 flags; 1329 __le64 max_rfer; 1330 __le64 max_excl; 1331 __le64 rsv_rfer; 1332 __le64 rsv_excl; 1333 } __attribute__ ((__packed__)); 1334 1335 struct btrfs_verity_descriptor_item { 1336 /* Size of the verity descriptor in bytes */ 1337 __le64 size; 1338 /* 1339 * When we implement support for fscrypt, we will need to encrypt the 1340 * Merkle tree for encrypted verity files. These 128 bits are for the 1341 * eventual storage of an fscrypt initialization vector. 1342 */ 1343 __le64 reserved[2]; 1344 __u8 encryption; 1345 } __attribute__ ((__packed__)); 1346 1347 /* 1348 * For a range identified by a BTRFS_REMAP_KEY item in the remap tree, gives 1349 * the address that the start of the range will get remapped to. This 1350 * structure is also shared by BTRFS_REMAP_BACKREF_KEY. 1351 */ 1352 struct btrfs_remap_item { 1353 __le64 address; 1354 } __attribute__ ((__packed__)); 1355 1356 #endif /* _BTRFS_CTREE_H_ */ 1357