1 #ifndef _BTRFS_CTREE_H_
2 #define _BTRFS_CTREE_H_
4 #include <linux/types.h>
7 * This header contains the structure definitions and constants used
8 * by file system objects that can be retrieved using
9 * the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that
10 * is needed to describe a leaf node's key or item contents.
13 /* holds pointers to all of the tree roots */
14 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
16 /* stores information about which extents are in use, and reference counts */
17 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
20 * chunk tree stores translations from logical -> physical block numbering
21 * the super block points to the chunk tree
23 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL
26 * stores information about which areas of a given device are in use.
27 * one per device. The tree of tree roots points to the device tree
29 #define BTRFS_DEV_TREE_OBJECTID 4ULL
31 /* one per subvolume, storing files and directories */
32 #define BTRFS_FS_TREE_OBJECTID 5ULL
34 /* directory objectid inside the root tree */
35 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
37 /* holds checksums of all the data extents */
38 #define BTRFS_CSUM_TREE_OBJECTID 7ULL
40 /* holds quota configuration and tracking */
41 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
43 /* for storing items that use the BTRFS_UUID_KEY* types */
44 #define BTRFS_UUID_TREE_OBJECTID 9ULL
46 /* tracks free space in block groups. */
47 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
49 /* device stats in the device tree */
50 #define BTRFS_DEV_STATS_OBJECTID 0ULL
52 /* for storing balance parameters in the root tree */
53 #define BTRFS_BALANCE_OBJECTID -4ULL
55 /* orhpan objectid for tracking unlinked/truncated files */
56 #define BTRFS_ORPHAN_OBJECTID -5ULL
58 /* does write ahead logging to speed up fsyncs */
59 #define BTRFS_TREE_LOG_OBJECTID -6ULL
60 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL
62 /* for space balancing */
63 #define BTRFS_TREE_RELOC_OBJECTID -8ULL
64 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL
67 * extent checksums all have this objectid
68 * this allows them to share the logging tree
71 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
73 /* For storing free space cache */
74 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
77 * The inode number assigned to the special inode for storing
80 #define BTRFS_FREE_INO_OBJECTID -12ULL
82 /* dummy objectid represents multiple objectids */
83 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL
86 * All files have objectids in this range.
88 #define BTRFS_FIRST_FREE_OBJECTID 256ULL
89 #define BTRFS_LAST_FREE_OBJECTID -256ULL
90 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
94 * the device items go into the chunk tree. The key is in the form
95 * [ 1 BTRFS_DEV_ITEM_KEY device_id ]
97 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL
99 #define BTRFS_BTREE_INODE_OBJECTID 1
101 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
103 #define BTRFS_DEV_REPLACE_DEVID 0ULL
106 * inode items have the data typically returned from stat and store other
107 * info about object characteristics. There is one for every file and dir in
110 #define BTRFS_INODE_ITEM_KEY 1
111 #define BTRFS_INODE_REF_KEY 12
112 #define BTRFS_INODE_EXTREF_KEY 13
113 #define BTRFS_XATTR_ITEM_KEY 24
114 #define BTRFS_ORPHAN_ITEM_KEY 48
115 /* reserve 2-15 close to the inode for later flexibility */
118 * dir items are the name -> inode pointers in a directory. There is one
119 * for every name in a directory.
121 #define BTRFS_DIR_LOG_ITEM_KEY 60
122 #define BTRFS_DIR_LOG_INDEX_KEY 72
123 #define BTRFS_DIR_ITEM_KEY 84
124 #define BTRFS_DIR_INDEX_KEY 96
126 * extent data is for file data
128 #define BTRFS_EXTENT_DATA_KEY 108
131 * extent csums are stored in a separate tree and hold csums for
132 * an entire extent on disk.
134 #define BTRFS_EXTENT_CSUM_KEY 128
137 * root items point to tree roots. They are typically in the root
138 * tree used by the super block to find all the other trees
140 #define BTRFS_ROOT_ITEM_KEY 132
143 * root backrefs tie subvols and snapshots to the directory entries that
146 #define BTRFS_ROOT_BACKREF_KEY 144
149 * root refs make a fast index for listing all of the snapshots and
150 * subvolumes referenced by a given root. They point directly to the
151 * directory item in the root that references the subvol
153 #define BTRFS_ROOT_REF_KEY 156
156 * extent items are in the extent map tree. These record which blocks
157 * are used, and how many references there are to each block
159 #define BTRFS_EXTENT_ITEM_KEY 168
162 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know
163 * the length, so we save the level in key->offset instead of the length.
165 #define BTRFS_METADATA_ITEM_KEY 169
167 #define BTRFS_TREE_BLOCK_REF_KEY 176
169 #define BTRFS_EXTENT_DATA_REF_KEY 178
171 #define BTRFS_EXTENT_REF_V0_KEY 180
173 #define BTRFS_SHARED_BLOCK_REF_KEY 182
175 #define BTRFS_SHARED_DATA_REF_KEY 184
178 * block groups give us hints into the extent allocation trees. Which
179 * blocks are free etc etc
181 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192
184 * Every block group is represented in the free space tree by a free space info
185 * item, which stores some accounting information. It is keyed on
186 * (block_group_start, FREE_SPACE_INFO, block_group_length).
188 #define BTRFS_FREE_SPACE_INFO_KEY 198
191 * A free space extent tracks an extent of space that is free in a block group.
192 * It is keyed on (start, FREE_SPACE_EXTENT, length).
194 #define BTRFS_FREE_SPACE_EXTENT_KEY 199
197 * When a block group becomes very fragmented, we convert it to use bitmaps
198 * instead of extents. A free space bitmap is keyed on
199 * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with
200 * (length / sectorsize) bits.
202 #define BTRFS_FREE_SPACE_BITMAP_KEY 200
204 #define BTRFS_DEV_EXTENT_KEY 204
205 #define BTRFS_DEV_ITEM_KEY 216
206 #define BTRFS_CHUNK_ITEM_KEY 228
209 * Records the overall state of the qgroups.
210 * There's only one instance of this key present,
211 * (0, BTRFS_QGROUP_STATUS_KEY, 0)
213 #define BTRFS_QGROUP_STATUS_KEY 240
215 * Records the currently used space of the qgroup.
216 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid).
218 #define BTRFS_QGROUP_INFO_KEY 242
220 * Contains the user configured limits for the qgroup.
221 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid).
223 #define BTRFS_QGROUP_LIMIT_KEY 244
225 * Records the child-parent relationship of qgroups. For
226 * each relation, 2 keys are present:
227 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid)
228 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid)
230 #define BTRFS_QGROUP_RELATION_KEY 246
233 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY.
235 #define BTRFS_BALANCE_ITEM_KEY 248
238 * The key type for tree items that are stored persistently, but do not need to
239 * exist for extended period of time. The items can exist in any tree.
241 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data]
245 * - balance status item
246 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0)
248 #define BTRFS_TEMPORARY_ITEM_KEY 248
251 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY
253 #define BTRFS_DEV_STATS_KEY 249
256 * The key type for tree items that are stored persistently and usually exist
257 * for a long period, eg. filesystem lifetime. The item kinds can be status
258 * information, stats or preference values. The item can exist in any tree.
260 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data]
264 * - device statistics, store IO stats in the device tree, one key for all
266 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0)
268 #define BTRFS_PERSISTENT_ITEM_KEY 249
271 * Persistantly stores the device replace state in the device tree.
272 * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).
274 #define BTRFS_DEV_REPLACE_KEY 250
277 * Stores items that allow to quickly map UUIDs to something else.
278 * These items are part of the filesystem UUID tree.
279 * The key is built like this:
280 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits).
282 #if BTRFS_UUID_SIZE != 16
283 #error "UUID items require BTRFS_UUID_SIZE == 16!"
285 #define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */
286 #define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to
287 * received subvols */
290 * string items are for debugging. They just store a short string of
293 #define BTRFS_STRING_ITEM_KEY 253
297 /* 32 bytes in various csum fields */
298 #define BTRFS_CSUM_SIZE 32
301 #define BTRFS_CSUM_TYPE_CRC32 0
304 * flags definitions for directory entry item type
307 * struct btrfs_dir_item.type
309 #define BTRFS_FT_UNKNOWN 0
310 #define BTRFS_FT_REG_FILE 1
311 #define BTRFS_FT_DIR 2
312 #define BTRFS_FT_CHRDEV 3
313 #define BTRFS_FT_BLKDEV 4
314 #define BTRFS_FT_FIFO 5
315 #define BTRFS_FT_SOCK 6
316 #define BTRFS_FT_SYMLINK 7
317 #define BTRFS_FT_XATTR 8
318 #define BTRFS_FT_MAX 9
321 * The key defines the order in the tree, and so it also defines (optimal)
324 * objectid corresponds to the inode number.
326 * type tells us things about the object, and is a kind of stream selector.
327 * so for a given inode, keys with type of 1 might refer to the inode data,
328 * type of 2 may point to file data in the btree and type == 3 may point to
331 * offset is the starting byte offset for this key in the stream.
333 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
334 * in cpu native order. Otherwise they are identical and their sizes
335 * should be the same (ie both packed)
337 struct btrfs_disk_key {
341 } __attribute__ ((__packed__));
347 } __attribute__ ((__packed__));
349 struct btrfs_dev_item {
350 /* the internal btrfs device id */
353 /* size of the device */
359 /* optimal io alignment for this device */
362 /* optimal io width for this device */
365 /* minimal io size for this device */
368 /* type and info about this device */
371 /* expected generation for this device */
375 * starting byte of this partition on the device,
376 * to allow for stripe alignment in the future
380 /* grouping information for allocation decisions */
383 /* seek speed 0-100 where 100 is fastest */
386 /* bandwidth 0-100 where 100 is fastest */
389 /* btrfs generated uuid for this device */
390 __u8 uuid[BTRFS_UUID_SIZE];
392 /* uuid of FS who owns this device */
393 __u8 fsid[BTRFS_UUID_SIZE];
394 } __attribute__ ((__packed__));
396 struct btrfs_stripe {
399 __u8 dev_uuid[BTRFS_UUID_SIZE];
400 } __attribute__ ((__packed__));
403 /* size of this chunk in bytes */
406 /* objectid of the root referencing this chunk */
412 /* optimal io alignment for this chunk */
415 /* optimal io width for this chunk */
418 /* minimal io size for this chunk */
421 /* 2^16 stripes is quite a lot, a second limit is the size of a single
426 /* sub stripes only matter for raid10 */
428 struct btrfs_stripe stripe;
429 /* additional stripes go here */
430 } __attribute__ ((__packed__));
432 #define BTRFS_FREE_SPACE_EXTENT 1
433 #define BTRFS_FREE_SPACE_BITMAP 2
435 struct btrfs_free_space_entry {
439 } __attribute__ ((__packed__));
441 struct btrfs_free_space_header {
442 struct btrfs_disk_key location;
446 } __attribute__ ((__packed__));
448 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
449 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
451 /* Super block flags */
452 /* Errors detected */
453 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
455 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
456 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
457 #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
461 * items in the extent btree are used to record the objectid of the
462 * owner of the block and the number of references
465 struct btrfs_extent_item {
469 } __attribute__ ((__packed__));
471 struct btrfs_extent_item_v0 {
473 } __attribute__ ((__packed__));
476 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
477 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
479 /* following flags only apply to tree blocks */
481 /* use full backrefs for extent pointers in the block */
482 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
485 * this flag is only used internally by scrub and may be changed at any time
486 * it is only declared here to avoid collisions
488 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
490 struct btrfs_tree_block_info {
491 struct btrfs_disk_key key;
493 } __attribute__ ((__packed__));
495 struct btrfs_extent_data_ref {
500 } __attribute__ ((__packed__));
502 struct btrfs_shared_data_ref {
504 } __attribute__ ((__packed__));
506 struct btrfs_extent_inline_ref {
509 } __attribute__ ((__packed__));
511 /* old style backrefs item */
512 struct btrfs_extent_ref_v0 {
517 } __attribute__ ((__packed__));
520 /* dev extents record free space on individual devices. The owner
521 * field points back to the chunk allocation mapping tree that allocated
522 * the extent. The chunk tree uuid field is a way to double check the owner
524 struct btrfs_dev_extent {
526 __le64 chunk_objectid;
529 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
530 } __attribute__ ((__packed__));
532 struct btrfs_inode_ref {
536 } __attribute__ ((__packed__));
538 struct btrfs_inode_extref {
539 __le64 parent_objectid;
544 } __attribute__ ((__packed__));
546 struct btrfs_timespec {
549 } __attribute__ ((__packed__));
551 struct btrfs_inode_item {
552 /* nfs style generation number */
554 /* transid that last touched this inode */
566 /* modification sequence number for NFS */
570 * a little future expansion, for more than this we can
571 * just grow the inode item and version it
574 struct btrfs_timespec atime;
575 struct btrfs_timespec ctime;
576 struct btrfs_timespec mtime;
577 struct btrfs_timespec otime;
578 } __attribute__ ((__packed__));
580 struct btrfs_dir_log_item {
582 } __attribute__ ((__packed__));
584 struct btrfs_dir_item {
585 struct btrfs_disk_key location;
590 } __attribute__ ((__packed__));
592 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
595 * Internal in-memory flag that a subvolume has been marked for deletion but
596 * still visible as a directory
598 #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
600 struct btrfs_root_item {
601 struct btrfs_inode_item inode;
607 __le64 last_snapshot;
610 struct btrfs_disk_key drop_progress;
615 * The following fields appear after subvol_uuids+subvol_times
620 * This generation number is used to test if the new fields are valid
621 * and up to date while reading the root item. Every time the root item
622 * is written out, the "generation" field is copied into this field. If
623 * anyone ever mounted the fs with an older kernel, we will have
624 * mismatching generation values here and thus must invalidate the
625 * new fields. See btrfs_update_root and btrfs_find_last_root for
627 * the offset of generation_v2 is also used as the start for the memset
628 * when invalidating the fields.
630 __le64 generation_v2;
631 __u8 uuid[BTRFS_UUID_SIZE];
632 __u8 parent_uuid[BTRFS_UUID_SIZE];
633 __u8 received_uuid[BTRFS_UUID_SIZE];
634 __le64 ctransid; /* updated when an inode changes */
635 __le64 otransid; /* trans when created */
636 __le64 stransid; /* trans when sent. non-zero for received subvol */
637 __le64 rtransid; /* trans when received. non-zero for received subvol */
638 struct btrfs_timespec ctime;
639 struct btrfs_timespec otime;
640 struct btrfs_timespec stime;
641 struct btrfs_timespec rtime;
642 __le64 reserved[8]; /* for future */
643 } __attribute__ ((__packed__));
646 * this is used for both forward and backward root refs
648 struct btrfs_root_ref {
652 } __attribute__ ((__packed__));
654 struct btrfs_disk_balance_args {
656 * profiles to operate on, single is denoted by
657 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
663 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
664 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
677 /* devid subset filter [pstart..pend) */
681 /* btrfs virtual address space subset filter [vstart..vend) */
686 * profile to convert to, single is denoted by
687 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
691 /* BTRFS_BALANCE_ARGS_* */
695 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
696 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
708 * Process chunks that cross stripes_min..stripes_max devices,
709 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
715 } __attribute__ ((__packed__));
718 * store balance parameters to disk so that balance can be properly
719 * resumed after crash or unmount
721 struct btrfs_balance_item {
722 /* BTRFS_BALANCE_* */
725 struct btrfs_disk_balance_args data;
726 struct btrfs_disk_balance_args meta;
727 struct btrfs_disk_balance_args sys;
730 } __attribute__ ((__packed__));
732 #define BTRFS_FILE_EXTENT_INLINE 0
733 #define BTRFS_FILE_EXTENT_REG 1
734 #define BTRFS_FILE_EXTENT_PREALLOC 2
735 #define BTRFS_FILE_EXTENT_TYPES 2
737 struct btrfs_file_extent_item {
739 * transaction id that created this extent
743 * max number of bytes to hold this extent in ram
744 * when we split a compressed extent we can't know how big
745 * each of the resulting pieces will be. So, this is
746 * an upper limit on the size of the extent in ram instead of
752 * 32 bits for the various ways we might encode the data,
753 * including compression and encryption. If any of these
754 * are set to something a given disk format doesn't understand
755 * it is treated like an incompat flag for reading and writing,
760 __le16 other_encoding; /* spare for later use */
762 /* are we inline data or a real extent? */
766 * disk space consumed by the extent, checksum blocks are included
769 * At this offset in the structure, the inline extent data start.
772 __le64 disk_num_bytes;
774 * the logical offset in file blocks (no csums)
775 * this extent record is for. This allows a file extent to point
776 * into the middle of an existing extent on disk, sharing it
777 * between two snapshots (useful if some bytes in the middle of the
778 * extent have changed
782 * the logical number of file blocks (no csums included). This
783 * always reflects the size uncompressed and without encoding.
787 } __attribute__ ((__packed__));
789 struct btrfs_csum_item {
791 } __attribute__ ((__packed__));
793 struct btrfs_dev_stats_item {
795 * grow this item struct at the end for future enhancements and keep
796 * the existing values unchanged
798 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
799 } __attribute__ ((__packed__));
801 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
802 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
803 #define BTRFS_DEV_REPLACE_ITEM_STATE_NEVER_STARTED 0
804 #define BTRFS_DEV_REPLACE_ITEM_STATE_STARTED 1
805 #define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED 2
806 #define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED 3
807 #define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED 4
809 struct btrfs_dev_replace_item {
811 * grow this item struct at the end for future enhancements and keep
812 * the existing values unchanged
817 __le64 cont_reading_from_srcdev_mode;
819 __le64 replace_state;
822 __le64 num_write_errors;
823 __le64 num_uncorrectable_read_errors;
824 } __attribute__ ((__packed__));
826 /* different types of block groups (and chunks) */
827 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
828 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
829 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
830 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
831 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
832 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
833 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
834 #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
835 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
836 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
837 BTRFS_SPACE_INFO_GLOBAL_RSV)
839 enum btrfs_raid_types {
850 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
851 BTRFS_BLOCK_GROUP_SYSTEM | \
852 BTRFS_BLOCK_GROUP_METADATA)
854 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \
855 BTRFS_BLOCK_GROUP_RAID1 | \
856 BTRFS_BLOCK_GROUP_RAID5 | \
857 BTRFS_BLOCK_GROUP_RAID6 | \
858 BTRFS_BLOCK_GROUP_DUP | \
859 BTRFS_BLOCK_GROUP_RAID10)
860 #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \
861 BTRFS_BLOCK_GROUP_RAID6)
864 * We need a bit for restriper to be able to tell when chunks of type
865 * SINGLE are available. This "extended" profile format is used in
866 * fs_info->avail_*_alloc_bits (in-memory) and balance item fields
867 * (on-disk). The corresponding on-disk bit in chunk.type is reserved
868 * to avoid remappings between two formats in future.
870 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
873 * A fake block group type that is used to communicate global block reserve
874 * size to userspace via the SPACE_INFO ioctl.
876 #define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
878 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \
879 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
881 static inline __u64 chunk_to_extended(__u64 flags)
883 if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0)
884 flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE;
888 static inline __u64 extended_to_chunk(__u64 flags)
890 return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE;
893 struct btrfs_block_group_item {
895 __le64 chunk_objectid;
897 } __attribute__ ((__packed__));
899 struct btrfs_free_space_info {
902 } __attribute__ ((__packed__));
904 #define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
906 #define BTRFS_QGROUP_LEVEL_SHIFT 48
907 static inline __u64 btrfs_qgroup_level(__u64 qgroupid)
909 return qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT;
913 * is subvolume quota turned on?
915 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
917 * RESCAN is set during the initialization phase
919 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
921 * Some qgroup entries are known to be out of date,
922 * either because the configuration has changed in a way that
923 * makes a rescan necessary, or because the fs has been mounted
924 * with a non-qgroup-aware version.
925 * Turning qouta off and on again makes it inconsistent, too.
927 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
929 #define BTRFS_QGROUP_STATUS_VERSION 1
931 struct btrfs_qgroup_status_item {
934 * the generation is updated during every commit. As older
935 * versions of btrfs are not aware of qgroups, it will be
936 * possible to detect inconsistencies by checking the
937 * generation on mount time
941 /* flag definitions see above */
945 * only used during scanning to record the progress
946 * of the scan. It contains a logical address
949 } __attribute__ ((__packed__));
951 struct btrfs_qgroup_info_item {
957 } __attribute__ ((__packed__));
959 struct btrfs_qgroup_limit_item {
961 * only updated when any of the other values change
968 } __attribute__ ((__packed__));
970 #endif /* _BTRFS_CTREE_H_ */