1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _BTRFS_CTREE_H_
3 #define _BTRFS_CTREE_H_
5 #include <linux/btrfs.h>
6 #include <linux/types.h>
9 * This header contains the structure definitions and constants used
10 * by file system objects that can be retrieved using
11 * the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that
12 * is needed to describe a leaf node's key or item contents.
15 /* holds pointers to all of the tree roots */
16 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
18 /* stores information about which extents are in use, and reference counts */
19 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
22 * chunk tree stores translations from logical -> physical block numbering
23 * the super block points to the chunk tree
25 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL
28 * stores information about which areas of a given device are in use.
29 * one per device. The tree of tree roots points to the device tree
31 #define BTRFS_DEV_TREE_OBJECTID 4ULL
33 /* one per subvolume, storing files and directories */
34 #define BTRFS_FS_TREE_OBJECTID 5ULL
36 /* directory objectid inside the root tree */
37 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
39 /* holds checksums of all the data extents */
40 #define BTRFS_CSUM_TREE_OBJECTID 7ULL
42 /* holds quota configuration and tracking */
43 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
45 /* for storing items that use the BTRFS_UUID_KEY* types */
46 #define BTRFS_UUID_TREE_OBJECTID 9ULL
48 /* tracks free space in block groups. */
49 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
51 /* device stats in the device tree */
52 #define BTRFS_DEV_STATS_OBJECTID 0ULL
54 /* for storing balance parameters in the root tree */
55 #define BTRFS_BALANCE_OBJECTID -4ULL
57 /* orhpan objectid for tracking unlinked/truncated files */
58 #define BTRFS_ORPHAN_OBJECTID -5ULL
60 /* does write ahead logging to speed up fsyncs */
61 #define BTRFS_TREE_LOG_OBJECTID -6ULL
62 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL
64 /* for space balancing */
65 #define BTRFS_TREE_RELOC_OBJECTID -8ULL
66 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL
69 * extent checksums all have this objectid
70 * this allows them to share the logging tree
73 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
75 /* For storing free space cache */
76 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
79 * The inode number assigned to the special inode for storing
82 #define BTRFS_FREE_INO_OBJECTID -12ULL
84 /* dummy objectid represents multiple objectids */
85 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL
88 * All files have objectids in this range.
90 #define BTRFS_FIRST_FREE_OBJECTID 256ULL
91 #define BTRFS_LAST_FREE_OBJECTID -256ULL
92 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
96 * the device items go into the chunk tree. The key is in the form
97 * [ 1 BTRFS_DEV_ITEM_KEY device_id ]
99 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL
101 #define BTRFS_BTREE_INODE_OBJECTID 1
103 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
105 #define BTRFS_DEV_REPLACE_DEVID 0ULL
108 * inode items have the data typically returned from stat and store other
109 * info about object characteristics. There is one for every file and dir in
112 #define BTRFS_INODE_ITEM_KEY 1
113 #define BTRFS_INODE_REF_KEY 12
114 #define BTRFS_INODE_EXTREF_KEY 13
115 #define BTRFS_XATTR_ITEM_KEY 24
116 #define BTRFS_ORPHAN_ITEM_KEY 48
117 /* reserve 2-15 close to the inode for later flexibility */
120 * dir items are the name -> inode pointers in a directory. There is one
121 * for every name in a directory.
123 #define BTRFS_DIR_LOG_ITEM_KEY 60
124 #define BTRFS_DIR_LOG_INDEX_KEY 72
125 #define BTRFS_DIR_ITEM_KEY 84
126 #define BTRFS_DIR_INDEX_KEY 96
128 * extent data is for file data
130 #define BTRFS_EXTENT_DATA_KEY 108
133 * extent csums are stored in a separate tree and hold csums for
134 * an entire extent on disk.
136 #define BTRFS_EXTENT_CSUM_KEY 128
139 * root items point to tree roots. They are typically in the root
140 * tree used by the super block to find all the other trees
142 #define BTRFS_ROOT_ITEM_KEY 132
145 * root backrefs tie subvols and snapshots to the directory entries that
148 #define BTRFS_ROOT_BACKREF_KEY 144
151 * root refs make a fast index for listing all of the snapshots and
152 * subvolumes referenced by a given root. They point directly to the
153 * directory item in the root that references the subvol
155 #define BTRFS_ROOT_REF_KEY 156
158 * extent items are in the extent map tree. These record which blocks
159 * are used, and how many references there are to each block
161 #define BTRFS_EXTENT_ITEM_KEY 168
164 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know
165 * the length, so we save the level in key->offset instead of the length.
167 #define BTRFS_METADATA_ITEM_KEY 169
169 #define BTRFS_TREE_BLOCK_REF_KEY 176
171 #define BTRFS_EXTENT_DATA_REF_KEY 178
173 #define BTRFS_EXTENT_REF_V0_KEY 180
175 #define BTRFS_SHARED_BLOCK_REF_KEY 182
177 #define BTRFS_SHARED_DATA_REF_KEY 184
180 * block groups give us hints into the extent allocation trees. Which
181 * blocks are free etc etc
183 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192
186 * Every block group is represented in the free space tree by a free space info
187 * item, which stores some accounting information. It is keyed on
188 * (block_group_start, FREE_SPACE_INFO, block_group_length).
190 #define BTRFS_FREE_SPACE_INFO_KEY 198
193 * A free space extent tracks an extent of space that is free in a block group.
194 * It is keyed on (start, FREE_SPACE_EXTENT, length).
196 #define BTRFS_FREE_SPACE_EXTENT_KEY 199
199 * When a block group becomes very fragmented, we convert it to use bitmaps
200 * instead of extents. A free space bitmap is keyed on
201 * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with
202 * (length / sectorsize) bits.
204 #define BTRFS_FREE_SPACE_BITMAP_KEY 200
206 #define BTRFS_DEV_EXTENT_KEY 204
207 #define BTRFS_DEV_ITEM_KEY 216
208 #define BTRFS_CHUNK_ITEM_KEY 228
211 * Records the overall state of the qgroups.
212 * There's only one instance of this key present,
213 * (0, BTRFS_QGROUP_STATUS_KEY, 0)
215 #define BTRFS_QGROUP_STATUS_KEY 240
217 * Records the currently used space of the qgroup.
218 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid).
220 #define BTRFS_QGROUP_INFO_KEY 242
222 * Contains the user configured limits for the qgroup.
223 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid).
225 #define BTRFS_QGROUP_LIMIT_KEY 244
227 * Records the child-parent relationship of qgroups. For
228 * each relation, 2 keys are present:
229 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid)
230 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid)
232 #define BTRFS_QGROUP_RELATION_KEY 246
235 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY.
237 #define BTRFS_BALANCE_ITEM_KEY 248
240 * The key type for tree items that are stored persistently, but do not need to
241 * exist for extended period of time. The items can exist in any tree.
243 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data]
247 * - balance status item
248 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0)
250 #define BTRFS_TEMPORARY_ITEM_KEY 248
253 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY
255 #define BTRFS_DEV_STATS_KEY 249
258 * The key type for tree items that are stored persistently and usually exist
259 * for a long period, eg. filesystem lifetime. The item kinds can be status
260 * information, stats or preference values. The item can exist in any tree.
262 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data]
266 * - device statistics, store IO stats in the device tree, one key for all
268 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0)
270 #define BTRFS_PERSISTENT_ITEM_KEY 249
273 * Persistantly stores the device replace state in the device tree.
274 * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).
276 #define BTRFS_DEV_REPLACE_KEY 250
279 * Stores items that allow to quickly map UUIDs to something else.
280 * These items are part of the filesystem UUID tree.
281 * The key is built like this:
282 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits).
284 #if BTRFS_UUID_SIZE != 16
285 #error "UUID items require BTRFS_UUID_SIZE == 16!"
287 #define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */
288 #define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to
289 * received subvols */
292 * string items are for debugging. They just store a short string of
295 #define BTRFS_STRING_ITEM_KEY 253
299 /* 32 bytes in various csum fields */
300 #define BTRFS_CSUM_SIZE 32
303 enum btrfs_csum_type {
304 BTRFS_CSUM_TYPE_CRC32 = 0,
305 BTRFS_CSUM_TYPE_XXHASH = 1,
309 * flags definitions for directory entry item type
312 * struct btrfs_dir_item.type
314 * Values 0..7 must match common file type values in fs_types.h.
316 #define BTRFS_FT_UNKNOWN 0
317 #define BTRFS_FT_REG_FILE 1
318 #define BTRFS_FT_DIR 2
319 #define BTRFS_FT_CHRDEV 3
320 #define BTRFS_FT_BLKDEV 4
321 #define BTRFS_FT_FIFO 5
322 #define BTRFS_FT_SOCK 6
323 #define BTRFS_FT_SYMLINK 7
324 #define BTRFS_FT_XATTR 8
325 #define BTRFS_FT_MAX 9
328 * The key defines the order in the tree, and so it also defines (optimal)
331 * objectid corresponds to the inode number.
333 * type tells us things about the object, and is a kind of stream selector.
334 * so for a given inode, keys with type of 1 might refer to the inode data,
335 * type of 2 may point to file data in the btree and type == 3 may point to
338 * offset is the starting byte offset for this key in the stream.
340 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
341 * in cpu native order. Otherwise they are identical and their sizes
342 * should be the same (ie both packed)
344 struct btrfs_disk_key {
348 } __attribute__ ((__packed__));
354 } __attribute__ ((__packed__));
356 struct btrfs_dev_item {
357 /* the internal btrfs device id */
360 /* size of the device */
366 /* optimal io alignment for this device */
369 /* optimal io width for this device */
372 /* minimal io size for this device */
375 /* type and info about this device */
378 /* expected generation for this device */
382 * starting byte of this partition on the device,
383 * to allow for stripe alignment in the future
387 /* grouping information for allocation decisions */
390 /* seek speed 0-100 where 100 is fastest */
393 /* bandwidth 0-100 where 100 is fastest */
396 /* btrfs generated uuid for this device */
397 __u8 uuid[BTRFS_UUID_SIZE];
399 /* uuid of FS who owns this device */
400 __u8 fsid[BTRFS_UUID_SIZE];
401 } __attribute__ ((__packed__));
403 struct btrfs_stripe {
406 __u8 dev_uuid[BTRFS_UUID_SIZE];
407 } __attribute__ ((__packed__));
410 /* size of this chunk in bytes */
413 /* objectid of the root referencing this chunk */
419 /* optimal io alignment for this chunk */
422 /* optimal io width for this chunk */
425 /* minimal io size for this chunk */
428 /* 2^16 stripes is quite a lot, a second limit is the size of a single
433 /* sub stripes only matter for raid10 */
435 struct btrfs_stripe stripe;
436 /* additional stripes go here */
437 } __attribute__ ((__packed__));
439 #define BTRFS_FREE_SPACE_EXTENT 1
440 #define BTRFS_FREE_SPACE_BITMAP 2
442 struct btrfs_free_space_entry {
446 } __attribute__ ((__packed__));
448 struct btrfs_free_space_header {
449 struct btrfs_disk_key location;
453 } __attribute__ ((__packed__));
455 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
456 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
458 /* Super block flags */
459 /* Errors detected */
460 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
462 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
463 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
464 #define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
465 #define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
466 #define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
470 * items in the extent btree are used to record the objectid of the
471 * owner of the block and the number of references
474 struct btrfs_extent_item {
478 } __attribute__ ((__packed__));
480 struct btrfs_extent_item_v0 {
482 } __attribute__ ((__packed__));
485 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
486 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
488 /* following flags only apply to tree blocks */
490 /* use full backrefs for extent pointers in the block */
491 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
494 * this flag is only used internally by scrub and may be changed at any time
495 * it is only declared here to avoid collisions
497 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
499 struct btrfs_tree_block_info {
500 struct btrfs_disk_key key;
502 } __attribute__ ((__packed__));
504 struct btrfs_extent_data_ref {
509 } __attribute__ ((__packed__));
511 struct btrfs_shared_data_ref {
513 } __attribute__ ((__packed__));
515 struct btrfs_extent_inline_ref {
518 } __attribute__ ((__packed__));
520 /* old style backrefs item */
521 struct btrfs_extent_ref_v0 {
526 } __attribute__ ((__packed__));
529 /* dev extents record free space on individual devices. The owner
530 * field points back to the chunk allocation mapping tree that allocated
531 * the extent. The chunk tree uuid field is a way to double check the owner
533 struct btrfs_dev_extent {
535 __le64 chunk_objectid;
538 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
539 } __attribute__ ((__packed__));
541 struct btrfs_inode_ref {
545 } __attribute__ ((__packed__));
547 struct btrfs_inode_extref {
548 __le64 parent_objectid;
553 } __attribute__ ((__packed__));
555 struct btrfs_timespec {
558 } __attribute__ ((__packed__));
560 struct btrfs_inode_item {
561 /* nfs style generation number */
563 /* transid that last touched this inode */
575 /* modification sequence number for NFS */
579 * a little future expansion, for more than this we can
580 * just grow the inode item and version it
583 struct btrfs_timespec atime;
584 struct btrfs_timespec ctime;
585 struct btrfs_timespec mtime;
586 struct btrfs_timespec otime;
587 } __attribute__ ((__packed__));
589 struct btrfs_dir_log_item {
591 } __attribute__ ((__packed__));
593 struct btrfs_dir_item {
594 struct btrfs_disk_key location;
599 } __attribute__ ((__packed__));
601 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
604 * Internal in-memory flag that a subvolume has been marked for deletion but
605 * still visible as a directory
607 #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
609 struct btrfs_root_item {
610 struct btrfs_inode_item inode;
616 __le64 last_snapshot;
619 struct btrfs_disk_key drop_progress;
624 * The following fields appear after subvol_uuids+subvol_times
629 * This generation number is used to test if the new fields are valid
630 * and up to date while reading the root item. Every time the root item
631 * is written out, the "generation" field is copied into this field. If
632 * anyone ever mounted the fs with an older kernel, we will have
633 * mismatching generation values here and thus must invalidate the
634 * new fields. See btrfs_update_root and btrfs_find_last_root for
636 * the offset of generation_v2 is also used as the start for the memset
637 * when invalidating the fields.
639 __le64 generation_v2;
640 __u8 uuid[BTRFS_UUID_SIZE];
641 __u8 parent_uuid[BTRFS_UUID_SIZE];
642 __u8 received_uuid[BTRFS_UUID_SIZE];
643 __le64 ctransid; /* updated when an inode changes */
644 __le64 otransid; /* trans when created */
645 __le64 stransid; /* trans when sent. non-zero for received subvol */
646 __le64 rtransid; /* trans when received. non-zero for received subvol */
647 struct btrfs_timespec ctime;
648 struct btrfs_timespec otime;
649 struct btrfs_timespec stime;
650 struct btrfs_timespec rtime;
651 __le64 reserved[8]; /* for future */
652 } __attribute__ ((__packed__));
655 * this is used for both forward and backward root refs
657 struct btrfs_root_ref {
661 } __attribute__ ((__packed__));
663 struct btrfs_disk_balance_args {
665 * profiles to operate on, single is denoted by
666 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
672 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
673 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
686 /* devid subset filter [pstart..pend) */
690 /* btrfs virtual address space subset filter [vstart..vend) */
695 * profile to convert to, single is denoted by
696 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
700 /* BTRFS_BALANCE_ARGS_* */
704 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
705 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
717 * Process chunks that cross stripes_min..stripes_max devices,
718 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
724 } __attribute__ ((__packed__));
727 * store balance parameters to disk so that balance can be properly
728 * resumed after crash or unmount
730 struct btrfs_balance_item {
731 /* BTRFS_BALANCE_* */
734 struct btrfs_disk_balance_args data;
735 struct btrfs_disk_balance_args meta;
736 struct btrfs_disk_balance_args sys;
739 } __attribute__ ((__packed__));
742 BTRFS_FILE_EXTENT_INLINE = 0,
743 BTRFS_FILE_EXTENT_REG = 1,
744 BTRFS_FILE_EXTENT_PREALLOC = 2,
745 BTRFS_NR_FILE_EXTENT_TYPES = 3,
748 struct btrfs_file_extent_item {
750 * transaction id that created this extent
754 * max number of bytes to hold this extent in ram
755 * when we split a compressed extent we can't know how big
756 * each of the resulting pieces will be. So, this is
757 * an upper limit on the size of the extent in ram instead of
763 * 32 bits for the various ways we might encode the data,
764 * including compression and encryption. If any of these
765 * are set to something a given disk format doesn't understand
766 * it is treated like an incompat flag for reading and writing,
771 __le16 other_encoding; /* spare for later use */
773 /* are we inline data or a real extent? */
777 * disk space consumed by the extent, checksum blocks are included
780 * At this offset in the structure, the inline extent data start.
783 __le64 disk_num_bytes;
785 * the logical offset in file blocks (no csums)
786 * this extent record is for. This allows a file extent to point
787 * into the middle of an existing extent on disk, sharing it
788 * between two snapshots (useful if some bytes in the middle of the
789 * extent have changed
793 * the logical number of file blocks (no csums included). This
794 * always reflects the size uncompressed and without encoding.
798 } __attribute__ ((__packed__));
800 struct btrfs_csum_item {
802 } __attribute__ ((__packed__));
804 struct btrfs_dev_stats_item {
806 * grow this item struct at the end for future enhancements and keep
807 * the existing values unchanged
809 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
810 } __attribute__ ((__packed__));
812 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
813 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
815 struct btrfs_dev_replace_item {
817 * grow this item struct at the end for future enhancements and keep
818 * the existing values unchanged
823 __le64 cont_reading_from_srcdev_mode;
825 __le64 replace_state;
828 __le64 num_write_errors;
829 __le64 num_uncorrectable_read_errors;
830 } __attribute__ ((__packed__));
832 /* different types of block groups (and chunks) */
833 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
834 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
835 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
836 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
837 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
838 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
839 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
840 #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
841 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
842 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
843 BTRFS_SPACE_INFO_GLOBAL_RSV)
845 enum btrfs_raid_types {
856 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
857 BTRFS_BLOCK_GROUP_SYSTEM | \
858 BTRFS_BLOCK_GROUP_METADATA)
860 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \
861 BTRFS_BLOCK_GROUP_RAID1 | \
862 BTRFS_BLOCK_GROUP_RAID5 | \
863 BTRFS_BLOCK_GROUP_RAID6 | \
864 BTRFS_BLOCK_GROUP_DUP | \
865 BTRFS_BLOCK_GROUP_RAID10)
866 #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \
867 BTRFS_BLOCK_GROUP_RAID6)
869 #define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1)
872 * We need a bit for restriper to be able to tell when chunks of type
873 * SINGLE are available. This "extended" profile format is used in
874 * fs_info->avail_*_alloc_bits (in-memory) and balance item fields
875 * (on-disk). The corresponding on-disk bit in chunk.type is reserved
876 * to avoid remappings between two formats in future.
878 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
881 * A fake block group type that is used to communicate global block reserve
882 * size to userspace via the SPACE_INFO ioctl.
884 #define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
886 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \
887 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
889 static inline __u64 chunk_to_extended(__u64 flags)
891 if ((flags & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0)
892 flags |= BTRFS_AVAIL_ALLOC_BIT_SINGLE;
896 static inline __u64 extended_to_chunk(__u64 flags)
898 return flags & ~BTRFS_AVAIL_ALLOC_BIT_SINGLE;
901 struct btrfs_block_group_item {
903 __le64 chunk_objectid;
905 } __attribute__ ((__packed__));
907 struct btrfs_free_space_info {
910 } __attribute__ ((__packed__));
912 #define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
914 #define BTRFS_QGROUP_LEVEL_SHIFT 48
915 static inline __u64 btrfs_qgroup_level(__u64 qgroupid)
917 return qgroupid >> BTRFS_QGROUP_LEVEL_SHIFT;
921 * is subvolume quota turned on?
923 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
925 * RESCAN is set during the initialization phase
927 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
929 * Some qgroup entries are known to be out of date,
930 * either because the configuration has changed in a way that
931 * makes a rescan necessary, or because the fs has been mounted
932 * with a non-qgroup-aware version.
933 * Turning qouta off and on again makes it inconsistent, too.
935 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
937 #define BTRFS_QGROUP_STATUS_VERSION 1
939 struct btrfs_qgroup_status_item {
942 * the generation is updated during every commit. As older
943 * versions of btrfs are not aware of qgroups, it will be
944 * possible to detect inconsistencies by checking the
945 * generation on mount time
949 /* flag definitions see above */
953 * only used during scanning to record the progress
954 * of the scan. It contains a logical address
957 } __attribute__ ((__packed__));
959 struct btrfs_qgroup_info_item {
965 } __attribute__ ((__packed__));
967 struct btrfs_qgroup_limit_item {
969 * only updated when any of the other values change
976 } __attribute__ ((__packed__));
978 #endif /* _BTRFS_CTREE_H_ */