1 #ifndef _BTRFS_CTREE_H_
2 #define _BTRFS_CTREE_H_
5 * This header contains the structure definitions and constants used
6 * by file system objects that can be retrieved using
7 * the BTRFS_IOC_SEARCH_TREE ioctl. That means basically anything that
8 * is needed to describe a leaf node's key or item contents.
11 /* holds pointers to all of the tree roots */
12 #define BTRFS_ROOT_TREE_OBJECTID 1ULL
14 /* stores information about which extents are in use, and reference counts */
15 #define BTRFS_EXTENT_TREE_OBJECTID 2ULL
18 * chunk tree stores translations from logical -> physical block numbering
19 * the super block points to the chunk tree
21 #define BTRFS_CHUNK_TREE_OBJECTID 3ULL
24 * stores information about which areas of a given device are in use.
25 * one per device. The tree of tree roots points to the device tree
27 #define BTRFS_DEV_TREE_OBJECTID 4ULL
29 /* one per subvolume, storing files and directories */
30 #define BTRFS_FS_TREE_OBJECTID 5ULL
32 /* directory objectid inside the root tree */
33 #define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
35 /* holds checksums of all the data extents */
36 #define BTRFS_CSUM_TREE_OBJECTID 7ULL
38 /* holds quota configuration and tracking */
39 #define BTRFS_QUOTA_TREE_OBJECTID 8ULL
41 /* for storing items that use the BTRFS_UUID_KEY* types */
42 #define BTRFS_UUID_TREE_OBJECTID 9ULL
44 /* tracks free space in block groups. */
45 #define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
47 /* device stats in the device tree */
48 #define BTRFS_DEV_STATS_OBJECTID 0ULL
50 /* for storing balance parameters in the root tree */
51 #define BTRFS_BALANCE_OBJECTID -4ULL
53 /* orhpan objectid for tracking unlinked/truncated files */
54 #define BTRFS_ORPHAN_OBJECTID -5ULL
56 /* does write ahead logging to speed up fsyncs */
57 #define BTRFS_TREE_LOG_OBJECTID -6ULL
58 #define BTRFS_TREE_LOG_FIXUP_OBJECTID -7ULL
60 /* for space balancing */
61 #define BTRFS_TREE_RELOC_OBJECTID -8ULL
62 #define BTRFS_DATA_RELOC_TREE_OBJECTID -9ULL
65 * extent checksums all have this objectid
66 * this allows them to share the logging tree
69 #define BTRFS_EXTENT_CSUM_OBJECTID -10ULL
71 /* For storing free space cache */
72 #define BTRFS_FREE_SPACE_OBJECTID -11ULL
75 * The inode number assigned to the special inode for storing
78 #define BTRFS_FREE_INO_OBJECTID -12ULL
80 /* dummy objectid represents multiple objectids */
81 #define BTRFS_MULTIPLE_OBJECTIDS -255ULL
84 * All files have objectids in this range.
86 #define BTRFS_FIRST_FREE_OBJECTID 256ULL
87 #define BTRFS_LAST_FREE_OBJECTID -256ULL
88 #define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
92 * the device items go into the chunk tree. The key is in the form
93 * [ 1 BTRFS_DEV_ITEM_KEY device_id ]
95 #define BTRFS_DEV_ITEMS_OBJECTID 1ULL
97 #define BTRFS_BTREE_INODE_OBJECTID 1
99 #define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
101 #define BTRFS_DEV_REPLACE_DEVID 0ULL
104 * inode items have the data typically returned from stat and store other
105 * info about object characteristics. There is one for every file and dir in
108 #define BTRFS_INODE_ITEM_KEY 1
109 #define BTRFS_INODE_REF_KEY 12
110 #define BTRFS_INODE_EXTREF_KEY 13
111 #define BTRFS_XATTR_ITEM_KEY 24
112 #define BTRFS_ORPHAN_ITEM_KEY 48
113 /* reserve 2-15 close to the inode for later flexibility */
116 * dir items are the name -> inode pointers in a directory. There is one
117 * for every name in a directory.
119 #define BTRFS_DIR_LOG_ITEM_KEY 60
120 #define BTRFS_DIR_LOG_INDEX_KEY 72
121 #define BTRFS_DIR_ITEM_KEY 84
122 #define BTRFS_DIR_INDEX_KEY 96
124 * extent data is for file data
126 #define BTRFS_EXTENT_DATA_KEY 108
129 * extent csums are stored in a separate tree and hold csums for
130 * an entire extent on disk.
132 #define BTRFS_EXTENT_CSUM_KEY 128
135 * root items point to tree roots. They are typically in the root
136 * tree used by the super block to find all the other trees
138 #define BTRFS_ROOT_ITEM_KEY 132
141 * root backrefs tie subvols and snapshots to the directory entries that
144 #define BTRFS_ROOT_BACKREF_KEY 144
147 * root refs make a fast index for listing all of the snapshots and
148 * subvolumes referenced by a given root. They point directly to the
149 * directory item in the root that references the subvol
151 #define BTRFS_ROOT_REF_KEY 156
154 * extent items are in the extent map tree. These record which blocks
155 * are used, and how many references there are to each block
157 #define BTRFS_EXTENT_ITEM_KEY 168
160 * The same as the BTRFS_EXTENT_ITEM_KEY, except it's metadata we already know
161 * the length, so we save the level in key->offset instead of the length.
163 #define BTRFS_METADATA_ITEM_KEY 169
165 #define BTRFS_TREE_BLOCK_REF_KEY 176
167 #define BTRFS_EXTENT_DATA_REF_KEY 178
169 #define BTRFS_EXTENT_REF_V0_KEY 180
171 #define BTRFS_SHARED_BLOCK_REF_KEY 182
173 #define BTRFS_SHARED_DATA_REF_KEY 184
176 * block groups give us hints into the extent allocation trees. Which
177 * blocks are free etc etc
179 #define BTRFS_BLOCK_GROUP_ITEM_KEY 192
182 * Every block group is represented in the free space tree by a free space info
183 * item, which stores some accounting information. It is keyed on
184 * (block_group_start, FREE_SPACE_INFO, block_group_length).
186 #define BTRFS_FREE_SPACE_INFO_KEY 198
189 * A free space extent tracks an extent of space that is free in a block group.
190 * It is keyed on (start, FREE_SPACE_EXTENT, length).
192 #define BTRFS_FREE_SPACE_EXTENT_KEY 199
195 * When a block group becomes very fragmented, we convert it to use bitmaps
196 * instead of extents. A free space bitmap is keyed on
197 * (start, FREE_SPACE_BITMAP, length); the corresponding item is a bitmap with
198 * (length / sectorsize) bits.
200 #define BTRFS_FREE_SPACE_BITMAP_KEY 200
202 #define BTRFS_DEV_EXTENT_KEY 204
203 #define BTRFS_DEV_ITEM_KEY 216
204 #define BTRFS_CHUNK_ITEM_KEY 228
207 * Records the overall state of the qgroups.
208 * There's only one instance of this key present,
209 * (0, BTRFS_QGROUP_STATUS_KEY, 0)
211 #define BTRFS_QGROUP_STATUS_KEY 240
213 * Records the currently used space of the qgroup.
214 * One key per qgroup, (0, BTRFS_QGROUP_INFO_KEY, qgroupid).
216 #define BTRFS_QGROUP_INFO_KEY 242
218 * Contains the user configured limits for the qgroup.
219 * One key per qgroup, (0, BTRFS_QGROUP_LIMIT_KEY, qgroupid).
221 #define BTRFS_QGROUP_LIMIT_KEY 244
223 * Records the child-parent relationship of qgroups. For
224 * each relation, 2 keys are present:
225 * (childid, BTRFS_QGROUP_RELATION_KEY, parentid)
226 * (parentid, BTRFS_QGROUP_RELATION_KEY, childid)
228 #define BTRFS_QGROUP_RELATION_KEY 246
231 * Obsolete name, see BTRFS_TEMPORARY_ITEM_KEY.
233 #define BTRFS_BALANCE_ITEM_KEY 248
236 * The key type for tree items that are stored persistently, but do not need to
237 * exist for extended period of time. The items can exist in any tree.
239 * [subtype, BTRFS_TEMPORARY_ITEM_KEY, data]
243 * - balance status item
244 * (BTRFS_BALANCE_OBJECTID, BTRFS_TEMPORARY_ITEM_KEY, 0)
246 #define BTRFS_TEMPORARY_ITEM_KEY 248
249 * Obsolete name, see BTRFS_PERSISTENT_ITEM_KEY
251 #define BTRFS_DEV_STATS_KEY 249
254 * The key type for tree items that are stored persistently and usually exist
255 * for a long period, eg. filesystem lifetime. The item kinds can be status
256 * information, stats or preference values. The item can exist in any tree.
258 * [subtype, BTRFS_PERSISTENT_ITEM_KEY, data]
262 * - device statistics, store IO stats in the device tree, one key for all
264 * (BTRFS_DEV_STATS_OBJECTID, BTRFS_DEV_STATS_KEY, 0)
266 #define BTRFS_PERSISTENT_ITEM_KEY 249
269 * Persistantly stores the device replace state in the device tree.
270 * The key is built like this: (0, BTRFS_DEV_REPLACE_KEY, 0).
272 #define BTRFS_DEV_REPLACE_KEY 250
275 * Stores items that allow to quickly map UUIDs to something else.
276 * These items are part of the filesystem UUID tree.
277 * The key is built like this:
278 * (UUID_upper_64_bits, BTRFS_UUID_KEY*, UUID_lower_64_bits).
280 #if BTRFS_UUID_SIZE != 16
281 #error "UUID items require BTRFS_UUID_SIZE == 16!"
283 #define BTRFS_UUID_KEY_SUBVOL 251 /* for UUIDs assigned to subvols */
284 #define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252 /* for UUIDs assigned to
285 * received subvols */
288 * string items are for debugging. They just store a short string of
291 #define BTRFS_STRING_ITEM_KEY 253
295 /* 32 bytes in various csum fields */
296 #define BTRFS_CSUM_SIZE 32
299 #define BTRFS_CSUM_TYPE_CRC32 0
302 * flags definitions for directory entry item type
305 * struct btrfs_dir_item.type
307 #define BTRFS_FT_UNKNOWN 0
308 #define BTRFS_FT_REG_FILE 1
309 #define BTRFS_FT_DIR 2
310 #define BTRFS_FT_CHRDEV 3
311 #define BTRFS_FT_BLKDEV 4
312 #define BTRFS_FT_FIFO 5
313 #define BTRFS_FT_SOCK 6
314 #define BTRFS_FT_SYMLINK 7
315 #define BTRFS_FT_XATTR 8
316 #define BTRFS_FT_MAX 9
319 * The key defines the order in the tree, and so it also defines (optimal)
322 * objectid corresponds to the inode number.
324 * type tells us things about the object, and is a kind of stream selector.
325 * so for a given inode, keys with type of 1 might refer to the inode data,
326 * type of 2 may point to file data in the btree and type == 3 may point to
329 * offset is the starting byte offset for this key in the stream.
331 * btrfs_disk_key is in disk byte order. struct btrfs_key is always
332 * in cpu native order. Otherwise they are identical and their sizes
333 * should be the same (ie both packed)
335 struct btrfs_disk_key
{
339 } __attribute__ ((__packed__
));
345 } __attribute__ ((__packed__
));
347 struct btrfs_dev_item
{
348 /* the internal btrfs device id */
351 /* size of the device */
357 /* optimal io alignment for this device */
360 /* optimal io width for this device */
363 /* minimal io size for this device */
366 /* type and info about this device */
369 /* expected generation for this device */
373 * starting byte of this partition on the device,
374 * to allow for stripe alignment in the future
378 /* grouping information for allocation decisions */
381 /* seek speed 0-100 where 100 is fastest */
384 /* bandwidth 0-100 where 100 is fastest */
387 /* btrfs generated uuid for this device */
388 __u8 uuid
[BTRFS_UUID_SIZE
];
390 /* uuid of FS who owns this device */
391 __u8 fsid
[BTRFS_UUID_SIZE
];
392 } __attribute__ ((__packed__
));
394 struct btrfs_stripe
{
397 __u8 dev_uuid
[BTRFS_UUID_SIZE
];
398 } __attribute__ ((__packed__
));
401 /* size of this chunk in bytes */
404 /* objectid of the root referencing this chunk */
410 /* optimal io alignment for this chunk */
413 /* optimal io width for this chunk */
416 /* minimal io size for this chunk */
419 /* 2^16 stripes is quite a lot, a second limit is the size of a single
424 /* sub stripes only matter for raid10 */
426 struct btrfs_stripe stripe
;
427 /* additional stripes go here */
428 } __attribute__ ((__packed__
));
430 #define BTRFS_FREE_SPACE_EXTENT 1
431 #define BTRFS_FREE_SPACE_BITMAP 2
433 struct btrfs_free_space_entry
{
437 } __attribute__ ((__packed__
));
439 struct btrfs_free_space_header
{
440 struct btrfs_disk_key location
;
444 } __attribute__ ((__packed__
));
446 #define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
447 #define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
449 /* Super block flags */
450 /* Errors detected */
451 #define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
453 #define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
454 #define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
458 * items in the extent btree are used to record the objectid of the
459 * owner of the block and the number of references
462 struct btrfs_extent_item
{
466 } __attribute__ ((__packed__
));
468 struct btrfs_extent_item_v0
{
470 } __attribute__ ((__packed__
));
473 #define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
474 #define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
476 /* following flags only apply to tree blocks */
478 /* use full backrefs for extent pointers in the block */
479 #define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
482 * this flag is only used internally by scrub and may be changed at any time
483 * it is only declared here to avoid collisions
485 #define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
487 struct btrfs_tree_block_info
{
488 struct btrfs_disk_key key
;
490 } __attribute__ ((__packed__
));
492 struct btrfs_extent_data_ref
{
497 } __attribute__ ((__packed__
));
499 struct btrfs_shared_data_ref
{
501 } __attribute__ ((__packed__
));
503 struct btrfs_extent_inline_ref
{
506 } __attribute__ ((__packed__
));
508 /* old style backrefs item */
509 struct btrfs_extent_ref_v0
{
514 } __attribute__ ((__packed__
));
517 /* dev extents record free space on individual devices. The owner
518 * field points back to the chunk allocation mapping tree that allocated
519 * the extent. The chunk tree uuid field is a way to double check the owner
521 struct btrfs_dev_extent
{
523 __le64 chunk_objectid
;
526 __u8 chunk_tree_uuid
[BTRFS_UUID_SIZE
];
527 } __attribute__ ((__packed__
));
529 struct btrfs_inode_ref
{
533 } __attribute__ ((__packed__
));
535 struct btrfs_inode_extref
{
536 __le64 parent_objectid
;
541 } __attribute__ ((__packed__
));
543 struct btrfs_timespec
{
546 } __attribute__ ((__packed__
));
548 struct btrfs_inode_item
{
549 /* nfs style generation number */
551 /* transid that last touched this inode */
563 /* modification sequence number for NFS */
567 * a little future expansion, for more than this we can
568 * just grow the inode item and version it
571 struct btrfs_timespec atime
;
572 struct btrfs_timespec ctime
;
573 struct btrfs_timespec mtime
;
574 struct btrfs_timespec otime
;
575 } __attribute__ ((__packed__
));
577 struct btrfs_dir_log_item
{
579 } __attribute__ ((__packed__
));
581 struct btrfs_dir_item
{
582 struct btrfs_disk_key location
;
587 } __attribute__ ((__packed__
));
589 #define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
592 * Internal in-memory flag that a subvolume has been marked for deletion but
593 * still visible as a directory
595 #define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
597 struct btrfs_root_item
{
598 struct btrfs_inode_item inode
;
604 __le64 last_snapshot
;
607 struct btrfs_disk_key drop_progress
;
612 * The following fields appear after subvol_uuids+subvol_times
617 * This generation number is used to test if the new fields are valid
618 * and up to date while reading the root item. Every time the root item
619 * is written out, the "generation" field is copied into this field. If
620 * anyone ever mounted the fs with an older kernel, we will have
621 * mismatching generation values here and thus must invalidate the
622 * new fields. See btrfs_update_root and btrfs_find_last_root for
624 * the offset of generation_v2 is also used as the start for the memset
625 * when invalidating the fields.
627 __le64 generation_v2
;
628 __u8 uuid
[BTRFS_UUID_SIZE
];
629 __u8 parent_uuid
[BTRFS_UUID_SIZE
];
630 __u8 received_uuid
[BTRFS_UUID_SIZE
];
631 __le64 ctransid
; /* updated when an inode changes */
632 __le64 otransid
; /* trans when created */
633 __le64 stransid
; /* trans when sent. non-zero for received subvol */
634 __le64 rtransid
; /* trans when received. non-zero for received subvol */
635 struct btrfs_timespec ctime
;
636 struct btrfs_timespec otime
;
637 struct btrfs_timespec stime
;
638 struct btrfs_timespec rtime
;
639 __le64 reserved
[8]; /* for future */
640 } __attribute__ ((__packed__
));
643 * this is used for both forward and backward root refs
645 struct btrfs_root_ref
{
649 } __attribute__ ((__packed__
));
651 struct btrfs_disk_balance_args
{
653 * profiles to operate on, single is denoted by
654 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
660 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
661 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
674 /* devid subset filter [pstart..pend) */
678 /* btrfs virtual address space subset filter [vstart..vend) */
683 * profile to convert to, single is denoted by
684 * BTRFS_AVAIL_ALLOC_BIT_SINGLE
688 /* BTRFS_BALANCE_ARGS_* */
692 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
693 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
705 * Process chunks that cross stripes_min..stripes_max devices,
706 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
712 } __attribute__ ((__packed__
));
715 * store balance parameters to disk so that balance can be properly
716 * resumed after crash or unmount
718 struct btrfs_balance_item
{
719 /* BTRFS_BALANCE_* */
722 struct btrfs_disk_balance_args data
;
723 struct btrfs_disk_balance_args meta
;
724 struct btrfs_disk_balance_args sys
;
727 } __attribute__ ((__packed__
));
729 #define BTRFS_FILE_EXTENT_INLINE 0
730 #define BTRFS_FILE_EXTENT_REG 1
731 #define BTRFS_FILE_EXTENT_PREALLOC 2
733 struct btrfs_file_extent_item
{
735 * transaction id that created this extent
739 * max number of bytes to hold this extent in ram
740 * when we split a compressed extent we can't know how big
741 * each of the resulting pieces will be. So, this is
742 * an upper limit on the size of the extent in ram instead of
748 * 32 bits for the various ways we might encode the data,
749 * including compression and encryption. If any of these
750 * are set to something a given disk format doesn't understand
751 * it is treated like an incompat flag for reading and writing,
756 __le16 other_encoding
; /* spare for later use */
758 /* are we inline data or a real extent? */
762 * disk space consumed by the extent, checksum blocks are included
765 * At this offset in the structure, the inline extent data start.
768 __le64 disk_num_bytes
;
770 * the logical offset in file blocks (no csums)
771 * this extent record is for. This allows a file extent to point
772 * into the middle of an existing extent on disk, sharing it
773 * between two snapshots (useful if some bytes in the middle of the
774 * extent have changed
778 * the logical number of file blocks (no csums included). This
779 * always reflects the size uncompressed and without encoding.
783 } __attribute__ ((__packed__
));
785 struct btrfs_csum_item
{
787 } __attribute__ ((__packed__
));
789 struct btrfs_dev_stats_item
{
791 * grow this item struct at the end for future enhancements and keep
792 * the existing values unchanged
794 __le64 values
[BTRFS_DEV_STAT_VALUES_MAX
];
795 } __attribute__ ((__packed__
));
797 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
798 #define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
799 #define BTRFS_DEV_REPLACE_ITEM_STATE_NEVER_STARTED 0
800 #define BTRFS_DEV_REPLACE_ITEM_STATE_STARTED 1
801 #define BTRFS_DEV_REPLACE_ITEM_STATE_SUSPENDED 2
802 #define BTRFS_DEV_REPLACE_ITEM_STATE_FINISHED 3
803 #define BTRFS_DEV_REPLACE_ITEM_STATE_CANCELED 4
805 struct btrfs_dev_replace_item
{
807 * grow this item struct at the end for future enhancements and keep
808 * the existing values unchanged
813 __le64 cont_reading_from_srcdev_mode
;
815 __le64 replace_state
;
818 __le64 num_write_errors
;
819 __le64 num_uncorrectable_read_errors
;
820 } __attribute__ ((__packed__
));
822 /* different types of block groups (and chunks) */
823 #define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
824 #define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
825 #define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
826 #define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
827 #define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
828 #define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
829 #define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
830 #define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
831 #define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
832 #define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | \
833 BTRFS_SPACE_INFO_GLOBAL_RSV)
835 enum btrfs_raid_types
{
846 #define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | \
847 BTRFS_BLOCK_GROUP_SYSTEM | \
848 BTRFS_BLOCK_GROUP_METADATA)
850 #define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | \
851 BTRFS_BLOCK_GROUP_RAID1 | \
852 BTRFS_BLOCK_GROUP_RAID5 | \
853 BTRFS_BLOCK_GROUP_RAID6 | \
854 BTRFS_BLOCK_GROUP_DUP | \
855 BTRFS_BLOCK_GROUP_RAID10)
856 #define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | \
857 BTRFS_BLOCK_GROUP_RAID6)
860 * We need a bit for restriper to be able to tell when chunks of type
861 * SINGLE are available. This "extended" profile format is used in
862 * fs_info->avail_*_alloc_bits (in-memory) and balance item fields
863 * (on-disk). The corresponding on-disk bit in chunk.type is reserved
864 * to avoid remappings between two formats in future.
866 #define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
869 * A fake block group type that is used to communicate global block reserve
870 * size to userspace via the SPACE_INFO ioctl.
872 #define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
874 #define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | \
875 BTRFS_AVAIL_ALLOC_BIT_SINGLE)
877 static inline __u64
chunk_to_extended(__u64 flags
)
879 if ((flags
& BTRFS_BLOCK_GROUP_PROFILE_MASK
) == 0)
880 flags
|= BTRFS_AVAIL_ALLOC_BIT_SINGLE
;
884 static inline __u64
extended_to_chunk(__u64 flags
)
886 return flags
& ~BTRFS_AVAIL_ALLOC_BIT_SINGLE
;
889 struct btrfs_block_group_item
{
891 __le64 chunk_objectid
;
893 } __attribute__ ((__packed__
));
895 struct btrfs_free_space_info
{
898 } __attribute__ ((__packed__
));
900 #define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
902 #define BTRFS_QGROUP_LEVEL_SHIFT 48
903 static inline __u64
btrfs_qgroup_level(__u64 qgroupid
)
905 return qgroupid
>> BTRFS_QGROUP_LEVEL_SHIFT
;
909 * is subvolume quota turned on?
911 #define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
913 * RESCAN is set during the initialization phase
915 #define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
917 * Some qgroup entries are known to be out of date,
918 * either because the configuration has changed in a way that
919 * makes a rescan necessary, or because the fs has been mounted
920 * with a non-qgroup-aware version.
921 * Turning qouta off and on again makes it inconsistent, too.
923 #define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
925 #define BTRFS_QGROUP_STATUS_VERSION 1
927 struct btrfs_qgroup_status_item
{
930 * the generation is updated during every commit. As older
931 * versions of btrfs are not aware of qgroups, it will be
932 * possible to detect inconsistencies by checking the
933 * generation on mount time
937 /* flag definitions see above */
941 * only used during scanning to record the progress
942 * of the scan. It contains a logical address
945 } __attribute__ ((__packed__
));
947 struct btrfs_qgroup_info_item
{
953 } __attribute__ ((__packed__
));
955 struct btrfs_qgroup_limit_item
{
957 * only updated when any of the other values change
964 } __attribute__ ((__packed__
));
966 #endif /* _BTRFS_CTREE_H_ */