The C and C++ Include Header Files
/usr/include/linux/btrfs_tree.h
$ cat -n /usr/include/linux/btrfs_tree.h 1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 #ifndef _BTRFS_CTREE_H_ 3 #define _BTRFS_CTREE_H_ 4 5 #include
6 #include
7 #include
8 9 /* 10 * This header contains the structure definitions and constants used 11 * by file system objects that can be retrieved using 12 * the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that 13 * is needed to describe a leaf node's key or item contents. 14 */ 15 16 /* holds pointers to all of the tree roots */ 17 #define BTRFS_ROOT_TREE_OBJECTID 1ULL 18 19 /* stores information about which extents are in use, and reference counts */ 20 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL 21 22 /* 23 * chunk tree stores translations from logical -> physical block numbering 24 * the super block points to the chunk tree 25 */ 26 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL 27 28 /* 29 * stores information about which areas of a given device are in use. 30 * one per device. The tree of tree roots points to the device tree 31 */ 32 #define BTRFS_DEV_TREE_OBJECTID 4ULL 33 34 /* one per subvolume, storing files and directories */ 35 #define BTRFS_FS_TREE_OBJECTID 5ULL 36 37 /* directory objectid inside the root tree */ 38 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL 39 40 /* holds checksums of all the data extents */ 41 #define BTRFS_CSUM_TREE_OBJECTID 7ULL 42 43 /* holds quota configuration and tracking */ 44 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL 45 46 /* for storing items that use the BTRFS_UUID_KEY* types */ 47 #define BTRFS_UUID_TREE_OBJECTID 9ULL 48 49 /* tracks free space in block groups. */ 50 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL 51 52 /* device stats in the device tree */ 53 #define BTRFS_DEV_STATS_OBJECTID 0ULL 54 55 /* for storing balance parameters in the root tree */ 56 #define BTRFS_BALANCE_OBJECTID -4ULL 57 58 /* orphan objectid for tracking unlinked/truncated files */ 59 #define BTRFS_ORPHAN_OBJECTID -5ULL 60 61 /* does write ahead logging to speed up fsyncs */ 62 #define BTRFS_TREE_LOG_OBJECTID -6ULL 63 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL 64 65 /* for space balancing */ 66 #define BTRFS_TREE_RELOC_OBJECTID -8ULL 67 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL 68 69 /* 70 * extent checksums all have this objectid 71 * this allows them to share the logging tree 72 * for fsyncs 73 */ 74 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL 75 76 /* For storing free space cache */ 77 #define BTRFS_FREE_SPACE_OBJECTID -11ULL 78 79 /* 80 * The inode number assigned to the special inode for storing 81 * free ino cache 82 */ 83 #define BTRFS_FREE_INO_OBJECTID -12ULL 84 85 /* dummy objectid represents multiple objectids */ 86 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL 87 88 /* 89 * All files have objectids in this range. 90 */ 91 #define BTRFS_FIRST_FREE_OBJECTID 256ULL 92 #define BTRFS_LAST_FREE_OBJECTID -256ULL 93 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL 94 95 96 /* 97 * the device items go into the chunk tree. The key is in the form 98 * [ 1 BTRFS_DEV_ITEM_KEY device_id ] 99 */ 100 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL 101 102 #define BTRFS_BTREE_INODE_OBJECTID 1 103 104 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2 105 106 #define BTRFS_DEV_REPLACE_DEVID 0ULL 107 108 /* 109 * inode items have the data typically returned from stat and store other 110 * info about object characteristics. There is one for every file and dir in 111 * the FS 112 */ 113 #define BTRFS_INODE_ITEM_KEY 1 114 #define BTRFS_INODE_REF_KEY 12 115 #define BTRFS_INODE_EXTREF_KEY 13 116 #define BTRFS_XATTR_ITEM_KEY 24 117 118 /* 119 * fs verity items are stored under two different key types on disk. 120 * The descriptor items: 121 * [ inode objectid, BTRFS_VERITY_DESC_ITEM_KEY, offset ] 122 * 123 * At offset 0, we store a btrfs_verity_descriptor_item which tracks the size 124 * of the descriptor item and some extra data for encryption. 125 * Starting at offset 1, these hold the generic fs verity descriptor. The 126 * latter are opaque to btrfs, we just read and write them as a blob for the 127 * higher level verity code. The most common descriptor size is 256 bytes. 128 * 129 * The merkle tree items: 130 * [ inode objectid, BTRFS_VERITY_MERKLE_ITEM_KEY, offset ] 131 * 132 * These also start at offset 0, and correspond to the merkle tree bytes. When 133 * fsverity asks for page 0 of the merkle tree, we pull up one page starting at 134 * offset 0 for this key type. These are also opaque to btrfs, we're blindly 135 * storing whatever fsverity sends down. 136 */ 137 #define BTRFS_VERITY_DESC_ITEM_KEY 36 138 #define BTRFS_VERITY_MERKLE_ITEM_KEY 37 139 140 #define BTRFS_ORPHAN_ITEM_KEY 48 141 /* reserve 2-15 close to the inode for later flexibility */ 142 143 /* 144 * dir items are the name -> inode pointers in a directory. There is one 145 * for every name in a directory. BTRFS_DIR_LOG_ITEM_KEY is no longer used 146 * but it's still defined here for documentation purposes and to help avoid 147 * having its numerical value reused in the future. 148 */ 149 #define BTRFS_DIR_LOG_ITEM_KEY 60 150 #define BTRFS_DIR_LOG_INDEX_KEY 72 151 #define BTRFS_DIR_ITEM_KEY 84 152 #define BTRFS_DIR_INDEX_KEY 96 153 /* 154 * extent data is for file data 155 */ 156 #define BTRFS_EXTENT_DATA_KEY 108 157 158 /* 159 * extent csums are stored in a separate tree and hold csums for 160 * an entire extent on disk. 161 */ 162 #define BTRFS_EXTENT_CSUM_KEY 128 163 164 /* 165 * root items point to tree roots. They are typically in the root 166 * tree used by the super block to find all the other trees 167 */ 168 #define BTRFS_ROOT_ITEM_KEY 132 169 170 /* 171 * root backrefs tie subvols and snapshots to the directory entries that 172 * reference them 173 */ 174 #define BTRFS_ROOT_BACKREF_KEY 144 175 176 /* 177 * root refs make a fast index for listing all of the snapshots and 178 * subvolumes referenced by a given root. They point directly to the 179 * directory item in the root that references the subvol 180 */ 181 #define BTRFS_ROOT_REF_KEY 156 182 183 /* 184 * extent items are in the extent map tree. These record which blocks 185 * are used, and how many references there are to each block 186 */ 187 #define BTRFS_EXTENT_ITEM_KEY 168 188 189 /* 190 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know 191 * the length, so we save the level in key->offset instead of the length. 192 */ 193 #define BTRFS_METADATA_ITEM_KEY 169 194 195 #define BTRFS_TREE_BLOCK_REF_KEY 176 196 197 #define BTRFS_EXTENT_DATA_REF_KEY 178 198 199 #define BTRFS_EXTENT_REF_V0_KEY 180 200 201 #define BTRFS_SHARED_BLOCK_REF_KEY 182 202 203 #define BTRFS_SHARED_DATA_REF_KEY 184 204 205 /* 206 * block groups give us hints into the extent allocation trees. Which 207 * blocks are free etc etc 208 */ 209 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192 210 211 /* 212 * Every block group is represented in the free space tree by a free space info 213 * item, which stores some accounting information. It is keyed on 214 * (block_group_start, FREE_SPACE_INFO, block_group_length). 215 */ 216 #define BTRFS_FREE_SPACE_INFO_KEY 198 217 218 /* 219 * A free space extent tracks an extent of space that is free in a block group. 220 * It is keyed on (start, FREE_SPACE_EXTENT, length). 221 */ 222 #define BTRFS_FREE_SPACE_EXTENT_KEY 199 223 224 /* 225 * When a block group becomes very fragmented, we convert it to use bitmaps 226 * instead of extents. A free space bitmap is keyed on 227 * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with 228 * (length / sectorsize) bits. 229 */ 230 #define BTRFS_FREE_SPACE_BITMAP_KEY 200 231 232 #define BTRFS_DEV_EXTENT_KEY 204 233 #define BTRFS_DEV_ITEM_KEY 216 234 #define BTRFS_CHUNK_ITEM_KEY 228 235 236 /* 237 * Records the overall state of the qgroups. 238 * There's only one instance of this key present, 239 * (0, BTRFS_QGROUP_STATUS_KEY, 0) 240 */ 241 #define BTRFS_QGROUP_STATUS_KEY 240 242 /* 243 * Records the currently used space of the qgroup. 244 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid). 245 */ 246 #define BTRFS_QGROUP_INFO_KEY 242 247 /* 248 * Contains the user configured limits for the qgroup. 249 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid). 250 */ 251 #define BTRFS_QGROUP_LIMIT_KEY 244 252 /* 253 * Records the child-parent relationship of qgroups. For 254 * each relation, 2 keys are present: 255 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid) 256 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid) 257 */ 258 #define BTRFS_QGROUP_RELATION_KEY 246 259 260 /* 261 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY. 262 */ 263 #define BTRFS_BALANCE_ITEM_KEY 248 264 265 /* 266 * The key type for tree items that are stored persistently, but do not need to 267 * exist for extended period of time. The items can exist in any tree. 268 * 269 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data] 270 * 271 * Existing items: 272 * 273 * - balance status item 274 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0) 275 */ 276 #define BTRFS_TEMPORARY_ITEM_KEY 248 277 278 /* 279 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY 280 */ 281 #define BTRFS_DEV_STATS_KEY 249 282 283 /* 284 * The key type for tree items that are stored persistently and usually exist 285 * for a long period, eg. filesystem lifetime. The item kinds can be status 286 * information, stats or preference values. The item can exist in any tree. 287 * 288 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data] 289 * 290 * Existing items: 291 * 292 * - device statistics, store IO stats in the device tree, one key for all 293 * stats 294 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0) 295 */ 296 #define BTRFS_PERSISTENT_ITEM_KEY 249 297 298 /* 299 * Persistently stores the device replace state in the device tree. 300 * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0). 301 */ 302 #define BTRFS_DEV_REPLACE_KEY 250 303 304 /* 305 * Stores items that allow to quickly map UUIDs to something else. 306 * These items are part of the filesystem UUID tree. 307 * The key is built like this: 308 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits). 309 */ 310 #if BTRFS_UUID_SIZE != 16 311 #error "UUID items require BTRFS_UUID_SIZE == 16!" 312 #endif 313 #define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */ 314 #define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to 315 * received subvols */ 316 317 /* 318 * string items are for debugging. They just store a short string of 319 * data in the FS 320 */ 321 #define BTRFS_STRING_ITEM_KEY 253 322 323 /* Maximum metadata block size (nodesize) */ 324 #define BTRFS_MAX_METADATA_BLOCKSIZE 65536 325 326 /* 32 bytes in various csum fields */ 327 #define BTRFS_CSUM_SIZE 32 328 329 /* csum types */ 330 enum btrfs_csum_type { 331 BTRFS_CSUM_TYPE_CRC32 = 0, 332 BTRFS_CSUM_TYPE_XXHASH = 1, 333 BTRFS_CSUM_TYPE_SHA256 = 2, 334 BTRFS_CSUM_TYPE_BLAKE2 = 3, 335 }; 336 337 /* 338 * flags definitions for directory entry item type 339 * 340 * Used by: 341 * struct btrfs_dir_item.type 342 * 343 * Values 0..7 must match common file type values in fs_types.h. 344 */ 345 #define BTRFS_FT_UNKNOWN 0 346 #define BTRFS_FT_REG_FILE 1 347 #define BTRFS_FT_DIR 2 348 #define BTRFS_FT_CHRDEV 3 349 #define BTRFS_FT_BLKDEV 4 350 #define BTRFS_FT_FIFO 5 351 #define BTRFS_FT_SOCK 6 352 #define BTRFS_FT_SYMLINK 7 353 #define BTRFS_FT_XATTR 8 354 #define BTRFS_FT_MAX 9 355 356 /* 357 * The key defines the order in the tree, and so it also defines (optimal) 358 * block layout. 359 * 360 * objectid corresponds to the inode number. 361 * 362 * type tells us things about the object, and is a kind of stream selector. 363 * so for a given inode, keys with type of 1 might refer to the inode data, 364 * type of 2 may point to file data in the btree and type == 3 may point to 365 * extents. 366 * 367 * offset is the starting byte offset for this key in the stream. 368 * 369 * btrfs_disk_key is in disk byte order. struct btrfs_key is always 370 * in cpu native order. Otherwise they are identical and their sizes 371 * should be the same (ie both packed) 372 */ 373 struct btrfs_disk_key { 374 __le64 objectid; 375 __u8 type; 376 __le64 offset; 377 } __attribute__ ((__packed__)); 378 379 struct btrfs_key { 380 __u64 objectid; 381 __u8 type; 382 __u64 offset; 383 } __attribute__ ((__packed__)); 384 385 struct btrfs_dev_item { 386 /* the internal btrfs device id */ 387 __le64 devid; 388 389 /* size of the device */ 390 __le64 total_bytes; 391 392 /* bytes used */ 393 __le64 bytes_used; 394 395 /* optimal io alignment for this device */ 396 __le32 io_align; 397 398 /* optimal io width for this device */ 399 __le32 io_width; 400 401 /* minimal io size for this device */ 402 __le32 sector_size; 403 404 /* type and info about this device */ 405 __le64 type; 406 407 /* expected generation for this device */ 408 __le64 generation; 409 410 /* 411 * starting byte of this partition on the device, 412 * to allow for stripe alignment in the future 413 */ 414 __le64 start_offset; 415 416 /* grouping information for allocation decisions */ 417 __le32 dev_group; 418 419 /* seek speed 0-100 where 100 is fastest */ 420 __u8 seek_speed; 421 422 /* bandwidth 0-100 where 100 is fastest */ 423 __u8 bandwidth; 424 425 /* btrfs generated uuid for this device */ 426 __u8 uuid[BTRFS_UUID_SIZE]; 427 428 /* uuid of FS who owns this device */ 429 __u8 fsid[BTRFS_UUID_SIZE]; 430 } __attribute__ ((__packed__)); 431 432 struct btrfs_stripe { 433 __le64 devid; 434 __le64 offset; 435 __u8 dev_uuid[BTRFS_UUID_SIZE]; 436 } __attribute__ ((__packed__)); 437 438 struct btrfs_chunk { 439 /* size of this chunk in bytes */ 440 __le64 length; 441 442 /* objectid of the root referencing this chunk */ 443 __le64 owner; 444 445 __le64 stripe_len; 446 __le64 type; 447 448 /* optimal io alignment for this chunk */ 449 __le32 io_align; 450 451 /* optimal io width for this chunk */ 452 __le32 io_width; 453 454 /* minimal io size for this chunk */ 455 __le32 sector_size; 456 457 /* 2^16 stripes is quite a lot, a second limit is the size of a single 458 * item in the btree 459 */ 460 __le16 num_stripes; 461 462 /* sub stripes only matter for raid10 */ 463 __le16 sub_stripes; 464 struct btrfs_stripe stripe; 465 /* additional stripes go here */ 466 } __attribute__ ((__packed__)); 467 468 #define BTRFS_FREE_SPACE_EXTENT 1 469 #define BTRFS_FREE_SPACE_BITMAP 2 470 471 struct btrfs_free_space_entry { 472 __le64 offset; 473 __le64 bytes; 474 __u8 type; 475 } __attribute__ ((__packed__)); 476 477 struct btrfs_free_space_header { 478 struct btrfs_disk_key location; 479 __le64 generation; 480 __le64 num_entries; 481 __le64 num_bitmaps; 482 } __attribute__ ((__packed__)); 483 484 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0) 485 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1) 486 487 /* Super block flags */ 488 /* Errors detected */ 489 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2) 490 491 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32) 492 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33) 493 #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34) 494 #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35) 495 #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36) 496 497 498 /* 499 * items in the extent btree are used to record the objectid of the 500 * owner of the block and the number of references 501 */ 502 503 struct btrfs_extent_item { 504 __le64 refs; 505 __le64 generation; 506 __le64 flags; 507 } __attribute__ ((__packed__)); 508 509 struct btrfs_extent_item_v0 { 510 __le32 refs; 511 } __attribute__ ((__packed__)); 512 513 514 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0) 515 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1) 516 517 /* following flags only apply to tree blocks */ 518 519 /* use full backrefs for extent pointers in the block */ 520 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8) 521 522 /* 523 * this flag is only used internally by scrub and may be changed at any time 524 * it is only declared here to avoid collisions 525 */ 526 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48) 527 528 struct btrfs_tree_block_info { 529 struct btrfs_disk_key key; 530 __u8 level; 531 } __attribute__ ((__packed__)); 532 533 struct btrfs_extent_data_ref { 534 __le64 root; 535 __le64 objectid; 536 __le64 offset; 537 __le32 count; 538 } __attribute__ ((__packed__)); 539 540 struct btrfs_shared_data_ref { 541 __le32 count; 542 } __attribute__ ((__packed__)); 543 544 struct btrfs_extent_inline_ref { 545 __u8 type; 546 __le64 offset; 547 } __attribute__ ((__packed__)); 548 549 /* dev extents record free space on individual devices. The owner 550 * field points back to the chunk allocation mapping tree that allocated 551 * the extent. The chunk tree uuid field is a way to double check the owner 552 */ 553 struct btrfs_dev_extent { 554 __le64 chunk_tree; 555 __le64 chunk_objectid; 556 __le64 chunk_offset; 557 __le64 length; 558 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE]; 559 } __attribute__ ((__packed__)); 560 561 struct btrfs_inode_ref { 562 __le64 index; 563 __le16 name_len; 564 /* name goes here */ 565 } __attribute__ ((__packed__)); 566 567 struct btrfs_inode_extref { 568 __le64 parent_objectid; 569 __le64 index; 570 __le16 name_len; 571 __u8 name[0]; 572 /* name goes here */ 573 } __attribute__ ((__packed__)); 574 575 struct btrfs_timespec { 576 __le64 sec; 577 __le32 nsec; 578 } __attribute__ ((__packed__)); 579 580 struct btrfs_inode_item { 581 /* nfs style generation number */ 582 __le64 generation; 583 /* transid that last touched this inode */ 584 __le64 transid; 585 __le64 size; 586 __le64 nbytes; 587 __le64 block_group; 588 __le32 nlink; 589 __le32 uid; 590 __le32 gid; 591 __le32 mode; 592 __le64 rdev; 593 __le64 flags; 594 595 /* modification sequence number for NFS */ 596 __le64 sequence; 597 598 /* 599 * a little future expansion, for more than this we can 600 * just grow the inode item and version it 601 */ 602 __le64 reserved[4]; 603 struct btrfs_timespec atime; 604 struct btrfs_timespec ctime; 605 struct btrfs_timespec mtime; 606 struct btrfs_timespec otime; 607 } __attribute__ ((__packed__)); 608 609 struct btrfs_dir_log_item { 610 __le64 end; 611 } __attribute__ ((__packed__)); 612 613 struct btrfs_dir_item { 614 struct btrfs_disk_key location; 615 __le64 transid; 616 __le16 data_len; 617 __le16 name_len; 618 __u8 type; 619 } __attribute__ ((__packed__)); 620 621 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0) 622 623 /* 624 * Internal in-memory flag that a subvolume has been marked for deletion but 625 * still visible as a directory 626 */ 627 #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48) 628 629 struct btrfs_root_item { 630 struct btrfs_inode_item inode; 631 __le64 generation; 632 __le64 root_dirid; 633 __le64 bytenr; 634 __le64 byte_limit; 635 __le64 bytes_used; 636 __le64 last_snapshot; 637 __le64 flags; 638 __le32 refs; 639 struct btrfs_disk_key drop_progress; 640 __u8 drop_level; 641 __u8 level; 642 643 /* 644 * The following fields appear after subvol_uuids+subvol_times 645 * were introduced. 646 */ 647 648 /* 649 * This generation number is used to test if the new fields are valid 650 * and up to date while reading the root item. Every time the root item 651 * is written out, the "generation" field is copied into this field. If 652 * anyone ever mounted the fs with an older kernel, we will have 653 * mismatching generation values here and thus must invalidate the 654 * new fields. See btrfs_update_root and btrfs_find_last_root for 655 * details. 656 * the offset of generation_v2 is also used as the start for the memset 657 * when invalidating the fields. 658 */ 659 __le64 generation_v2; 660 __u8 uuid[BTRFS_UUID_SIZE]; 661 __u8 parent_uuid[BTRFS_UUID_SIZE]; 662 __u8 received_uuid[BTRFS_UUID_SIZE]; 663 __le64 ctransid; /* updated when an inode changes */ 664 __le64 otransid; /* trans when created */ 665 __le64 stransid; /* trans when sent. non-zero for received subvol */ 666 __le64 rtransid; /* trans when received. non-zero for received subvol */ 667 struct btrfs_timespec ctime; 668 struct btrfs_timespec otime; 669 struct btrfs_timespec stime; 670 struct btrfs_timespec rtime; 671 __le64 reserved[8]; /* for future */ 672 } __attribute__ ((__packed__)); 673 674 /* 675 * Btrfs root item used to be smaller than current size. The old format ends 676 * at where member generation_v2 is. 677 */ 678 static __inline__ __u32 btrfs_legacy_root_item_size(void) 679 { 680 return offsetof(struct btrfs_root_item, generation_v2); 681 } 682 683 /* 684 * this is used for both forward and backward root refs 685 */ 686 struct btrfs_root_ref { 687 __le64 dirid; 688 __le64 sequence; 689 __le16 name_len; 690 } __attribute__ ((__packed__)); 691 692 struct btrfs_disk_balance_args { 693 /* 694 * profiles to operate on, single is denoted by 695 * BTRFS_AVAIL_ALLOC_BIT_SINGLE 696 */ 697 __le64 profiles; 698 699 /* 700 * usage filter 701 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N' 702 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max 703 */ 704 union { 705 __le64 usage; 706 struct { 707 __le32 usage_min; 708 __le32 usage_max; 709 }; 710 }; 711 712 /* devid filter */ 713 __le64 devid; 714 715 /* devid subset filter [pstart..pend) */ 716 __le64 pstart; 717 __le64 pend; 718 719 /* btrfs virtual address space subset filter [vstart..vend) */ 720 __le64 vstart; 721 __le64 vend; 722 723 /* 724 * profile to convert to, single is denoted by 725 * BTRFS_AVAIL_ALLOC_BIT_SINGLE 726 */ 727 __le64 target; 728 729 /* BTRFS_BALANCE_ARGS_* */ 730 __le64 flags; 731 732 /* 733 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit' 734 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum 735 * and maximum 736 */ 737 union { 738 __le64 limit; 739 struct { 740 __le32 limit_min; 741 __le32 limit_max; 742 }; 743 }; 744 745 /* 746 * Process chunks that cross stripes_min..stripes_max devices, 747 * BTRFS_BALANCE_ARGS_STRIPES_RANGE 748 */ 749 __le32 stripes_min; 750 __le32 stripes_max; 751 752 __le64 unused[6]; 753 } __attribute__ ((__packed__)); 754 755 /* 756 * store balance parameters to disk so that balance can be properly 757 * resumed after crash or unmount 758 */ 759 struct btrfs_balance_item { 760 /* BTRFS_BALANCE_* */ 761 __le64 flags; 762 763 struct btrfs_disk_balance_args data; 764 struct btrfs_disk_balance_args meta; 765 struct btrfs_disk_balance_args sys; 766 767 __le64 unused[4]; 768 } __attribute__ ((__packed__)); 769 770 enum { 771 BTRFS_FILE_EXTENT_INLINE = 0, 772 BTRFS_FILE_EXTENT_REG = 1, 773 BTRFS_FILE_EXTENT_PREALLOC = 2, 774 BTRFS_NR_FILE_EXTENT_TYPES = 3, 775 }; 776 777 struct btrfs_file_extent_item { 778 /* 779 * transaction id that created this extent 780 */ 781 __le64 generation; 782 /* 783 * max number of bytes to hold this extent in ram 784 * when we split a compressed extent we can't know how big 785 * each of the resulting pieces will be. So, this is 786 * an upper limit on the size of the extent in ram instead of 787 * an exact limit. 788 */ 789 __le64 ram_bytes; 790 791 /* 792 * 32 bits for the various ways we might encode the data, 793 * including compression and encryption. If any of these 794 * are set to something a given disk format doesn't understand 795 * it is treated like an incompat flag for reading and writing, 796 * but not for stat. 797 */ 798 __u8 compression; 799 __u8 encryption; 800 __le16 other_encoding; /* spare for later use */ 801 802 /* are we __inline__ data or a real extent? */ 803 __u8 type; 804 805 /* 806 * disk space consumed by the extent, checksum blocks are included 807 * in these numbers 808 * 809 * At this offset in the structure, the __inline__ extent data start. 810 */ 811 __le64 disk_bytenr; 812 __le64 disk_num_bytes; 813 /* 814 * the logical offset in file blocks (no csums) 815 * this extent record is for. This allows a file extent to point 816 * into the middle of an existing extent on disk, sharing it 817 * between two snapshots (useful if some bytes in the middle of the 818 * extent have changed 819 */ 820 __le64 offset; 821 /* 822 * the logical number of file blocks (no csums included). This 823 * always reflects the size uncompressed and without encoding. 824 */ 825 __le64 num_bytes; 826 827 } __attribute__ ((__packed__)); 828 829 struct btrfs_csum_item { 830 __u8 csum; 831 } __attribute__ ((__packed__)); 832 833 struct btrfs_dev_stats_item { 834 /* 835 * grow this item struct at the end for future enhancements and keep 836 * the existing values unchanged 837 */ 838 __le64 values[BTRFS_DEV_STAT_VALUES_MAX]; 839 } __attribute__ ((__packed__)); 840 841 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 842 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 843 844 struct btrfs_dev_replace_item { 845 /* 846 * grow this item struct at the end for future enhancements and keep 847 * the existing values unchanged 848 */ 849 __le64 src_devid; 850 __le64 cursor_left; 851 __le64 cursor_right; 852 __le64 cont_reading_from_srcdev_mode; 853 854 __le64 replace_state; 855 __le64 time_started; 856 __le64 time_stopped; 857 __le64 num_write_errors; 858 __le64 num_uncorrectable_read_errors; 859 } __attribute__ ((__packed__)); 860 861 /* different types of block groups (and chunks) */ 862 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0) 863 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1) 864 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2) 865 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3) 866 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4) 867 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5) 868 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6) 869 #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7) 870 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8) 871 #define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9) 872 #define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10) 873 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \ 874 BTRFS_SPACE_INFO_GLOBAL_RSV) 875 876 enum btrfs_raid_types { 877 BTRFS_RAID_RAID10, 878 BTRFS_RAID_RAID1, 879 BTRFS_RAID_DUP, 880 BTRFS_RAID_RAID0, 881 BTRFS_RAID_SINGLE, 882 BTRFS_RAID_RAID5, 883 BTRFS_RAID_RAID6, 884 BTRFS_RAID_RAID1C3, 885 BTRFS_RAID_RAID1C4, 886 BTRFS_NR_RAID_TYPES 887 }; 888 889 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \ 890 BTRFS_BLOCK_GROUP_SYSTEM | \ 891 BTRFS_BLOCK_GROUP_METADATA) 892 893 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \ 894 BTRFS_BLOCK_GROUP_RAID1 | \ 895 BTRFS_BLOCK_GROUP_RAID1C3 | \ 896 BTRFS_BLOCK_GROUP_RAID1C4 | \ 897 BTRFS_BLOCK_GROUP_RAID5 | \ 898 BTRFS_BLOCK_GROUP_RAID6 | \ 899 BTRFS_BLOCK_GROUP_DUP | \ 900 BTRFS_BLOCK_GROUP_RAID10) 901 #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \ 902 BTRFS_BLOCK_GROUP_RAID6) 903 904 #define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | \ 905 BTRFS_BLOCK_GROUP_RAID1C3 | \ 906 BTRFS_BLOCK_GROUP_RAID1C4) 907 908 /* 909 * We need a bit for restriper to be able to tell when chunks of type 910 * SINGLE are available. This "extended" profile format is used in 911 * fs_info->avail_*_alloc_bits (in-memory) and balance item fields 912 * (on-disk). The corresponding on-disk bit in chunk.type is reserved 913 * to avoid remappings between two formats in future. 914 */ 915 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48) 916 917 /* 918 * A fake block group type that is used to communicate global block reserve 919 * size to userspace via the SPACE_INFO ioctl. 920 */ 921 #define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49) 922 923 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \ 924 BTRFS_AVAIL_ALLOC_BIT_SINGLE) 925 926 static __inline__ __u64 chunk_to_extended(__u64 flags) 927 { 928 if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0) 929 flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE; 930 931 return flags; 932 } 933 static __inline__ __u64 extended_to_chunk(__u64 flags) 934 { 935 return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE; 936 } 937 938 struct btrfs_block_group_item { 939 __le64 used; 940 __le64 chunk_objectid; 941 __le64 flags; 942 } __attribute__ ((__packed__)); 943 944 struct btrfs_free_space_info { 945 __le32 extent_count; 946 __le32 flags; 947 } __attribute__ ((__packed__)); 948 949 #define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0) 950 951 #define BTRFS_QGROUP_LEVEL_SHIFT 48 952 static __inline__ __u16 btrfs_qgroup_level(__u64 qgroupid) 953 { 954 return (__u16)(qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT); 955 } 956 957 /* 958 * is subvolume quota turned on? 959 */ 960 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0) 961 /* 962 * RESCAN is set during the initialization phase 963 */ 964 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1) 965 /* 966 * Some qgroup entries are known to be out of date, 967 * either because the configuration has changed in a way that 968 * makes a rescan necessary, or because the fs has been mounted 969 * with a non-qgroup-aware version. 970 * Turning qouta off and on again makes it inconsistent, too. 971 */ 972 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2) 973 974 #define BTRFS_QGROUP_STATUS_VERSION 1 975 976 struct btrfs_qgroup_status_item { 977 __le64 version; 978 /* 979 * the generation is updated during every commit. As older 980 * versions of btrfs are not aware of qgroups, it will be 981 * possible to detect inconsistencies by checking the 982 * generation on mount time 983 */ 984 __le64 generation; 985 986 /* flag definitions see above */ 987 __le64 flags; 988 989 /* 990 * only used during scanning to record the progress 991 * of the scan. It contains a logical address 992 */ 993 __le64 rescan; 994 } __attribute__ ((__packed__)); 995 996 struct btrfs_qgroup_info_item { 997 __le64 generation; 998 __le64 rfer; 999 __le64 rfer_cmpr; 1000 __le64 excl; 1001 __le64 excl_cmpr; 1002 } __attribute__ ((__packed__)); 1003 1004 struct btrfs_qgroup_limit_item { 1005 /* 1006 * only updated when any of the other values change 1007 */ 1008 __le64 flags; 1009 __le64 max_rfer; 1010 __le64 max_excl; 1011 __le64 rsv_rfer; 1012 __le64 rsv_excl; 1013 } __attribute__ ((__packed__)); 1014 1015 struct btrfs_verity_descriptor_item { 1016 /* Size of the verity descriptor in bytes */ 1017 __le64 size; 1018 /* 1019 * When we implement support for fscrypt, we will need to encrypt the 1020 * Merkle tree for encrypted verity files. These 128 bits are for the 1021 * eventual storage of an fscrypt initialization vector. 1022 */ 1023 __le64 reserved[2]; 1024 __u8 encryption; 1025 } __attribute__ ((__packed__)); 1026 1027 #endif /* _BTRFS_CTREE_H_ */
Contact us
|
About us
|
Term of use
|
Copyright © 2000-2024 MyWebUniversity.com ™