linux-headers (unknown)

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