]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - include/uapi/linux/btrfs.h
btrfs: uapi/linux/btrfs.h migration, move balance flags
[mirror_ubuntu-eoan-kernel.git] / include / uapi / linux / btrfs.h
CommitLineData
6cbd5570
CM
1/*
2 * Copyright (C) 2007 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
16 * Boston, MA 021110-1307, USA.
17 */
18
55e301fd
FB
19#ifndef _UAPI_LINUX_BTRFS_H
20#define _UAPI_LINUX_BTRFS_H
21#include <linux/types.h>
c5739bba
CM
22#include <linux/ioctl.h>
23
24#define BTRFS_IOCTL_MAGIC 0x94
25#define BTRFS_VOL_NAME_MAX 255
d4ae133b 26#define BTRFS_LABEL_SIZE 256
8a4b83cc 27
c071fcfd 28/* this should be 4k */
72fd032e 29#define BTRFS_PATH_NAME_MAX 4087
c5739bba 30struct btrfs_ioctl_vol_args {
3de4586c 31 __s64 fd;
8a4b83cc 32 char name[BTRFS_PATH_NAME_MAX + 1];
c5739bba
CM
33};
34
3f6bcfbd
SB
35#define BTRFS_DEVICE_PATH_NAME_MAX 1024
36
475f6387
JS
37#define BTRFS_FSID_SIZE 16
38#define BTRFS_UUID_SIZE 16
b2373f25 39#define BTRFS_UUID_UNPARSED_SIZE 37
fdfb1e4f 40
83288b60
JM
41/*
42 * flags definition for qgroup limits
43 *
44 * Used by:
45 * struct btrfs_qgroup_limit.flags
46 * struct btrfs_qgroup_limit_item.flags
47 */
48#define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
49#define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
50#define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
51#define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
52#define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
53#define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
bed92eae
AJ
54
55struct btrfs_qgroup_limit {
56 __u64 flags;
57 __u64 max_rfer;
58 __u64 max_excl;
59 __u64 rsv_rfer;
60 __u64 rsv_excl;
61};
62
83288b60
JM
63/*
64 * flags definition for qgroup inheritance
65 *
66 * Used by:
67 * struct btrfs_qgroup_inherit.flags
68 */
69#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
70
bed92eae
AJ
71struct btrfs_qgroup_inherit {
72 __u64 flags;
73 __u64 num_qgroups;
74 __u64 num_ref_copies;
75 __u64 num_excl_copies;
76 struct btrfs_qgroup_limit lim;
77 __u64 qgroups[0];
78};
79
80struct btrfs_ioctl_qgroup_limit_args {
81 __u64 qgroupid;
82 struct btrfs_qgroup_limit lim;
83};
84
884f6eca
JM
85/*
86 * flags for subvolumes
87 *
88 * Used by:
89 * struct btrfs_ioctl_vol_args_v2.flags
90 *
91 * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
92 * - BTRFS_IOC_SUBVOL_GETFLAGS
93 * - BTRFS_IOC_SUBVOL_SETFLAGS
94 */
95#define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
96#define BTRFS_SUBVOL_RDONLY (1ULL << 1)
97#define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
98
fdfb1e4f
LZ
99#define BTRFS_SUBVOL_NAME_MAX 4039
100struct btrfs_ioctl_vol_args_v2 {
72fd032e
SW
101 __s64 fd;
102 __u64 transid;
fdfb1e4f 103 __u64 flags;
6f72c7e2
AJ
104 union {
105 struct {
106 __u64 size;
107 struct btrfs_qgroup_inherit __user *qgroup_inherit;
108 };
109 __u64 unused[4];
110 };
fdfb1e4f 111 char name[BTRFS_SUBVOL_NAME_MAX + 1];
72fd032e
SW
112};
113
a2de733c
AJ
114/*
115 * structure to report errors and progress to userspace, either as a
116 * result of a finished scrub, a canceled scrub or a progress inquiry
117 */
118struct btrfs_scrub_progress {
119 __u64 data_extents_scrubbed; /* # of data extents scrubbed */
120 __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */
121 __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */
122 __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
123 __u64 read_errors; /* # of read errors encountered (EIO) */
124 __u64 csum_errors; /* # of failed csum checks */
125 __u64 verify_errors; /* # of occurences, where the metadata
126 * of a tree block did not match the
127 * expected values, like generation or
128 * logical */
129 __u64 no_csum; /* # of 4k data block for which no csum
130 * is present, probably the result of
131 * data written with nodatasum */
132 __u64 csum_discards; /* # of csum for which no data was found
133 * in the extent tree. */
134 __u64 super_errors; /* # of bad super blocks encountered */
135 __u64 malloc_errors; /* # of internal kmalloc errors. These
136 * will likely cause an incomplete
137 * scrub */
138 __u64 uncorrectable_errors; /* # of errors where either no intact
139 * copy was found or the writeback
140 * failed */
141 __u64 corrected_errors; /* # of errors corrected */
142 __u64 last_physical; /* last physical address scrubbed. In
143 * case a scrub was aborted, this can
144 * be used to restart the scrub */
145 __u64 unverified_errors; /* # of occurences where a read for a
146 * full (64k) bio failed, but the re-
147 * check succeeded for each 4k piece.
148 * Intermittent error. */
149};
150
8628764e 151#define BTRFS_SCRUB_READONLY 1
475f6387
JS
152struct btrfs_ioctl_scrub_args {
153 __u64 devid; /* in */
154 __u64 start; /* in */
155 __u64 end; /* in */
156 __u64 flags; /* in */
157 struct btrfs_scrub_progress progress; /* out */
158 /* pad to 1k */
159 __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
160};
161
e93c89c1
SB
162#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
163#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
164struct btrfs_ioctl_dev_replace_start_params {
165 __u64 srcdevid; /* in, if 0, use srcdev_name instead */
e93c89c1
SB
166 __u64 cont_reading_from_srcdev_mode; /* in, see #define
167 * above */
3f6bcfbd
SB
168 __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
169 __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
e93c89c1
SB
170};
171
172#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
173#define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
174#define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2
175#define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3
176#define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4
177struct btrfs_ioctl_dev_replace_status_params {
178 __u64 replace_state; /* out, see #define above */
179 __u64 progress_1000; /* out, 0 <= x <= 1000 */
180 __u64 time_started; /* out, seconds since 1-Jan-1970 */
181 __u64 time_stopped; /* out, seconds since 1-Jan-1970 */
182 __u64 num_write_errors; /* out */
183 __u64 num_uncorrectable_read_errors; /* out */
184};
185
186#define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
187#define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
188#define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2
189#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0
190#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1
191#define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2
2fc9f6ba 192#define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3
e93c89c1
SB
193struct btrfs_ioctl_dev_replace_args {
194 __u64 cmd; /* in */
195 __u64 result; /* out */
196
197 union {
198 struct btrfs_ioctl_dev_replace_start_params start;
199 struct btrfs_ioctl_dev_replace_status_params status;
200 }; /* in/out */
201
202 __u64 spare[64];
203};
204
475f6387
JS
205struct btrfs_ioctl_dev_info_args {
206 __u64 devid; /* in/out */
207 __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
208 __u64 bytes_used; /* out */
209 __u64 total_bytes; /* out */
210 __u64 unused[379]; /* pad to 4k */
211 __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
212};
213
214struct btrfs_ioctl_fs_info_args {
215 __u64 max_id; /* out */
216 __u64 num_devices; /* out */
217 __u8 fsid[BTRFS_FSID_SIZE]; /* out */
80a773fb
DS
218 __u32 nodesize; /* out */
219 __u32 sectorsize; /* out */
220 __u32 clone_alignment; /* out */
221 __u32 reserved32;
222 __u64 reserved[122]; /* pad to 1k */
475f6387
JS
223};
224
18db9ac6
JM
225/*
226 * feature flags
227 *
228 * Used by:
229 * struct btrfs_ioctl_feature_flags
230 */
231#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
232
233#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
234#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
235#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
236#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
237/*
238 * some patches floated around with a second compression method
239 * lets save that incompat here for when they do get in
240 * Note we don't actually support it, we're just reserving the
241 * number
242 */
243#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZOv2 (1ULL << 4)
244
245/*
246 * older kernels tried to do bigger metadata blocks, but the
247 * code was pretty buggy. Lets not let them try anymore.
248 */
249#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
250
251#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
252#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
253#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
254#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
255
2eaa055f
JM
256struct btrfs_ioctl_feature_flags {
257 __u64 compat_flags;
258 __u64 compat_ro_flags;
259 __u64 incompat_flags;
260};
261
837d5b6e
ID
262/* balance control ioctl modes */
263#define BTRFS_BALANCE_CTL_PAUSE 1
a7e99c69 264#define BTRFS_BALANCE_CTL_CANCEL 2
837d5b6e 265
c9e9f97b
ID
266/*
267 * this is packed, because it should be exactly the same as its disk
268 * byte order counterpart (struct btrfs_disk_balance_args)
269 */
270struct btrfs_balance_args {
271 __u64 profiles;
bc309467
DS
272 union {
273 __le64 usage;
274 struct {
275 __le32 usage_min;
276 __le32 usage_max;
277 };
278 };
c9e9f97b
ID
279 __u64 devid;
280 __u64 pstart;
281 __u64 pend;
282 __u64 vstart;
283 __u64 vend;
284
285 __u64 target;
286
287 __u64 flags;
288
12907fc7
DS
289 /*
290 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
291 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
292 * and maximum
293 */
294 union {
295 __u64 limit; /* limit number of processed chunks */
296 struct {
297 __u32 limit_min;
298 __u32 limit_max;
299 };
300 };
dee32d0a
GAP
301
302 /*
303 * Process chunks that cross stripes_min..stripes_max devices,
304 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
305 */
306 __le32 stripes_min;
307 __le32 stripes_max;
308
309 __u64 unused[6];
c9e9f97b
ID
310} __attribute__ ((__packed__));
311
312/* report balance progress to userspace */
313struct btrfs_balance_progress {
314 __u64 expected; /* estimated # of chunks that will be
315 * relocated to fulfill the request */
316 __u64 considered; /* # of chunks we have considered so far */
317 __u64 completed; /* # of chunks relocated so far */
318};
319
04cd01df
JM
320/*
321 * flags definition for balance
322 *
323 * Restriper's general type filter
324 *
325 * Used by:
326 * btrfs_ioctl_balance_args.flags
327 * btrfs_balance_control.flags (internal)
328 */
329#define BTRFS_BALANCE_DATA (1ULL << 0)
330#define BTRFS_BALANCE_SYSTEM (1ULL << 1)
331#define BTRFS_BALANCE_METADATA (1ULL << 2)
332
333#define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \
334 BTRFS_BALANCE_SYSTEM | \
335 BTRFS_BALANCE_METADATA)
336
337#define BTRFS_BALANCE_FORCE (1ULL << 3)
338#define BTRFS_BALANCE_RESUME (1ULL << 4)
339
340/*
341 * flags definitions for per-type balance args
342 *
343 * Balance filters
344 *
345 * Used by:
346 * struct btrfs_balance_args
347 */
348#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
349#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
350#define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
351#define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3)
352#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
353#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
354#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
355#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
356#define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
357
358#define BTRFS_BALANCE_ARGS_MASK \
359 (BTRFS_BALANCE_ARGS_PROFILES | \
360 BTRFS_BALANCE_ARGS_USAGE | \
361 BTRFS_BALANCE_ARGS_DEVID | \
362 BTRFS_BALANCE_ARGS_DRANGE | \
363 BTRFS_BALANCE_ARGS_VRANGE | \
364 BTRFS_BALANCE_ARGS_LIMIT | \
365 BTRFS_BALANCE_ARGS_LIMIT_RANGE | \
366 BTRFS_BALANCE_ARGS_STRIPES_RANGE | \
367 BTRFS_BALANCE_ARGS_USAGE_RANGE)
368
369/*
370 * Profile changing flags. When SOFT is set we won't relocate chunk if
371 * it already has the target profile (even though it may be
372 * half-filled).
373 */
374#define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)
375#define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9)
376
377
378/*
379 * flags definition for balance state
380 *
381 * Used by:
382 * struct btrfs_ioctl_balance_args.state
383 */
837d5b6e
ID
384#define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
385#define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
a7e99c69 386#define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
837d5b6e 387
c9e9f97b
ID
388struct btrfs_ioctl_balance_args {
389 __u64 flags; /* in/out */
390 __u64 state; /* out */
391
392 struct btrfs_balance_args data; /* in/out */
393 struct btrfs_balance_args meta; /* in/out */
394 struct btrfs_balance_args sys; /* in/out */
395
396 struct btrfs_balance_progress stat; /* out */
397
398 __u64 unused[72]; /* pad to 1k */
399};
400
ac8e9819
CM
401#define BTRFS_INO_LOOKUP_PATH_MAX 4080
402struct btrfs_ioctl_ino_lookup_args {
403 __u64 treeid;
404 __u64 objectid;
405 char name[BTRFS_INO_LOOKUP_PATH_MAX];
406};
407
408struct btrfs_ioctl_search_key {
409 /* which root are we searching. 0 is the tree of tree roots */
410 __u64 tree_id;
411
412 /* keys returned will be >= min and <= max */
413 __u64 min_objectid;
414 __u64 max_objectid;
415
416 /* keys returned will be >= min and <= max */
417 __u64 min_offset;
418 __u64 max_offset;
419
420 /* max and min transids to search for */
421 __u64 min_transid;
422 __u64 max_transid;
423
424 /* keys returned will be >= min and <= max */
425 __u32 min_type;
426 __u32 max_type;
427
428 /*
429 * how many items did userland ask for, and how many are we
430 * returning
431 */
432 __u32 nr_items;
433
434 /* align to 64 bits */
435 __u32 unused;
436
437 /* some extra for later */
438 __u64 unused1;
439 __u64 unused2;
440 __u64 unused3;
441 __u64 unused4;
442};
443
444struct btrfs_ioctl_search_header {
445 __u64 transid;
446 __u64 objectid;
447 __u64 offset;
448 __u32 type;
449 __u32 len;
450};
451
452#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
453/*
454 * the buf is an array of search headers where
455 * each header is followed by the actual item
456 * the type field is expanded to 32 bits for alignment
457 */
458struct btrfs_ioctl_search_args {
459 struct btrfs_ioctl_search_key key;
460 char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
461};
462
cc68a8a5
GH
463struct btrfs_ioctl_search_args_v2 {
464 struct btrfs_ioctl_search_key key; /* in/out - search parameters */
465 __u64 buf_size; /* in - size of buffer
466 * out - on EOVERFLOW: needed size
467 * to store item */
468 __u64 buf[0]; /* out - found items */
469};
470
c071fcfd
CM
471struct btrfs_ioctl_clone_range_args {
472 __s64 src_fd;
473 __u64 src_offset, src_length;
474 __u64 dest_offset;
475};
476
1e701a32
CM
477/* flags for the defrag range ioctl */
478#define BTRFS_DEFRAG_RANGE_COMPRESS 1
479#define BTRFS_DEFRAG_RANGE_START_IO 2
480
416161db
MF
481#define BTRFS_SAME_DATA_DIFFERS 1
482/* For extent-same ioctl */
483struct btrfs_ioctl_same_extent_info {
484 __s64 fd; /* in - destination file */
485 __u64 logical_offset; /* in - start of extent in destination */
486 __u64 bytes_deduped; /* out - total # of bytes we were able
487 * to dedupe from this file */
488 /* status of this dedupe operation:
489 * 0 if dedup succeeds
490 * < 0 for error
491 * == BTRFS_SAME_DATA_DIFFERS if data differs
492 */
493 __s32 status; /* out - see above description */
494 __u32 reserved;
495};
496
497struct btrfs_ioctl_same_args {
498 __u64 logical_offset; /* in - start of extent in source */
499 __u64 length; /* in - length of extent */
500 __u16 dest_count; /* in - total elements in info array */
501 __u16 reserved1;
502 __u32 reserved2;
503 struct btrfs_ioctl_same_extent_info info[0];
504};
505
1406e432 506struct btrfs_ioctl_space_info {
ce769a29
SW
507 __u64 flags;
508 __u64 total_bytes;
509 __u64 used_bytes;
1406e432
JB
510};
511
512struct btrfs_ioctl_space_args {
ce769a29
SW
513 __u64 space_slots;
514 __u64 total_spaces;
1406e432
JB
515 struct btrfs_ioctl_space_info spaces[0];
516};
1e701a32 517
a542ad1b
JS
518struct btrfs_data_container {
519 __u32 bytes_left; /* out -- bytes not needed to deliver output */
520 __u32 bytes_missing; /* out -- additional bytes needed for result */
521 __u32 elem_cnt; /* out */
522 __u32 elem_missed; /* out */
740c3d22 523 __u64 val[0]; /* out */
a542ad1b
JS
524};
525
d7728c96
JS
526struct btrfs_ioctl_ino_path_args {
527 __u64 inum; /* in */
d04b1deb 528 __u64 size; /* in */
d7728c96 529 __u64 reserved[4];
740c3d22
CM
530 /* struct btrfs_data_container *fspath; out */
531 __u64 fspath; /* out */
d7728c96
JS
532};
533
534struct btrfs_ioctl_logical_ino_args {
535 __u64 logical; /* in */
d04b1deb 536 __u64 size; /* in */
d7728c96 537 __u64 reserved[4];
740c3d22
CM
538 /* struct btrfs_data_container *inodes; out */
539 __u64 inodes;
d7728c96
JS
540};
541
442a4f63
SB
542enum btrfs_dev_stat_values {
543 /* disk I/O failure stats */
544 BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
545 BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
546 BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
547
548 /* stats for indirect indications for I/O failures */
549 BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
550 * contents is illegal: this is an
551 * indication that the block was damaged
552 * during read or write, or written to
553 * wrong location or read from wrong
554 * location */
555 BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
556 * been written */
557
558 BTRFS_DEV_STAT_VALUES_MAX
559};
560
b27f7c0c
DS
561/* Reset statistics after reading; needs SYS_ADMIN capability */
562#define BTRFS_DEV_STATS_RESET (1ULL << 0)
563
c11d2c23
SB
564struct btrfs_ioctl_get_dev_stats {
565 __u64 devid; /* in */
566 __u64 nr_items; /* in/out */
b27f7c0c 567 __u64 flags; /* in/out */
c11d2c23
SB
568
569 /* out values: */
570 __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
571
572 __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */
573};
574
5d13a37b
AJ
575#define BTRFS_QUOTA_CTL_ENABLE 1
576#define BTRFS_QUOTA_CTL_DISABLE 2
2f232036 577#define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
5d13a37b
AJ
578struct btrfs_ioctl_quota_ctl_args {
579 __u64 cmd;
580 __u64 status;
581};
582
2f232036
JS
583struct btrfs_ioctl_quota_rescan_args {
584 __u64 flags;
585 __u64 progress;
586 __u64 reserved[6];
587};
588
5d13a37b
AJ
589struct btrfs_ioctl_qgroup_assign_args {
590 __u64 assign;
591 __u64 src;
592 __u64 dst;
593};
594
595struct btrfs_ioctl_qgroup_create_args {
596 __u64 create;
597 __u64 qgroupid;
598};
8ea05e3a
AB
599struct btrfs_ioctl_timespec {
600 __u64 sec;
601 __u32 nsec;
602};
603
604struct btrfs_ioctl_received_subvol_args {
605 char uuid[BTRFS_UUID_SIZE]; /* in */
606 __u64 stransid; /* in */
607 __u64 rtransid; /* out */
608 struct btrfs_ioctl_timespec stime; /* in */
609 struct btrfs_ioctl_timespec rtime; /* out */
610 __u64 flags; /* in */
611 __u64 reserved[16]; /* in */
612};
613
cb95e7bf
MF
614/*
615 * Caller doesn't want file data in the send stream, even if the
616 * search of clone sources doesn't find an extent. UPDATE_EXTENT
617 * commands will be sent instead of WRITE commands.
618 */
c2c71324
SB
619#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
620
621/*
622 * Do not add the leading stream header. Used when multiple snapshots
623 * are sent back to back.
624 */
625#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
626
627/*
628 * Omit the command at the end of the stream that indicated the end
629 * of the stream. This option is used when multiple snapshots are
630 * sent back to back.
631 */
632#define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
633
634#define BTRFS_SEND_FLAG_MASK \
635 (BTRFS_SEND_FLAG_NO_FILE_DATA | \
636 BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
637 BTRFS_SEND_FLAG_OMIT_END_CMD)
cb95e7bf 638
31db9f7c
AB
639struct btrfs_ioctl_send_args {
640 __s64 send_fd; /* in */
641 __u64 clone_sources_count; /* in */
642 __u64 __user *clone_sources; /* in */
643 __u64 parent_root; /* in */
644 __u64 flags; /* in */
645 __u64 reserved[4]; /* in */
646};
5d13a37b 647
183860f6
AJ
648/* Error codes as returned by the kernel */
649enum btrfs_err_code {
eb710b15 650 BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
183860f6
AJ
651 BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
652 BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
653 BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
654 BTRFS_ERROR_DEV_TGT_REPLACE,
655 BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
656 BTRFS_ERROR_DEV_ONLY_WRITABLE,
657 BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
658};
659/* An error code to error string mapping for the kernel
660* error codes
661*/
662static inline char *btrfs_err_str(enum btrfs_err_code err_code)
663{
664 switch (err_code) {
665 case BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET:
666 return "unable to go below two devices on raid1";
667 case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
668 return "unable to go below four devices on raid10";
669 case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
670 return "unable to go below two devices on raid5";
671 case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:
672 return "unable to go below three devices on raid6";
673 case BTRFS_ERROR_DEV_TGT_REPLACE:
674 return "unable to remove the dev_replace target dev";
675 case BTRFS_ERROR_DEV_MISSING_NOT_FOUND:
676 return "no missing devices found to remove";
677 case BTRFS_ERROR_DEV_ONLY_WRITABLE:
678 return "unable to remove the only writeable device";
679 case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS:
680 return "add/delete/balance/replace/resize operation "\
681 "in progress";
682 default:
683 return NULL;
684 }
685}
686
c5739bba
CM
687#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
688 struct btrfs_ioctl_vol_args)
6702ed49 689#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
8352d8a4 690 struct btrfs_ioctl_vol_args)
edbd8d4e
CM
691#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
692 struct btrfs_ioctl_vol_args)
8a4b83cc
CM
693#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
694 struct btrfs_ioctl_vol_args)
6bf13c0c
SW
695/* trans start and trans end are dangerous, and only for
696 * use by applications that know how to avoid the
697 * resulting deadlocks
698 */
699#define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
700#define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
701#define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
702
f2eb0a24 703#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
788f20eb
CM
704#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
705 struct btrfs_ioctl_vol_args)
706#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
707 struct btrfs_ioctl_vol_args)
708#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
709 struct btrfs_ioctl_vol_args)
c5c9cd4d
SW
710
711#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
712 struct btrfs_ioctl_clone_range_args)
713
3de4586c
CM
714#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
715 struct btrfs_ioctl_vol_args)
76dda93c
YZ
716#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
717 struct btrfs_ioctl_vol_args)
1e701a32
CM
718#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
719 struct btrfs_ioctl_defrag_range_args)
ac8e9819
CM
720#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
721 struct btrfs_ioctl_search_args)
cc68a8a5
GH
722#define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
723 struct btrfs_ioctl_search_args_v2)
ac8e9819
CM
724#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
725 struct btrfs_ioctl_ino_lookup_args)
68b823ef 726#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
1406e432
JB
727#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
728 struct btrfs_ioctl_space_args)
46204592
SW
729#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
730#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
fdfb1e4f
LZ
731#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
732 struct btrfs_ioctl_vol_args_v2)
6f72c7e2
AJ
733#define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
734 struct btrfs_ioctl_vol_args_v2)
d3a94048 735#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
0caa102d 736#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
475f6387
JS
737#define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
738 struct btrfs_ioctl_scrub_args)
739#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
740#define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
741 struct btrfs_ioctl_scrub_args)
742#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
743 struct btrfs_ioctl_dev_info_args)
744#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
745 struct btrfs_ioctl_fs_info_args)
c9e9f97b
ID
746#define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
747 struct btrfs_ioctl_balance_args)
837d5b6e 748#define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
19a39dce
ID
749#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
750 struct btrfs_ioctl_balance_args)
d7728c96
JS
751#define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
752 struct btrfs_ioctl_ino_path_args)
753#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
754 struct btrfs_ioctl_ino_path_args)
8ea05e3a
AB
755#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
756 struct btrfs_ioctl_received_subvol_args)
31db9f7c 757#define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
02db0844
JB
758#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
759 struct btrfs_ioctl_vol_args)
5d13a37b
AJ
760#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
761 struct btrfs_ioctl_quota_ctl_args)
762#define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
763 struct btrfs_ioctl_qgroup_assign_args)
764#define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
765 struct btrfs_ioctl_qgroup_create_args)
766#define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
767 struct btrfs_ioctl_qgroup_limit_args)
2f232036
JS
768#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
769 struct btrfs_ioctl_quota_rescan_args)
770#define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
771 struct btrfs_ioctl_quota_rescan_args)
57254b6e 772#define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
867ab667 773#define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, \
774 char[BTRFS_LABEL_SIZE])
a8bfd4ab 775#define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, \
776 char[BTRFS_LABEL_SIZE])
c11d2c23
SB
777#define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
778 struct btrfs_ioctl_get_dev_stats)
e93c89c1
SB
779#define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
780 struct btrfs_ioctl_dev_replace_args)
416161db
MF
781#define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
782 struct btrfs_ioctl_same_args)
2eaa055f
JM
783#define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
784 struct btrfs_ioctl_feature_flags)
785#define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
786 struct btrfs_ioctl_feature_flags[2])
787#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
788 struct btrfs_ioctl_feature_flags[3])
416161db 789
55e301fd 790#endif /* _UAPI_LINUX_BTRFS_H */