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