blob: 57579e4d003a6455ac616037189d1d78f984c1e7 [file] [log] [blame]
Elliott Hughes180edef2023-11-02 00:08:05 +00001/*
2 * This file is auto-generated. Modifications will be lost.
3 *
4 * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
5 * for more information.
6 */
Christopher Ferris106b3a82016-08-24 12:15:38 -07007#ifndef _BTRFS_CTREE_H_
8#define _BTRFS_CTREE_H_
Christopher Ferris525ce912017-07-26 13:12:53 -07009#include <linux/btrfs.h>
10#include <linux/types.h>
Christopher Ferris32ff3f82020-12-14 13:10:04 -080011#include <stddef.h>
Christopher Ferris8b7fdc92023-02-21 13:36:32 -080012#define BTRFS_MAGIC 0x4D5F53665248425FULL
13#define BTRFS_MAX_LEVEL 8
14#define BTRFS_NAME_LEN 255
15#define BTRFS_LINK_MAX 65535U
Christopher Ferris106b3a82016-08-24 12:15:38 -070016#define BTRFS_ROOT_TREE_OBJECTID 1ULL
17#define BTRFS_EXTENT_TREE_OBJECTID 2ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070018#define BTRFS_CHUNK_TREE_OBJECTID 3ULL
19#define BTRFS_DEV_TREE_OBJECTID 4ULL
20#define BTRFS_FS_TREE_OBJECTID 5ULL
21#define BTRFS_ROOT_TREE_DIR_OBJECTID 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070022#define BTRFS_CSUM_TREE_OBJECTID 7ULL
23#define BTRFS_QUOTA_TREE_OBJECTID 8ULL
24#define BTRFS_UUID_TREE_OBJECTID 9ULL
25#define BTRFS_FREE_SPACE_TREE_OBJECTID 10ULL
Christopher Ferris10a76e62022-06-08 13:31:52 -070026#define BTRFS_BLOCK_GROUP_TREE_OBJECTID 11ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070027#define BTRFS_DEV_STATS_OBJECTID 0ULL
28#define BTRFS_BALANCE_OBJECTID - 4ULL
29#define BTRFS_ORPHAN_OBJECTID - 5ULL
30#define BTRFS_TREE_LOG_OBJECTID - 6ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070031#define BTRFS_TREE_LOG_FIXUP_OBJECTID - 7ULL
32#define BTRFS_TREE_RELOC_OBJECTID - 8ULL
33#define BTRFS_DATA_RELOC_TREE_OBJECTID - 9ULL
34#define BTRFS_EXTENT_CSUM_OBJECTID - 10ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070035#define BTRFS_FREE_SPACE_OBJECTID - 11ULL
36#define BTRFS_FREE_INO_OBJECTID - 12ULL
37#define BTRFS_MULTIPLE_OBJECTIDS - 255ULL
38#define BTRFS_FIRST_FREE_OBJECTID 256ULL
Christopher Ferris106b3a82016-08-24 12:15:38 -070039#define BTRFS_LAST_FREE_OBJECTID - 256ULL
40#define BTRFS_FIRST_CHUNK_TREE_OBJECTID 256ULL
41#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
42#define BTRFS_BTREE_INODE_OBJECTID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -070043#define BTRFS_EMPTY_SUBVOL_DIR_OBJECTID 2
44#define BTRFS_DEV_REPLACE_DEVID 0ULL
45#define BTRFS_INODE_ITEM_KEY 1
46#define BTRFS_INODE_REF_KEY 12
Christopher Ferris106b3a82016-08-24 12:15:38 -070047#define BTRFS_INODE_EXTREF_KEY 13
48#define BTRFS_XATTR_ITEM_KEY 24
Christopher Ferris2abfa9e2021-11-01 16:26:06 -070049#define BTRFS_VERITY_DESC_ITEM_KEY 36
50#define BTRFS_VERITY_MERKLE_ITEM_KEY 37
Christopher Ferris106b3a82016-08-24 12:15:38 -070051#define BTRFS_ORPHAN_ITEM_KEY 48
52#define BTRFS_DIR_LOG_ITEM_KEY 60
Christopher Ferris106b3a82016-08-24 12:15:38 -070053#define BTRFS_DIR_LOG_INDEX_KEY 72
54#define BTRFS_DIR_ITEM_KEY 84
55#define BTRFS_DIR_INDEX_KEY 96
56#define BTRFS_EXTENT_DATA_KEY 108
Christopher Ferris106b3a82016-08-24 12:15:38 -070057#define BTRFS_EXTENT_CSUM_KEY 128
58#define BTRFS_ROOT_ITEM_KEY 132
59#define BTRFS_ROOT_BACKREF_KEY 144
60#define BTRFS_ROOT_REF_KEY 156
Christopher Ferris106b3a82016-08-24 12:15:38 -070061#define BTRFS_EXTENT_ITEM_KEY 168
62#define BTRFS_METADATA_ITEM_KEY 169
63#define BTRFS_TREE_BLOCK_REF_KEY 176
64#define BTRFS_EXTENT_DATA_REF_KEY 178
Christopher Ferris106b3a82016-08-24 12:15:38 -070065#define BTRFS_SHARED_BLOCK_REF_KEY 182
66#define BTRFS_SHARED_DATA_REF_KEY 184
67#define BTRFS_BLOCK_GROUP_ITEM_KEY 192
Christopher Ferris106b3a82016-08-24 12:15:38 -070068#define BTRFS_FREE_SPACE_INFO_KEY 198
69#define BTRFS_FREE_SPACE_EXTENT_KEY 199
70#define BTRFS_FREE_SPACE_BITMAP_KEY 200
71#define BTRFS_DEV_EXTENT_KEY 204
Christopher Ferris106b3a82016-08-24 12:15:38 -070072#define BTRFS_DEV_ITEM_KEY 216
73#define BTRFS_CHUNK_ITEM_KEY 228
74#define BTRFS_QGROUP_STATUS_KEY 240
75#define BTRFS_QGROUP_INFO_KEY 242
Christopher Ferris106b3a82016-08-24 12:15:38 -070076#define BTRFS_QGROUP_LIMIT_KEY 244
77#define BTRFS_QGROUP_RELATION_KEY 246
78#define BTRFS_BALANCE_ITEM_KEY 248
79#define BTRFS_TEMPORARY_ITEM_KEY 248
Christopher Ferris106b3a82016-08-24 12:15:38 -070080#define BTRFS_DEV_STATS_KEY 249
81#define BTRFS_PERSISTENT_ITEM_KEY 249
82#define BTRFS_DEV_REPLACE_KEY 250
83#if BTRFS_UUID_SIZE != 16
Christopher Ferris106b3a82016-08-24 12:15:38 -070084#error "UUID items require BTRFS_UUID_SIZE == 16!"
85#endif
86#define BTRFS_UUID_KEY_SUBVOL 251
87#define BTRFS_UUID_KEY_RECEIVED_SUBVOL 252
Christopher Ferris106b3a82016-08-24 12:15:38 -070088#define BTRFS_STRING_ITEM_KEY 253
Christopher Ferris05667cd2021-02-16 16:01:34 -080089#define BTRFS_MAX_METADATA_BLOCKSIZE 65536
Christopher Ferris106b3a82016-08-24 12:15:38 -070090#define BTRFS_CSUM_SIZE 32
Christopher Ferris9584fa42019-12-09 15:36:13 -080091enum btrfs_csum_type {
92 BTRFS_CSUM_TYPE_CRC32 = 0,
Christopher Ferrisd32ca142020-02-04 16:16:51 -080093 BTRFS_CSUM_TYPE_XXHASH = 1,
94 BTRFS_CSUM_TYPE_SHA256 = 2,
95 BTRFS_CSUM_TYPE_BLAKE2 = 3,
Christopher Ferris9584fa42019-12-09 15:36:13 -080096};
Christopher Ferris106b3a82016-08-24 12:15:38 -070097#define BTRFS_FT_UNKNOWN 0
Christopher Ferris106b3a82016-08-24 12:15:38 -070098#define BTRFS_FT_REG_FILE 1
99#define BTRFS_FT_DIR 2
100#define BTRFS_FT_CHRDEV 3
101#define BTRFS_FT_BLKDEV 4
Christopher Ferris106b3a82016-08-24 12:15:38 -0700102#define BTRFS_FT_FIFO 5
103#define BTRFS_FT_SOCK 6
104#define BTRFS_FT_SYMLINK 7
105#define BTRFS_FT_XATTR 8
Christopher Ferris106b3a82016-08-24 12:15:38 -0700106#define BTRFS_FT_MAX 9
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800107#define BTRFS_FT_ENCRYPTED 0x80
108#define BTRFS_INODE_NODATASUM (1U << 0)
109#define BTRFS_INODE_NODATACOW (1U << 1)
110#define BTRFS_INODE_READONLY (1U << 2)
111#define BTRFS_INODE_NOCOMPRESS (1U << 3)
112#define BTRFS_INODE_PREALLOC (1U << 4)
113#define BTRFS_INODE_SYNC (1U << 5)
114#define BTRFS_INODE_IMMUTABLE (1U << 6)
115#define BTRFS_INODE_APPEND (1U << 7)
116#define BTRFS_INODE_NODUMP (1U << 8)
117#define BTRFS_INODE_NOATIME (1U << 9)
118#define BTRFS_INODE_DIRSYNC (1U << 10)
119#define BTRFS_INODE_COMPRESS (1U << 11)
120#define BTRFS_INODE_ROOT_ITEM_INIT (1U << 31)
121#define BTRFS_INODE_FLAG_MASK (BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW | BTRFS_INODE_READONLY | BTRFS_INODE_NOCOMPRESS | BTRFS_INODE_PREALLOC | BTRFS_INODE_SYNC | BTRFS_INODE_IMMUTABLE | BTRFS_INODE_APPEND | BTRFS_INODE_NODUMP | BTRFS_INODE_NOATIME | BTRFS_INODE_DIRSYNC | BTRFS_INODE_COMPRESS | BTRFS_INODE_ROOT_ITEM_INIT)
122#define BTRFS_INODE_RO_VERITY (1U << 0)
123#define BTRFS_INODE_RO_FLAG_MASK (BTRFS_INODE_RO_VERITY)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700124struct btrfs_disk_key {
125 __le64 objectid;
126 __u8 type;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700127 __le64 offset;
128} __attribute__((__packed__));
129struct btrfs_key {
130 __u64 objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700131 __u8 type;
132 __u64 offset;
133} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800134struct btrfs_header {
135 __u8 csum[BTRFS_CSUM_SIZE];
136 __u8 fsid[BTRFS_FSID_SIZE];
137 __le64 bytenr;
138 __le64 flags;
139 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
140 __le64 generation;
141 __le64 owner;
142 __le32 nritems;
143 __u8 level;
144} __attribute__((__packed__));
145#define BTRFS_SYSTEM_CHUNK_ARRAY_SIZE 2048
146#define BTRFS_NUM_BACKUP_ROOTS 4
147struct btrfs_root_backup {
148 __le64 tree_root;
149 __le64 tree_root_gen;
150 __le64 chunk_root;
151 __le64 chunk_root_gen;
152 __le64 extent_root;
153 __le64 extent_root_gen;
154 __le64 fs_root;
155 __le64 fs_root_gen;
156 __le64 dev_root;
157 __le64 dev_root_gen;
158 __le64 csum_root;
159 __le64 csum_root_gen;
160 __le64 total_bytes;
161 __le64 bytes_used;
162 __le64 num_devices;
163 __le64 unused_64[4];
164 __u8 tree_root_level;
165 __u8 chunk_root_level;
166 __u8 extent_root_level;
167 __u8 fs_root_level;
168 __u8 dev_root_level;
169 __u8 csum_root_level;
170 __u8 unused_8[10];
171} __attribute__((__packed__));
172struct btrfs_item {
173 struct btrfs_disk_key key;
174 __le32 offset;
175 __le32 size;
176} __attribute__((__packed__));
177struct btrfs_leaf {
178 struct btrfs_header header;
179 struct btrfs_item items[];
180} __attribute__((__packed__));
181struct btrfs_key_ptr {
182 struct btrfs_disk_key key;
183 __le64 blockptr;
184 __le64 generation;
185} __attribute__((__packed__));
186struct btrfs_node {
187 struct btrfs_header header;
188 struct btrfs_key_ptr ptrs[];
189} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700190struct btrfs_dev_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700191 __le64 devid;
192 __le64 total_bytes;
193 __le64 bytes_used;
194 __le32 io_align;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700195 __le32 io_width;
196 __le32 sector_size;
197 __le64 type;
198 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700199 __le64 start_offset;
200 __le32 dev_group;
201 __u8 seek_speed;
202 __u8 bandwidth;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700203 __u8 uuid[BTRFS_UUID_SIZE];
204 __u8 fsid[BTRFS_UUID_SIZE];
205} __attribute__((__packed__));
206struct btrfs_stripe {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700207 __le64 devid;
208 __le64 offset;
209 __u8 dev_uuid[BTRFS_UUID_SIZE];
210} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700211struct btrfs_chunk {
212 __le64 length;
213 __le64 owner;
214 __le64 stripe_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700215 __le64 type;
216 __le32 io_align;
217 __le32 io_width;
218 __le32 sector_size;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700219 __le16 num_stripes;
220 __le16 sub_stripes;
221 struct btrfs_stripe stripe;
222} __attribute__((__packed__));
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800223struct btrfs_super_block {
224 __u8 csum[BTRFS_CSUM_SIZE];
225 __u8 fsid[BTRFS_FSID_SIZE];
226 __le64 bytenr;
227 __le64 flags;
228 __le64 magic;
229 __le64 generation;
230 __le64 root;
231 __le64 chunk_root;
232 __le64 log_root;
233 __le64 __unused_log_root_transid;
234 __le64 total_bytes;
235 __le64 bytes_used;
236 __le64 root_dir_objectid;
237 __le64 num_devices;
238 __le32 sectorsize;
239 __le32 nodesize;
240 __le32 __unused_leafsize;
241 __le32 stripesize;
242 __le32 sys_chunk_array_size;
243 __le64 chunk_root_generation;
244 __le64 compat_flags;
245 __le64 compat_ro_flags;
246 __le64 incompat_flags;
247 __le16 csum_type;
248 __u8 root_level;
249 __u8 chunk_root_level;
250 __u8 log_root_level;
251 struct btrfs_dev_item dev_item;
252 char label[BTRFS_LABEL_SIZE];
253 __le64 cache_generation;
254 __le64 uuid_tree_generation;
255 __u8 metadata_uuid[BTRFS_FSID_SIZE];
256 __u64 nr_global_roots;
257 __le64 reserved[27];
258 __u8 sys_chunk_array[BTRFS_SYSTEM_CHUNK_ARRAY_SIZE];
259 struct btrfs_root_backup super_roots[BTRFS_NUM_BACKUP_ROOTS];
260 __u8 padding[565];
261} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700262#define BTRFS_FREE_SPACE_EXTENT 1
263#define BTRFS_FREE_SPACE_BITMAP 2
264struct btrfs_free_space_entry {
265 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700266 __le64 bytes;
267 __u8 type;
268} __attribute__((__packed__));
269struct btrfs_free_space_header {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700270 struct btrfs_disk_key location;
271 __le64 generation;
272 __le64 num_entries;
273 __le64 num_bitmaps;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700274} __attribute__((__packed__));
275#define BTRFS_HEADER_FLAG_WRITTEN (1ULL << 0)
276#define BTRFS_HEADER_FLAG_RELOC (1ULL << 1)
277#define BTRFS_SUPER_FLAG_ERROR (1ULL << 2)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700278#define BTRFS_SUPER_FLAG_SEEDING (1ULL << 32)
279#define BTRFS_SUPER_FLAG_METADUMP (1ULL << 33)
Christopher Ferris76a1d452018-06-27 14:12:29 -0700280#define BTRFS_SUPER_FLAG_METADUMP_V2 (1ULL << 34)
281#define BTRFS_SUPER_FLAG_CHANGING_FSID (1ULL << 35)
Christopher Ferrisd842e432019-03-07 10:21:59 -0800282#define BTRFS_SUPER_FLAG_CHANGING_FSID_V2 (1ULL << 36)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700283struct btrfs_extent_item {
284 __le64 refs;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700285 __le64 generation;
286 __le64 flags;
287} __attribute__((__packed__));
288struct btrfs_extent_item_v0 {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700289 __le32 refs;
290} __attribute__((__packed__));
291#define BTRFS_EXTENT_FLAG_DATA (1ULL << 0)
292#define BTRFS_EXTENT_FLAG_TREE_BLOCK (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700293#define BTRFS_BLOCK_FLAG_FULL_BACKREF (1ULL << 8)
Christopher Ferris8b7fdc92023-02-21 13:36:32 -0800294#define BTRFS_BACKREF_REV_MAX 256
295#define BTRFS_BACKREF_REV_SHIFT 56
296#define BTRFS_BACKREF_REV_MASK (((u64) BTRFS_BACKREF_REV_MAX - 1) << BTRFS_BACKREF_REV_SHIFT)
297#define BTRFS_OLD_BACKREF_REV 0
298#define BTRFS_MIXED_BACKREF_REV 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700299#define BTRFS_EXTENT_FLAG_SUPER (1ULL << 48)
300struct btrfs_tree_block_info {
301 struct btrfs_disk_key key;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700302 __u8 level;
303} __attribute__((__packed__));
304struct btrfs_extent_data_ref {
305 __le64 root;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700306 __le64 objectid;
307 __le64 offset;
308 __le32 count;
309} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700310struct btrfs_shared_data_ref {
311 __le32 count;
312} __attribute__((__packed__));
313struct btrfs_extent_inline_ref {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700314 __u8 type;
315 __le64 offset;
316} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700317struct btrfs_dev_extent {
318 __le64 chunk_tree;
319 __le64 chunk_objectid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700320 __le64 chunk_offset;
321 __le64 length;
322 __u8 chunk_tree_uuid[BTRFS_UUID_SIZE];
323} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700324struct btrfs_inode_ref {
325 __le64 index;
326 __le16 name_len;
327} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700328struct btrfs_inode_extref {
329 __le64 parent_objectid;
330 __le64 index;
331 __le16 name_len;
Christopher Ferris7447a1c2022-10-04 18:24:44 -0700332 __u8 name[];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700333} __attribute__((__packed__));
334struct btrfs_timespec {
335 __le64 sec;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700336 __le32 nsec;
337} __attribute__((__packed__));
338struct btrfs_inode_item {
339 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700340 __le64 transid;
341 __le64 size;
342 __le64 nbytes;
343 __le64 block_group;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700344 __le32 nlink;
345 __le32 uid;
346 __le32 gid;
347 __le32 mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700348 __le64 rdev;
349 __le64 flags;
350 __le64 sequence;
351 __le64 reserved[4];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700352 struct btrfs_timespec atime;
353 struct btrfs_timespec ctime;
354 struct btrfs_timespec mtime;
355 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700356} __attribute__((__packed__));
357struct btrfs_dir_log_item {
358 __le64 end;
359} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700360struct btrfs_dir_item {
361 struct btrfs_disk_key location;
362 __le64 transid;
363 __le16 data_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700364 __le16 name_len;
365 __u8 type;
366} __attribute__((__packed__));
367#define BTRFS_ROOT_SUBVOL_RDONLY (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700368#define BTRFS_ROOT_SUBVOL_DEAD (1ULL << 48)
369struct btrfs_root_item {
370 struct btrfs_inode_item inode;
371 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700372 __le64 root_dirid;
373 __le64 bytenr;
374 __le64 byte_limit;
375 __le64 bytes_used;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700376 __le64 last_snapshot;
377 __le64 flags;
378 __le32 refs;
379 struct btrfs_disk_key drop_progress;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700380 __u8 drop_level;
381 __u8 level;
382 __le64 generation_v2;
383 __u8 uuid[BTRFS_UUID_SIZE];
Christopher Ferris106b3a82016-08-24 12:15:38 -0700384 __u8 parent_uuid[BTRFS_UUID_SIZE];
385 __u8 received_uuid[BTRFS_UUID_SIZE];
386 __le64 ctransid;
387 __le64 otransid;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700388 __le64 stransid;
389 __le64 rtransid;
390 struct btrfs_timespec ctime;
391 struct btrfs_timespec otime;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700392 struct btrfs_timespec stime;
393 struct btrfs_timespec rtime;
394 __le64 reserved[8];
395} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700396struct btrfs_root_ref {
397 __le64 dirid;
398 __le64 sequence;
399 __le16 name_len;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700400} __attribute__((__packed__));
401struct btrfs_disk_balance_args {
402 __le64 profiles;
403 union {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700404 __le64 usage;
405 struct {
406 __le32 usage_min;
407 __le32 usage_max;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700408 };
409 };
410 __le64 devid;
411 __le64 pstart;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700412 __le64 pend;
413 __le64 vstart;
414 __le64 vend;
415 __le64 target;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700416 __le64 flags;
417 union {
418 __le64 limit;
419 struct {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700420 __le32 limit_min;
421 __le32 limit_max;
422 };
423 };
Christopher Ferris106b3a82016-08-24 12:15:38 -0700424 __le32 stripes_min;
425 __le32 stripes_max;
426 __le64 unused[6];
427} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700428struct btrfs_balance_item {
429 __le64 flags;
430 struct btrfs_disk_balance_args data;
431 struct btrfs_disk_balance_args meta;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700432 struct btrfs_disk_balance_args sys;
433 __le64 unused[4];
434} __attribute__((__packed__));
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800435enum {
436 BTRFS_FILE_EXTENT_INLINE = 0,
437 BTRFS_FILE_EXTENT_REG = 1,
438 BTRFS_FILE_EXTENT_PREALLOC = 2,
439 BTRFS_NR_FILE_EXTENT_TYPES = 3,
440};
Christopher Ferris106b3a82016-08-24 12:15:38 -0700441struct btrfs_file_extent_item {
442 __le64 generation;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700443 __le64 ram_bytes;
444 __u8 compression;
445 __u8 encryption;
446 __le16 other_encoding;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700447 __u8 type;
448 __le64 disk_bytenr;
449 __le64 disk_num_bytes;
450 __le64 offset;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700451 __le64 num_bytes;
452} __attribute__((__packed__));
453struct btrfs_csum_item {
454 __u8 csum;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700455} __attribute__((__packed__));
456struct btrfs_dev_stats_item {
457 __le64 values[BTRFS_DEV_STAT_VALUES_MAX];
458} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700459#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
460#define BTRFS_DEV_REPLACE_ITEM_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
Christopher Ferris106b3a82016-08-24 12:15:38 -0700461struct btrfs_dev_replace_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700462 __le64 src_devid;
463 __le64 cursor_left;
464 __le64 cursor_right;
465 __le64 cont_reading_from_srcdev_mode;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700466 __le64 replace_state;
467 __le64 time_started;
468 __le64 time_stopped;
469 __le64 num_write_errors;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700470 __le64 num_uncorrectable_read_errors;
471} __attribute__((__packed__));
472#define BTRFS_BLOCK_GROUP_DATA (1ULL << 0)
473#define BTRFS_BLOCK_GROUP_SYSTEM (1ULL << 1)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700474#define BTRFS_BLOCK_GROUP_METADATA (1ULL << 2)
475#define BTRFS_BLOCK_GROUP_RAID0 (1ULL << 3)
476#define BTRFS_BLOCK_GROUP_RAID1 (1ULL << 4)
477#define BTRFS_BLOCK_GROUP_DUP (1ULL << 5)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700478#define BTRFS_BLOCK_GROUP_RAID10 (1ULL << 6)
479#define BTRFS_BLOCK_GROUP_RAID5 (1ULL << 7)
480#define BTRFS_BLOCK_GROUP_RAID6 (1ULL << 8)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800481#define BTRFS_BLOCK_GROUP_RAID1C3 (1ULL << 9)
482#define BTRFS_BLOCK_GROUP_RAID1C4 (1ULL << 10)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700483#define BTRFS_BLOCK_GROUP_RESERVED (BTRFS_AVAIL_ALLOC_BIT_SINGLE | BTRFS_SPACE_INFO_GLOBAL_RSV)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700484#define BTRFS_BLOCK_GROUP_TYPE_MASK (BTRFS_BLOCK_GROUP_DATA | BTRFS_BLOCK_GROUP_SYSTEM | BTRFS_BLOCK_GROUP_METADATA)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800485#define BTRFS_BLOCK_GROUP_PROFILE_MASK (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4 | BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6 | BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID10)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700486#define BTRFS_BLOCK_GROUP_RAID56_MASK (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
Christopher Ferrisd32ca142020-02-04 16:16:51 -0800487#define BTRFS_BLOCK_GROUP_RAID1_MASK (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID1C3 | BTRFS_BLOCK_GROUP_RAID1C4)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700488#define BTRFS_AVAIL_ALLOC_BIT_SINGLE (1ULL << 48)
489#define BTRFS_SPACE_INFO_GLOBAL_RSV (1ULL << 49)
490#define BTRFS_EXTENDED_PROFILE_MASK (BTRFS_BLOCK_GROUP_PROFILE_MASK | BTRFS_AVAIL_ALLOC_BIT_SINGLE)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700491struct btrfs_block_group_item {
492 __le64 used;
493 __le64 chunk_objectid;
494 __le64 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700495} __attribute__((__packed__));
496struct btrfs_free_space_info {
497 __le32 extent_count;
498 __le32 flags;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700499} __attribute__((__packed__));
500#define BTRFS_FREE_SPACE_USING_BITMAPS (1ULL << 0)
501#define BTRFS_QGROUP_LEVEL_SHIFT 48
502#define BTRFS_QGROUP_STATUS_FLAG_ON (1ULL << 0)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700503#define BTRFS_QGROUP_STATUS_FLAG_RESCAN (1ULL << 1)
504#define BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT (1ULL << 2)
Christopher Ferris6cd53a52022-12-12 23:39:16 +0000505#define BTRFS_QGROUP_STATUS_FLAGS_MASK (BTRFS_QGROUP_STATUS_FLAG_ON | BTRFS_QGROUP_STATUS_FLAG_RESCAN | BTRFS_QGROUP_STATUS_FLAG_INCONSISTENT)
Christopher Ferris106b3a82016-08-24 12:15:38 -0700506#define BTRFS_QGROUP_STATUS_VERSION 1
507struct btrfs_qgroup_status_item {
Christopher Ferris106b3a82016-08-24 12:15:38 -0700508 __le64 version;
509 __le64 generation;
510 __le64 flags;
511 __le64 rescan;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700512} __attribute__((__packed__));
513struct btrfs_qgroup_info_item {
514 __le64 generation;
515 __le64 rfer;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700516 __le64 rfer_cmpr;
517 __le64 excl;
518 __le64 excl_cmpr;
519} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700520struct btrfs_qgroup_limit_item {
521 __le64 flags;
522 __le64 max_rfer;
523 __le64 max_excl;
Christopher Ferris106b3a82016-08-24 12:15:38 -0700524 __le64 rsv_rfer;
525 __le64 rsv_excl;
526} __attribute__((__packed__));
Christopher Ferris2abfa9e2021-11-01 16:26:06 -0700527struct btrfs_verity_descriptor_item {
528 __le64 size;
529 __le64 reserved[2];
530 __u8 encryption;
531} __attribute__((__packed__));
Christopher Ferris106b3a82016-08-24 12:15:38 -0700532#endif