xref: /linux/include/uapi/linux/btrfs.h (revision 100c85421b52e41269ada88f7d71a6b8a06c7a11)
1e2be04c7SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
255e301fdSFilipe Brandenburger /*
355e301fdSFilipe Brandenburger  * Copyright (C) 2007 Oracle.  All rights reserved.
455e301fdSFilipe Brandenburger  *
555e301fdSFilipe Brandenburger  * This program is free software; you can redistribute it and/or
655e301fdSFilipe Brandenburger  * modify it under the terms of the GNU General Public
755e301fdSFilipe Brandenburger  * License v2 as published by the Free Software Foundation.
855e301fdSFilipe Brandenburger  *
955e301fdSFilipe Brandenburger  * This program is distributed in the hope that it will be useful,
1055e301fdSFilipe Brandenburger  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1155e301fdSFilipe Brandenburger  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1255e301fdSFilipe Brandenburger  * General Public License for more details.
1355e301fdSFilipe Brandenburger  *
1455e301fdSFilipe Brandenburger  * You should have received a copy of the GNU General Public
1555e301fdSFilipe Brandenburger  * License along with this program; if not, write to the
1655e301fdSFilipe Brandenburger  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1755e301fdSFilipe Brandenburger  * Boston, MA 021110-1307, USA.
1855e301fdSFilipe Brandenburger  */
1955e301fdSFilipe Brandenburger 
2055e301fdSFilipe Brandenburger #ifndef _UAPI_LINUX_BTRFS_H
2155e301fdSFilipe Brandenburger #define _UAPI_LINUX_BTRFS_H
22a2813530SJosef Bacik 
23a2813530SJosef Bacik #ifdef __cplusplus
24a2813530SJosef Bacik extern "C" {
25a2813530SJosef Bacik #endif
26a2813530SJosef Bacik 
2755e301fdSFilipe Brandenburger #include <linux/types.h>
2855e301fdSFilipe Brandenburger #include <linux/ioctl.h>
29a2813530SJosef Bacik #include <linux/fs.h>
3055e301fdSFilipe Brandenburger 
3155e301fdSFilipe Brandenburger #define BTRFS_IOCTL_MAGIC 0x94
3255e301fdSFilipe Brandenburger #define BTRFS_VOL_NAME_MAX 255
33d4ae133bSJeff Mahoney #define BTRFS_LABEL_SIZE 256
3455e301fdSFilipe Brandenburger 
3555e301fdSFilipe Brandenburger /* this should be 4k */
3655e301fdSFilipe Brandenburger #define BTRFS_PATH_NAME_MAX 4087
3755e301fdSFilipe Brandenburger struct btrfs_ioctl_vol_args {
3855e301fdSFilipe Brandenburger 	__s64 fd;
3955e301fdSFilipe Brandenburger 	char name[BTRFS_PATH_NAME_MAX + 1];
4055e301fdSFilipe Brandenburger };
4155e301fdSFilipe Brandenburger 
4255e301fdSFilipe Brandenburger #define BTRFS_DEVICE_PATH_NAME_MAX	1024
43ad8bc4d0SAnand Jain #define BTRFS_SUBVOL_NAME_MAX 		4039
44ad8bc4d0SAnand Jain 
4534c51814SEugene Syromiatnikov #ifndef __KERNEL__
4634c51814SEugene Syromiatnikov /* Deprecated since 5.7 */
4734c51814SEugene Syromiatnikov # define BTRFS_SUBVOL_CREATE_ASYNC	(1ULL << 0)
4834c51814SEugene Syromiatnikov #endif
49ad8bc4d0SAnand Jain #define BTRFS_SUBVOL_RDONLY		(1ULL << 1)
50ad8bc4d0SAnand Jain #define BTRFS_SUBVOL_QGROUP_INHERIT	(1ULL << 2)
5155e301fdSFilipe Brandenburger 
52735654eaSDavid Sterba #define BTRFS_DEVICE_SPEC_BY_ID		(1ULL << 3)
53735654eaSDavid Sterba 
54949964c9SMarcos Paulo de Souza #define BTRFS_SUBVOL_SPEC_BY_ID	(1ULL << 4)
55949964c9SMarcos Paulo de Souza 
56735654eaSDavid Sterba #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED		\
579c1036fdSNikolay Borisov 			(BTRFS_SUBVOL_RDONLY |		\
586b526ed7SAnand Jain 			BTRFS_SUBVOL_QGROUP_INHERIT |	\
59949964c9SMarcos Paulo de Souza 			BTRFS_DEVICE_SPEC_BY_ID |	\
60949964c9SMarcos Paulo de Souza 			BTRFS_SUBVOL_SPEC_BY_ID)
616b526ed7SAnand Jain 
6255e301fdSFilipe Brandenburger #define BTRFS_FSID_SIZE 16
6355e301fdSFilipe Brandenburger #define BTRFS_UUID_SIZE 16
64b2373f25SAnand Jain #define BTRFS_UUID_UNPARSED_SIZE	37
6555e301fdSFilipe Brandenburger 
6683288b60SJeff Mahoney /*
6783288b60SJeff Mahoney  * flags definition for qgroup limits
6883288b60SJeff Mahoney  *
6983288b60SJeff Mahoney  * Used by:
7083288b60SJeff Mahoney  * struct btrfs_qgroup_limit.flags
7183288b60SJeff Mahoney  * struct btrfs_qgroup_limit_item.flags
7283288b60SJeff Mahoney  */
7383288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_MAX_RFER	(1ULL << 0)
7483288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_MAX_EXCL	(1ULL << 1)
7583288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_RSV_RFER	(1ULL << 2)
7683288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_RSV_EXCL	(1ULL << 3)
7783288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_RFER_CMPR	(1ULL << 4)
7883288b60SJeff Mahoney #define BTRFS_QGROUP_LIMIT_EXCL_CMPR	(1ULL << 5)
7955e301fdSFilipe Brandenburger 
8055e301fdSFilipe Brandenburger struct btrfs_qgroup_limit {
8155e301fdSFilipe Brandenburger 	__u64	flags;
8255e301fdSFilipe Brandenburger 	__u64	max_rfer;
8355e301fdSFilipe Brandenburger 	__u64	max_excl;
8455e301fdSFilipe Brandenburger 	__u64	rsv_rfer;
8555e301fdSFilipe Brandenburger 	__u64	rsv_excl;
8655e301fdSFilipe Brandenburger };
8755e301fdSFilipe Brandenburger 
8883288b60SJeff Mahoney /*
8983288b60SJeff Mahoney  * flags definition for qgroup inheritance
9083288b60SJeff Mahoney  *
9183288b60SJeff Mahoney  * Used by:
9283288b60SJeff Mahoney  * struct btrfs_qgroup_inherit.flags
9383288b60SJeff Mahoney  */
9483288b60SJeff Mahoney #define BTRFS_QGROUP_INHERIT_SET_LIMITS	(1ULL << 0)
95*86211eeaSQu Wenruo #define BTRFS_QGROUP_INHERIT_FLAGS_SUPP (BTRFS_QGROUP_INHERIT_SET_LIMITS)
9683288b60SJeff Mahoney 
9755e301fdSFilipe Brandenburger struct btrfs_qgroup_inherit {
9855e301fdSFilipe Brandenburger 	__u64	flags;
9955e301fdSFilipe Brandenburger 	__u64	num_qgroups;
10055e301fdSFilipe Brandenburger 	__u64	num_ref_copies;
10155e301fdSFilipe Brandenburger 	__u64	num_excl_copies;
10255e301fdSFilipe Brandenburger 	struct btrfs_qgroup_limit lim;
10394dfc73eSGustavo A. R. Silva 	__u64	qgroups[];
10455e301fdSFilipe Brandenburger };
10555e301fdSFilipe Brandenburger 
10655e301fdSFilipe Brandenburger struct btrfs_ioctl_qgroup_limit_args {
10755e301fdSFilipe Brandenburger 	__u64	qgroupid;
10855e301fdSFilipe Brandenburger 	struct btrfs_qgroup_limit lim;
10955e301fdSFilipe Brandenburger };
11055e301fdSFilipe Brandenburger 
111884f6ecaSJeff Mahoney /*
112eed02690SDavid Sterba  * Arguments for specification of subvolumes or devices, supporting by-name or
113eed02690SDavid Sterba  * by-id and flags
114884f6ecaSJeff Mahoney  *
115eed02690SDavid Sterba  * The set of supported flags depends on the ioctl
116884f6ecaSJeff Mahoney  *
117884f6ecaSJeff Mahoney  * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
118884f6ecaSJeff Mahoney  * - BTRFS_IOC_SUBVOL_GETFLAGS
119884f6ecaSJeff Mahoney  * - BTRFS_IOC_SUBVOL_SETFLAGS
120884f6ecaSJeff Mahoney  */
121884f6ecaSJeff Mahoney 
122eed02690SDavid Sterba /* Supported flags for BTRFS_IOC_RM_DEV_V2 */
123eed02690SDavid Sterba #define BTRFS_DEVICE_REMOVE_ARGS_MASK					\
124eed02690SDavid Sterba 	(BTRFS_DEVICE_SPEC_BY_ID)
125eed02690SDavid Sterba 
126eed02690SDavid Sterba /* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */
127eed02690SDavid Sterba #define BTRFS_SUBVOL_CREATE_ARGS_MASK					\
1289c1036fdSNikolay Borisov 	 (BTRFS_SUBVOL_RDONLY |						\
129eed02690SDavid Sterba 	 BTRFS_SUBVOL_QGROUP_INHERIT)
130eed02690SDavid Sterba 
131949964c9SMarcos Paulo de Souza /* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
132949964c9SMarcos Paulo de Souza #define BTRFS_SUBVOL_DELETE_ARGS_MASK					\
133949964c9SMarcos Paulo de Souza 	(BTRFS_SUBVOL_SPEC_BY_ID)
134949964c9SMarcos Paulo de Souza 
13555e301fdSFilipe Brandenburger struct btrfs_ioctl_vol_args_v2 {
13655e301fdSFilipe Brandenburger 	__s64 fd;
13755e301fdSFilipe Brandenburger 	__u64 transid;
13855e301fdSFilipe Brandenburger 	__u64 flags;
13955e301fdSFilipe Brandenburger 	union {
14055e301fdSFilipe Brandenburger 		struct {
14155e301fdSFilipe Brandenburger 			__u64 size;
14255e301fdSFilipe Brandenburger 			struct btrfs_qgroup_inherit __user *qgroup_inherit;
14355e301fdSFilipe Brandenburger 		};
14455e301fdSFilipe Brandenburger 		__u64 unused[4];
14555e301fdSFilipe Brandenburger 	};
1466b526ed7SAnand Jain 	union {
14755e301fdSFilipe Brandenburger 		char name[BTRFS_SUBVOL_NAME_MAX + 1];
1481691cf16SVinson Lee 		__u64 devid;
149949964c9SMarcos Paulo de Souza 		__u64 subvolid;
1506b526ed7SAnand Jain 	};
15155e301fdSFilipe Brandenburger };
15255e301fdSFilipe Brandenburger 
15355e301fdSFilipe Brandenburger /*
15455e301fdSFilipe Brandenburger  * structure to report errors and progress to userspace, either as a
15555e301fdSFilipe Brandenburger  * result of a finished scrub, a canceled scrub or a progress inquiry
15655e301fdSFilipe Brandenburger  */
15755e301fdSFilipe Brandenburger struct btrfs_scrub_progress {
15855e301fdSFilipe Brandenburger 	__u64 data_extents_scrubbed;	/* # of data extents scrubbed */
15955e301fdSFilipe Brandenburger 	__u64 tree_extents_scrubbed;	/* # of tree extents scrubbed */
16055e301fdSFilipe Brandenburger 	__u64 data_bytes_scrubbed;	/* # of data bytes scrubbed */
16155e301fdSFilipe Brandenburger 	__u64 tree_bytes_scrubbed;	/* # of tree bytes scrubbed */
16255e301fdSFilipe Brandenburger 	__u64 read_errors;		/* # of read errors encountered (EIO) */
16355e301fdSFilipe Brandenburger 	__u64 csum_errors;		/* # of failed csum checks */
1641a9fd417SDavid Sterba 	__u64 verify_errors;		/* # of occurrences, where the metadata
16555e301fdSFilipe Brandenburger 					 * of a tree block did not match the
16655e301fdSFilipe Brandenburger 					 * expected values, like generation or
16755e301fdSFilipe Brandenburger 					 * logical */
16855e301fdSFilipe Brandenburger 	__u64 no_csum;			/* # of 4k data block for which no csum
16955e301fdSFilipe Brandenburger 					 * is present, probably the result of
17055e301fdSFilipe Brandenburger 					 * data written with nodatasum */
17155e301fdSFilipe Brandenburger 	__u64 csum_discards;		/* # of csum for which no data was found
17255e301fdSFilipe Brandenburger 					 * in the extent tree. */
17355e301fdSFilipe Brandenburger 	__u64 super_errors;		/* # of bad super blocks encountered */
17455e301fdSFilipe Brandenburger 	__u64 malloc_errors;		/* # of internal kmalloc errors. These
17555e301fdSFilipe Brandenburger 					 * will likely cause an incomplete
17655e301fdSFilipe Brandenburger 					 * scrub */
17755e301fdSFilipe Brandenburger 	__u64 uncorrectable_errors;	/* # of errors where either no intact
17855e301fdSFilipe Brandenburger 					 * copy was found or the writeback
17955e301fdSFilipe Brandenburger 					 * failed */
18055e301fdSFilipe Brandenburger 	__u64 corrected_errors;		/* # of errors corrected */
18155e301fdSFilipe Brandenburger 	__u64 last_physical;		/* last physical address scrubbed. In
18255e301fdSFilipe Brandenburger 					 * case a scrub was aborted, this can
18355e301fdSFilipe Brandenburger 					 * be used to restart the scrub */
1841a9fd417SDavid Sterba 	__u64 unverified_errors;	/* # of occurrences where a read for a
18555e301fdSFilipe Brandenburger 					 * full (64k) bio failed, but the re-
18655e301fdSFilipe Brandenburger 					 * check succeeded for each 4k piece.
18755e301fdSFilipe Brandenburger 					 * Intermittent error. */
18855e301fdSFilipe Brandenburger };
18955e301fdSFilipe Brandenburger 
19055e301fdSFilipe Brandenburger #define BTRFS_SCRUB_READONLY	1
191604e6681SQu Wenruo #define BTRFS_SCRUB_SUPPORTED_FLAGS	(BTRFS_SCRUB_READONLY)
19255e301fdSFilipe Brandenburger struct btrfs_ioctl_scrub_args {
19355e301fdSFilipe Brandenburger 	__u64 devid;				/* in */
19455e301fdSFilipe Brandenburger 	__u64 start;				/* in */
19555e301fdSFilipe Brandenburger 	__u64 end;				/* in */
19655e301fdSFilipe Brandenburger 	__u64 flags;				/* in */
19755e301fdSFilipe Brandenburger 	struct btrfs_scrub_progress progress;	/* out */
19855e301fdSFilipe Brandenburger 	/* pad to 1k */
19955e301fdSFilipe Brandenburger 	__u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
20055e301fdSFilipe Brandenburger };
20155e301fdSFilipe Brandenburger 
20255e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS	0
20355e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID	1
20455e301fdSFilipe Brandenburger struct btrfs_ioctl_dev_replace_start_params {
20555e301fdSFilipe Brandenburger 	__u64 srcdevid;	/* in, if 0, use srcdev_name instead */
20655e301fdSFilipe Brandenburger 	__u64 cont_reading_from_srcdev_mode;	/* in, see #define
20755e301fdSFilipe Brandenburger 						 * above */
20855e301fdSFilipe Brandenburger 	__u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];	/* in */
20955e301fdSFilipe Brandenburger 	__u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];	/* in */
21055e301fdSFilipe Brandenburger };
21155e301fdSFilipe Brandenburger 
21255e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED	0
21355e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED		1
21455e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED		2
21555e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED		3
21655e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED		4
21755e301fdSFilipe Brandenburger struct btrfs_ioctl_dev_replace_status_params {
21855e301fdSFilipe Brandenburger 	__u64 replace_state;	/* out, see #define above */
21955e301fdSFilipe Brandenburger 	__u64 progress_1000;	/* out, 0 <= x <= 1000 */
22055e301fdSFilipe Brandenburger 	__u64 time_started;	/* out, seconds since 1-Jan-1970 */
22155e301fdSFilipe Brandenburger 	__u64 time_stopped;	/* out, seconds since 1-Jan-1970 */
22255e301fdSFilipe Brandenburger 	__u64 num_write_errors;	/* out */
22355e301fdSFilipe Brandenburger 	__u64 num_uncorrectable_read_errors;	/* out */
22455e301fdSFilipe Brandenburger };
22555e301fdSFilipe Brandenburger 
22655e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_CMD_START			0
22755e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS			1
22855e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL			2
22955e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR			0
23055e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED		1
23155e301fdSFilipe Brandenburger #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED		2
2322fc9f6baSEryu Guan #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS		3
23355e301fdSFilipe Brandenburger struct btrfs_ioctl_dev_replace_args {
23455e301fdSFilipe Brandenburger 	__u64 cmd;	/* in */
23555e301fdSFilipe Brandenburger 	__u64 result;	/* out */
23655e301fdSFilipe Brandenburger 
23755e301fdSFilipe Brandenburger 	union {
23855e301fdSFilipe Brandenburger 		struct btrfs_ioctl_dev_replace_start_params start;
23955e301fdSFilipe Brandenburger 		struct btrfs_ioctl_dev_replace_status_params status;
24055e301fdSFilipe Brandenburger 	};	/* in/out */
24155e301fdSFilipe Brandenburger 
24255e301fdSFilipe Brandenburger 	__u64 spare[64];
24355e301fdSFilipe Brandenburger };
24455e301fdSFilipe Brandenburger 
24555e301fdSFilipe Brandenburger struct btrfs_ioctl_dev_info_args {
24655e301fdSFilipe Brandenburger 	__u64 devid;				/* in/out */
24755e301fdSFilipe Brandenburger 	__u8 uuid[BTRFS_UUID_SIZE];		/* in/out */
24855e301fdSFilipe Brandenburger 	__u64 bytes_used;			/* out */
24955e301fdSFilipe Brandenburger 	__u64 total_bytes;			/* out */
2502943868aSQu Wenruo 	/*
2512943868aSQu Wenruo 	 * Optional, out.
2522943868aSQu Wenruo 	 *
2532943868aSQu Wenruo 	 * Showing the fsid of the device, allowing user space to check if this
2542943868aSQu Wenruo 	 * device is a seeding one.
2552943868aSQu Wenruo 	 *
2562943868aSQu Wenruo 	 * Introduced in v6.3, thus user space still needs to check if kernel
2572943868aSQu Wenruo 	 * changed this value.  Older kernel will not touch the values here.
2582943868aSQu Wenruo 	 */
2592943868aSQu Wenruo 	__u8 fsid[BTRFS_UUID_SIZE];
2602943868aSQu Wenruo 	__u64 unused[377];			/* pad to 4k */
26155e301fdSFilipe Brandenburger 	__u8 path[BTRFS_DEVICE_PATH_NAME_MAX];	/* out */
26255e301fdSFilipe Brandenburger };
26355e301fdSFilipe Brandenburger 
264137c5418SJohannes Thumshirn /*
265137c5418SJohannes Thumshirn  * Retrieve information about the filesystem
266137c5418SJohannes Thumshirn  */
267137c5418SJohannes Thumshirn 
268137c5418SJohannes Thumshirn /* Request information about checksum type and size */
269137c5418SJohannes Thumshirn #define BTRFS_FS_INFO_FLAG_CSUM_INFO			(1 << 0)
270137c5418SJohannes Thumshirn 
2710fb408a5SJohannes Thumshirn /* Request information about filesystem generation */
2720fb408a5SJohannes Thumshirn #define BTRFS_FS_INFO_FLAG_GENERATION			(1 << 1)
27349bac897SJohannes Thumshirn /* Request information about filesystem metadata UUID */
27449bac897SJohannes Thumshirn #define BTRFS_FS_INFO_FLAG_METADATA_UUID		(1 << 2)
2750fb408a5SJohannes Thumshirn 
27655e301fdSFilipe Brandenburger struct btrfs_ioctl_fs_info_args {
27755e301fdSFilipe Brandenburger 	__u64 max_id;				/* out */
27855e301fdSFilipe Brandenburger 	__u64 num_devices;			/* out */
27955e301fdSFilipe Brandenburger 	__u8 fsid[BTRFS_FSID_SIZE];		/* out */
28080a773fbSDavid Sterba 	__u32 nodesize;				/* out */
28180a773fbSDavid Sterba 	__u32 sectorsize;			/* out */
28280a773fbSDavid Sterba 	__u32 clone_alignment;			/* out */
283137c5418SJohannes Thumshirn 	/* See BTRFS_FS_INFO_FLAG_* */
284137c5418SJohannes Thumshirn 	__u16 csum_type;			/* out */
285137c5418SJohannes Thumshirn 	__u16 csum_size;			/* out */
286137c5418SJohannes Thumshirn 	__u64 flags;				/* in/out */
2870fb408a5SJohannes Thumshirn 	__u64 generation;			/* out */
28849bac897SJohannes Thumshirn 	__u8 metadata_uuid[BTRFS_FSID_SIZE];	/* out */
28949bac897SJohannes Thumshirn 	__u8 reserved[944];			/* pad to 1k */
29055e301fdSFilipe Brandenburger };
29155e301fdSFilipe Brandenburger 
29218db9ac6SJeff Mahoney /*
29318db9ac6SJeff Mahoney  * feature flags
29418db9ac6SJeff Mahoney  *
29518db9ac6SJeff Mahoney  * Used by:
29618db9ac6SJeff Mahoney  * struct btrfs_ioctl_feature_flags
29718db9ac6SJeff Mahoney  */
29818db9ac6SJeff Mahoney #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE		(1ULL << 0)
2996675df31SOmar Sandoval /*
3006675df31SOmar Sandoval  * Older kernels (< 4.9) on big-endian systems produced broken free space tree
3016675df31SOmar Sandoval  * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
3026675df31SOmar Sandoval  * < 4.7.3).  If this bit is clear, then the free space tree cannot be trusted.
3036675df31SOmar Sandoval  * btrfs-progs can also intentionally clear this bit to ask the kernel to
3046675df31SOmar Sandoval  * rebuild the free space tree, however this might not work on older kernels
3056675df31SOmar Sandoval  * that do not know about this bit. If not sure, clear the cache manually on
3066675df31SOmar Sandoval  * first mount when booting older kernel versions.
3076675df31SOmar Sandoval  */
3086675df31SOmar Sandoval #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID	(1ULL << 1)
30914605409SBoris Burkov #define BTRFS_FEATURE_COMPAT_RO_VERITY			(1ULL << 2)
31018db9ac6SJeff Mahoney 
3111c56ab99SQu Wenruo /*
3121c56ab99SQu Wenruo  * Put all block group items into a dedicated block group tree, greatly
3131c56ab99SQu Wenruo  * reducing mount time for large filesystem due to better locality.
3141c56ab99SQu Wenruo  */
3151c56ab99SQu Wenruo #define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE	(1ULL << 3)
3161c56ab99SQu Wenruo 
31718db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF	(1ULL << 0)
31818db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL	(1ULL << 1)
31918db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS	(1ULL << 2)
32018db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO	(1ULL << 3)
3215c1aab1dSNick Terrell #define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD	(1ULL << 4)
32218db9ac6SJeff Mahoney 
32318db9ac6SJeff Mahoney /*
32418db9ac6SJeff Mahoney  * older kernels tried to do bigger metadata blocks, but the
32518db9ac6SJeff Mahoney  * code was pretty buggy.  Lets not let them try anymore.
32618db9ac6SJeff Mahoney  */
32718db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA	(1ULL << 5)
32818db9ac6SJeff Mahoney 
32918db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF	(1ULL << 6)
33018db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_RAID56		(1ULL << 7)
33118db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA	(1ULL << 8)
33218db9ac6SJeff Mahoney #define BTRFS_FEATURE_INCOMPAT_NO_HOLES		(1ULL << 9)
3337239ff4bSNikolay Borisov #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID	(1ULL << 10)
334cfbb825cSDavid Sterba #define BTRFS_FEATURE_INCOMPAT_RAID1C34		(1ULL << 11)
3357b3d5a90SNaohiro Aota #define BTRFS_FEATURE_INCOMPAT_ZONED		(1ULL << 12)
3362c7d2a23SJosef Bacik #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2	(1ULL << 13)
33751502090SJohannes Thumshirn #define BTRFS_FEATURE_INCOMPAT_RAID_STRIPE_TREE	(1ULL << 14)
338182940f4SBoris Burkov #define BTRFS_FEATURE_INCOMPAT_SIMPLE_QUOTA	(1ULL << 16)
33918db9ac6SJeff Mahoney 
3402eaa055fSJeff Mahoney struct btrfs_ioctl_feature_flags {
3412eaa055fSJeff Mahoney 	__u64 compat_flags;
3422eaa055fSJeff Mahoney 	__u64 compat_ro_flags;
3432eaa055fSJeff Mahoney 	__u64 incompat_flags;
3442eaa055fSJeff Mahoney };
3452eaa055fSJeff Mahoney 
34655e301fdSFilipe Brandenburger /* balance control ioctl modes */
34755e301fdSFilipe Brandenburger #define BTRFS_BALANCE_CTL_PAUSE		1
34855e301fdSFilipe Brandenburger #define BTRFS_BALANCE_CTL_CANCEL	2
34955e301fdSFilipe Brandenburger 
35055e301fdSFilipe Brandenburger /*
35155e301fdSFilipe Brandenburger  * this is packed, because it should be exactly the same as its disk
35255e301fdSFilipe Brandenburger  * byte order counterpart (struct btrfs_disk_balance_args)
35355e301fdSFilipe Brandenburger  */
35455e301fdSFilipe Brandenburger struct btrfs_balance_args {
35555e301fdSFilipe Brandenburger 	__u64 profiles;
356a2813530SJosef Bacik 
357a2813530SJosef Bacik 	/*
358a2813530SJosef Bacik 	 * usage filter
359a2813530SJosef Bacik 	 * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N'
360a2813530SJosef Bacik 	 * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max
361a2813530SJosef Bacik 	 */
362bc309467SDavid Sterba 	union {
363261cc2ccSHans van Kranenburg 		__u64 usage;
364bc309467SDavid Sterba 		struct {
365261cc2ccSHans van Kranenburg 			__u32 usage_min;
366261cc2ccSHans van Kranenburg 			__u32 usage_max;
367bc309467SDavid Sterba 		};
368bc309467SDavid Sterba 	};
36955e301fdSFilipe Brandenburger 	__u64 devid;
37055e301fdSFilipe Brandenburger 	__u64 pstart;
37155e301fdSFilipe Brandenburger 	__u64 pend;
37255e301fdSFilipe Brandenburger 	__u64 vstart;
37355e301fdSFilipe Brandenburger 	__u64 vend;
37455e301fdSFilipe Brandenburger 
37555e301fdSFilipe Brandenburger 	__u64 target;
37655e301fdSFilipe Brandenburger 
37755e301fdSFilipe Brandenburger 	__u64 flags;
37855e301fdSFilipe Brandenburger 
37912907fc7SDavid Sterba 	/*
38012907fc7SDavid Sterba 	 * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
38112907fc7SDavid Sterba 	 * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
38212907fc7SDavid Sterba 	 * and maximum
38312907fc7SDavid Sterba 	 */
38412907fc7SDavid Sterba 	union {
3857d824b6fSDavid Sterba 		__u64 limit;		/* limit number of processed chunks */
38612907fc7SDavid Sterba 		struct {
38712907fc7SDavid Sterba 			__u32 limit_min;
38812907fc7SDavid Sterba 			__u32 limit_max;
38912907fc7SDavid Sterba 		};
39012907fc7SDavid Sterba 	};
391dee32d0aSGabríel Arthúr Pétursson 
392dee32d0aSGabríel Arthúr Pétursson 	/*
393dee32d0aSGabríel Arthúr Pétursson 	 * Process chunks that cross stripes_min..stripes_max devices,
394dee32d0aSGabríel Arthúr Pétursson 	 * BTRFS_BALANCE_ARGS_STRIPES_RANGE
395dee32d0aSGabríel Arthúr Pétursson 	 */
396261cc2ccSHans van Kranenburg 	__u32 stripes_min;
397261cc2ccSHans van Kranenburg 	__u32 stripes_max;
398dee32d0aSGabríel Arthúr Pétursson 
399dee32d0aSGabríel Arthúr Pétursson 	__u64 unused[6];
40055e301fdSFilipe Brandenburger } __attribute__ ((__packed__));
40155e301fdSFilipe Brandenburger 
40255e301fdSFilipe Brandenburger /* report balance progress to userspace */
40355e301fdSFilipe Brandenburger struct btrfs_balance_progress {
40455e301fdSFilipe Brandenburger 	__u64 expected;		/* estimated # of chunks that will be
40555e301fdSFilipe Brandenburger 				 * relocated to fulfill the request */
40655e301fdSFilipe Brandenburger 	__u64 considered;	/* # of chunks we have considered so far */
40755e301fdSFilipe Brandenburger 	__u64 completed;	/* # of chunks relocated so far */
40855e301fdSFilipe Brandenburger };
40955e301fdSFilipe Brandenburger 
41004cd01dfSJeff Mahoney /*
41104cd01dfSJeff Mahoney  * flags definition for balance
41204cd01dfSJeff Mahoney  *
41304cd01dfSJeff Mahoney  * Restriper's general type filter
41404cd01dfSJeff Mahoney  *
41504cd01dfSJeff Mahoney  * Used by:
41604cd01dfSJeff Mahoney  * btrfs_ioctl_balance_args.flags
41704cd01dfSJeff Mahoney  * btrfs_balance_control.flags (internal)
41804cd01dfSJeff Mahoney  */
41904cd01dfSJeff Mahoney #define BTRFS_BALANCE_DATA		(1ULL << 0)
42004cd01dfSJeff Mahoney #define BTRFS_BALANCE_SYSTEM		(1ULL << 1)
42104cd01dfSJeff Mahoney #define BTRFS_BALANCE_METADATA		(1ULL << 2)
42204cd01dfSJeff Mahoney 
42304cd01dfSJeff Mahoney #define BTRFS_BALANCE_TYPE_MASK		(BTRFS_BALANCE_DATA |	    \
42404cd01dfSJeff Mahoney 					 BTRFS_BALANCE_SYSTEM |	    \
42504cd01dfSJeff Mahoney 					 BTRFS_BALANCE_METADATA)
42604cd01dfSJeff Mahoney 
42704cd01dfSJeff Mahoney #define BTRFS_BALANCE_FORCE		(1ULL << 3)
42804cd01dfSJeff Mahoney #define BTRFS_BALANCE_RESUME		(1ULL << 4)
42904cd01dfSJeff Mahoney 
43004cd01dfSJeff Mahoney /*
43104cd01dfSJeff Mahoney  * flags definitions for per-type balance args
43204cd01dfSJeff Mahoney  *
43304cd01dfSJeff Mahoney  * Balance filters
43404cd01dfSJeff Mahoney  *
43504cd01dfSJeff Mahoney  * Used by:
43604cd01dfSJeff Mahoney  * struct btrfs_balance_args
43704cd01dfSJeff Mahoney  */
43804cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_PROFILES	(1ULL << 0)
43904cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_USAGE	(1ULL << 1)
44004cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_DEVID	(1ULL << 2)
44104cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_DRANGE	(1ULL << 3)
44204cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_VRANGE	(1ULL << 4)
44304cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_LIMIT	(1ULL << 5)
44404cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_LIMIT_RANGE	(1ULL << 6)
44504cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
44604cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_USAGE_RANGE	(1ULL << 10)
44704cd01dfSJeff Mahoney 
44804cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_MASK			\
44904cd01dfSJeff Mahoney 	(BTRFS_BALANCE_ARGS_PROFILES |		\
45004cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_USAGE |		\
45104cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_DEVID | 		\
45204cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_DRANGE |		\
45304cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_VRANGE |		\
45404cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_LIMIT |		\
45504cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_LIMIT_RANGE |	\
45604cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_STRIPES_RANGE |	\
45704cd01dfSJeff Mahoney 	 BTRFS_BALANCE_ARGS_USAGE_RANGE)
45804cd01dfSJeff Mahoney 
45904cd01dfSJeff Mahoney /*
46004cd01dfSJeff Mahoney  * Profile changing flags.  When SOFT is set we won't relocate chunk if
46104cd01dfSJeff Mahoney  * it already has the target profile (even though it may be
46204cd01dfSJeff Mahoney  * half-filled).
46304cd01dfSJeff Mahoney  */
46404cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_CONVERT	(1ULL << 8)
46504cd01dfSJeff Mahoney #define BTRFS_BALANCE_ARGS_SOFT		(1ULL << 9)
46604cd01dfSJeff Mahoney 
46704cd01dfSJeff Mahoney 
46804cd01dfSJeff Mahoney /*
46904cd01dfSJeff Mahoney  * flags definition for balance state
47004cd01dfSJeff Mahoney  *
47104cd01dfSJeff Mahoney  * Used by:
47204cd01dfSJeff Mahoney  * struct btrfs_ioctl_balance_args.state
47304cd01dfSJeff Mahoney  */
47455e301fdSFilipe Brandenburger #define BTRFS_BALANCE_STATE_RUNNING	(1ULL << 0)
47555e301fdSFilipe Brandenburger #define BTRFS_BALANCE_STATE_PAUSE_REQ	(1ULL << 1)
47655e301fdSFilipe Brandenburger #define BTRFS_BALANCE_STATE_CANCEL_REQ	(1ULL << 2)
47755e301fdSFilipe Brandenburger 
47855e301fdSFilipe Brandenburger struct btrfs_ioctl_balance_args {
47955e301fdSFilipe Brandenburger 	__u64 flags;				/* in/out */
48055e301fdSFilipe Brandenburger 	__u64 state;				/* out */
48155e301fdSFilipe Brandenburger 
48255e301fdSFilipe Brandenburger 	struct btrfs_balance_args data;		/* in/out */
48355e301fdSFilipe Brandenburger 	struct btrfs_balance_args meta;		/* in/out */
48455e301fdSFilipe Brandenburger 	struct btrfs_balance_args sys;		/* in/out */
48555e301fdSFilipe Brandenburger 
48655e301fdSFilipe Brandenburger 	struct btrfs_balance_progress stat;	/* out */
48755e301fdSFilipe Brandenburger 
48855e301fdSFilipe Brandenburger 	__u64 unused[72];			/* pad to 1k */
48955e301fdSFilipe Brandenburger };
49055e301fdSFilipe Brandenburger 
49155e301fdSFilipe Brandenburger #define BTRFS_INO_LOOKUP_PATH_MAX 4080
49255e301fdSFilipe Brandenburger struct btrfs_ioctl_ino_lookup_args {
49355e301fdSFilipe Brandenburger 	__u64 treeid;
49455e301fdSFilipe Brandenburger 	__u64 objectid;
49555e301fdSFilipe Brandenburger 	char name[BTRFS_INO_LOOKUP_PATH_MAX];
49655e301fdSFilipe Brandenburger };
49755e301fdSFilipe Brandenburger 
49823d0b79dSTomohiro Misono #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
49923d0b79dSTomohiro Misono struct btrfs_ioctl_ino_lookup_user_args {
50023d0b79dSTomohiro Misono 	/* in, inode number containing the subvolume of 'subvolid' */
50123d0b79dSTomohiro Misono 	__u64 dirid;
50223d0b79dSTomohiro Misono 	/* in */
50323d0b79dSTomohiro Misono 	__u64 treeid;
50423d0b79dSTomohiro Misono 	/* out, name of the subvolume of 'treeid' */
50523d0b79dSTomohiro Misono 	char name[BTRFS_VOL_NAME_MAX + 1];
50623d0b79dSTomohiro Misono 	/*
50723d0b79dSTomohiro Misono 	 * out, constructed path from the directory with which the ioctl is
50823d0b79dSTomohiro Misono 	 * called to dirid
50923d0b79dSTomohiro Misono 	 */
51023d0b79dSTomohiro Misono 	char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
51123d0b79dSTomohiro Misono };
51223d0b79dSTomohiro Misono 
5131a63143dSHans van Kranenburg /* Search criteria for the btrfs SEARCH ioctl family. */
51455e301fdSFilipe Brandenburger struct btrfs_ioctl_search_key {
5151a63143dSHans van Kranenburg 	/*
5161a63143dSHans van Kranenburg 	 * The tree we're searching in. 1 is the tree of tree roots, 2 is the
5171a63143dSHans van Kranenburg 	 * extent tree, etc...
5181a63143dSHans van Kranenburg 	 *
5191a63143dSHans van Kranenburg 	 * A special tree_id value of 0 will cause a search in the subvolume
5201a63143dSHans van Kranenburg 	 * tree that the inode which is passed to the ioctl is part of.
5211a63143dSHans van Kranenburg 	 */
5221a63143dSHans van Kranenburg 	__u64 tree_id;		/* in */
52355e301fdSFilipe Brandenburger 
52455e301fdSFilipe Brandenburger 	/*
5251a63143dSHans van Kranenburg 	 * When doing a tree search, we're actually taking a slice from a
5261a63143dSHans van Kranenburg 	 * linear search space of 136-bit keys.
5271a63143dSHans van Kranenburg 	 *
5281a63143dSHans van Kranenburg 	 * A full 136-bit tree key is composed as:
5291a63143dSHans van Kranenburg 	 *   (objectid << 72) + (type << 64) + offset
5301a63143dSHans van Kranenburg 	 *
5311a63143dSHans van Kranenburg 	 * The individual min and max values for objectid, type and offset
5321a63143dSHans van Kranenburg 	 * define the min_key and max_key values for the search range. All
5331a63143dSHans van Kranenburg 	 * metadata items with a key in the interval [min_key, max_key] will be
5341a63143dSHans van Kranenburg 	 * returned.
5351a63143dSHans van Kranenburg 	 *
5361a63143dSHans van Kranenburg 	 * Additionally, we can filter the items returned on transaction id of
5371a63143dSHans van Kranenburg 	 * the metadata block they're stored in by specifying a transid range.
5381a63143dSHans van Kranenburg 	 * Be aware that this transaction id only denotes when the metadata
5391a63143dSHans van Kranenburg 	 * page that currently contains the item got written the last time as
5401a63143dSHans van Kranenburg 	 * result of a COW operation.  The number does not have any meaning
5411a63143dSHans van Kranenburg 	 * related to the transaction in which an individual item that is being
5421a63143dSHans van Kranenburg 	 * returned was created or changed.
54355e301fdSFilipe Brandenburger 	 */
5441a63143dSHans van Kranenburg 	__u64 min_objectid;	/* in */
5451a63143dSHans van Kranenburg 	__u64 max_objectid;	/* in */
5461a63143dSHans van Kranenburg 	__u64 min_offset;	/* in */
5471a63143dSHans van Kranenburg 	__u64 max_offset;	/* in */
5481a63143dSHans van Kranenburg 	__u64 min_transid;	/* in */
5491a63143dSHans van Kranenburg 	__u64 max_transid;	/* in */
5501a63143dSHans van Kranenburg 	__u32 min_type;		/* in */
5511a63143dSHans van Kranenburg 	__u32 max_type;		/* in */
5521a63143dSHans van Kranenburg 
5531a63143dSHans van Kranenburg 	/*
5541a63143dSHans van Kranenburg 	 * input: The maximum amount of results desired.
5551a63143dSHans van Kranenburg 	 * output: The actual amount of items returned, restricted by any of:
5561a63143dSHans van Kranenburg 	 *  - reaching the upper bound of the search range
5571a63143dSHans van Kranenburg 	 *  - reaching the input nr_items amount of items
5581a63143dSHans van Kranenburg 	 *  - completely filling the supplied memory buffer
5591a63143dSHans van Kranenburg 	 */
5601a63143dSHans van Kranenburg 	__u32 nr_items;		/* in/out */
56155e301fdSFilipe Brandenburger 
56255e301fdSFilipe Brandenburger 	/* align to 64 bits */
56355e301fdSFilipe Brandenburger 	__u32 unused;
56455e301fdSFilipe Brandenburger 
56555e301fdSFilipe Brandenburger 	/* some extra for later */
56655e301fdSFilipe Brandenburger 	__u64 unused1;
56755e301fdSFilipe Brandenburger 	__u64 unused2;
56855e301fdSFilipe Brandenburger 	__u64 unused3;
56955e301fdSFilipe Brandenburger 	__u64 unused4;
57055e301fdSFilipe Brandenburger };
57155e301fdSFilipe Brandenburger 
57255e301fdSFilipe Brandenburger struct btrfs_ioctl_search_header {
57355e301fdSFilipe Brandenburger 	__u64 transid;
57455e301fdSFilipe Brandenburger 	__u64 objectid;
57555e301fdSFilipe Brandenburger 	__u64 offset;
57655e301fdSFilipe Brandenburger 	__u32 type;
57755e301fdSFilipe Brandenburger 	__u32 len;
578a2813530SJosef Bacik } __attribute__ ((__may_alias__));
57955e301fdSFilipe Brandenburger 
58055e301fdSFilipe Brandenburger #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
58155e301fdSFilipe Brandenburger /*
58255e301fdSFilipe Brandenburger  * the buf is an array of search headers where
58355e301fdSFilipe Brandenburger  * each header is followed by the actual item
58455e301fdSFilipe Brandenburger  * the type field is expanded to 32 bits for alignment
58555e301fdSFilipe Brandenburger  */
58655e301fdSFilipe Brandenburger struct btrfs_ioctl_search_args {
58755e301fdSFilipe Brandenburger 	struct btrfs_ioctl_search_key key;
58855e301fdSFilipe Brandenburger 	char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
58955e301fdSFilipe Brandenburger };
59055e301fdSFilipe Brandenburger 
591a2813530SJosef Bacik /*
592a2813530SJosef Bacik  * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes.
593a2813530SJosef Bacik  * The allocated size of the buffer is set in buf_size.
594a2813530SJosef Bacik  */
595cc68a8a5SGerhard Heift struct btrfs_ioctl_search_args_v2 {
596cc68a8a5SGerhard Heift 	struct btrfs_ioctl_search_key key; /* in/out - search parameters */
597cc68a8a5SGerhard Heift 	__u64 buf_size;		   /* in - size of buffer
598cc68a8a5SGerhard Heift 					    * out - on EOVERFLOW: needed size
599cc68a8a5SGerhard Heift 					    *       to store item */
60094dfc73eSGustavo A. R. Silva 	__u64 buf[];                       /* out - found items */
601cc68a8a5SGerhard Heift };
602cc68a8a5SGerhard Heift 
603a2813530SJosef Bacik /* With a @src_length of zero, the range from @src_offset->EOF is cloned! */
60455e301fdSFilipe Brandenburger struct btrfs_ioctl_clone_range_args {
60555e301fdSFilipe Brandenburger 	__s64 src_fd;
60655e301fdSFilipe Brandenburger 	__u64 src_offset, src_length;
60755e301fdSFilipe Brandenburger 	__u64 dest_offset;
60855e301fdSFilipe Brandenburger };
60955e301fdSFilipe Brandenburger 
61033ca9133SJeff Mahoney /*
61133ca9133SJeff Mahoney  * flags definition for the defrag range ioctl
61233ca9133SJeff Mahoney  *
61333ca9133SJeff Mahoney  * Used by:
61433ca9133SJeff Mahoney  * struct btrfs_ioctl_defrag_range_args.flags
61533ca9133SJeff Mahoney  */
61655e301fdSFilipe Brandenburger #define BTRFS_DEFRAG_RANGE_COMPRESS 1
61755e301fdSFilipe Brandenburger #define BTRFS_DEFRAG_RANGE_START_IO 2
618173431b2SQu Wenruo #define BTRFS_DEFRAG_RANGE_FLAGS_SUPP	(BTRFS_DEFRAG_RANGE_COMPRESS |		\
619173431b2SQu Wenruo 					 BTRFS_DEFRAG_RANGE_START_IO)
620173431b2SQu Wenruo 
62133ca9133SJeff Mahoney struct btrfs_ioctl_defrag_range_args {
62233ca9133SJeff Mahoney 	/* start of the defrag operation */
62333ca9133SJeff Mahoney 	__u64 start;
62433ca9133SJeff Mahoney 
62533ca9133SJeff Mahoney 	/* number of bytes to defrag, use (u64)-1 to say all */
62633ca9133SJeff Mahoney 	__u64 len;
62733ca9133SJeff Mahoney 
62833ca9133SJeff Mahoney 	/*
62933ca9133SJeff Mahoney 	 * flags for the operation, which can include turning
63033ca9133SJeff Mahoney 	 * on compression for this one defrag
63133ca9133SJeff Mahoney 	 */
63233ca9133SJeff Mahoney 	__u64 flags;
63333ca9133SJeff Mahoney 
63433ca9133SJeff Mahoney 	/*
63533ca9133SJeff Mahoney 	 * any extent bigger than this will be considered
63633ca9133SJeff Mahoney 	 * already defragged.  Use 0 to take the kernel default
63733ca9133SJeff Mahoney 	 * Use 1 to say every single extent must be rewritten
63833ca9133SJeff Mahoney 	 */
63933ca9133SJeff Mahoney 	__u32 extent_thresh;
64033ca9133SJeff Mahoney 
64133ca9133SJeff Mahoney 	/*
64233ca9133SJeff Mahoney 	 * which compression method to use if turning on compression
64333ca9133SJeff Mahoney 	 * for this defrag operation.  If unspecified, zlib will
64433ca9133SJeff Mahoney 	 * be used
64533ca9133SJeff Mahoney 	 */
64633ca9133SJeff Mahoney 	__u32 compress_type;
64733ca9133SJeff Mahoney 
64833ca9133SJeff Mahoney 	/* spare for later */
64933ca9133SJeff Mahoney 	__u32 unused[4];
65033ca9133SJeff Mahoney };
65133ca9133SJeff Mahoney 
65255e301fdSFilipe Brandenburger 
653416161dbSMark Fasheh #define BTRFS_SAME_DATA_DIFFERS	1
654416161dbSMark Fasheh /* For extent-same ioctl */
655416161dbSMark Fasheh struct btrfs_ioctl_same_extent_info {
656416161dbSMark Fasheh 	__s64 fd;		/* in - destination file */
657416161dbSMark Fasheh 	__u64 logical_offset;	/* in - start of extent in destination */
658416161dbSMark Fasheh 	__u64 bytes_deduped;	/* out - total # of bytes we were able
659416161dbSMark Fasheh 				 * to dedupe from this file */
660416161dbSMark Fasheh 	/* status of this dedupe operation:
661416161dbSMark Fasheh 	 * 0 if dedup succeeds
662416161dbSMark Fasheh 	 * < 0 for error
663416161dbSMark Fasheh 	 * == BTRFS_SAME_DATA_DIFFERS if data differs
664416161dbSMark Fasheh 	 */
665416161dbSMark Fasheh 	__s32 status;		/* out - see above description */
666416161dbSMark Fasheh 	__u32 reserved;
667416161dbSMark Fasheh };
668416161dbSMark Fasheh 
669416161dbSMark Fasheh struct btrfs_ioctl_same_args {
670416161dbSMark Fasheh 	__u64 logical_offset;	/* in - start of extent in source */
671416161dbSMark Fasheh 	__u64 length;		/* in - length of extent */
672416161dbSMark Fasheh 	__u16 dest_count;	/* in - total elements in info array */
673416161dbSMark Fasheh 	__u16 reserved1;
674416161dbSMark Fasheh 	__u32 reserved2;
67594dfc73eSGustavo A. R. Silva 	struct btrfs_ioctl_same_extent_info info[];
676416161dbSMark Fasheh };
677416161dbSMark Fasheh 
67855e301fdSFilipe Brandenburger struct btrfs_ioctl_space_info {
67955e301fdSFilipe Brandenburger 	__u64 flags;
68055e301fdSFilipe Brandenburger 	__u64 total_bytes;
68155e301fdSFilipe Brandenburger 	__u64 used_bytes;
68255e301fdSFilipe Brandenburger };
68355e301fdSFilipe Brandenburger 
68455e301fdSFilipe Brandenburger struct btrfs_ioctl_space_args {
68555e301fdSFilipe Brandenburger 	__u64 space_slots;
68655e301fdSFilipe Brandenburger 	__u64 total_spaces;
68794dfc73eSGustavo A. R. Silva 	struct btrfs_ioctl_space_info spaces[];
68855e301fdSFilipe Brandenburger };
68955e301fdSFilipe Brandenburger 
69055e301fdSFilipe Brandenburger struct btrfs_data_container {
69155e301fdSFilipe Brandenburger 	__u32	bytes_left;	/* out -- bytes not needed to deliver output */
69255e301fdSFilipe Brandenburger 	__u32	bytes_missing;	/* out -- additional bytes needed for result */
69355e301fdSFilipe Brandenburger 	__u32	elem_cnt;	/* out */
69455e301fdSFilipe Brandenburger 	__u32	elem_missed;	/* out */
69594dfc73eSGustavo A. R. Silva 	__u64	val[];		/* out */
69655e301fdSFilipe Brandenburger };
69755e301fdSFilipe Brandenburger 
69855e301fdSFilipe Brandenburger struct btrfs_ioctl_ino_path_args {
69955e301fdSFilipe Brandenburger 	__u64				inum;		/* in */
70055e301fdSFilipe Brandenburger 	__u64				size;		/* in */
70155e301fdSFilipe Brandenburger 	__u64				reserved[4];
70255e301fdSFilipe Brandenburger 	/* struct btrfs_data_container	*fspath;	   out */
70355e301fdSFilipe Brandenburger 	__u64				fspath;		/* out */
70455e301fdSFilipe Brandenburger };
70555e301fdSFilipe Brandenburger 
70655e301fdSFilipe Brandenburger struct btrfs_ioctl_logical_ino_args {
70755e301fdSFilipe Brandenburger 	__u64				logical;	/* in */
70855e301fdSFilipe Brandenburger 	__u64				size;		/* in */
709d24a67b2SZygo Blaxell 	__u64				reserved[3];	/* must be 0 for now */
710d24a67b2SZygo Blaxell 	__u64				flags;		/* in, v2 only */
71155e301fdSFilipe Brandenburger 	/* struct btrfs_data_container	*inodes;	out   */
71255e301fdSFilipe Brandenburger 	__u64				inodes;
71355e301fdSFilipe Brandenburger };
714a2813530SJosef Bacik 
715a2813530SJosef Bacik /*
716a2813530SJosef Bacik  * Return every ref to the extent, not just those containing logical block.
717a2813530SJosef Bacik  * Requires logical == extent bytenr.
718a2813530SJosef Bacik  */
719d24a67b2SZygo Blaxell #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET	(1ULL << 0)
72055e301fdSFilipe Brandenburger 
72155e301fdSFilipe Brandenburger enum btrfs_dev_stat_values {
72255e301fdSFilipe Brandenburger 	/* disk I/O failure stats */
72355e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
72455e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
72555e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
72655e301fdSFilipe Brandenburger 
72755e301fdSFilipe Brandenburger 	/* stats for indirect indications for I/O failures */
72855e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
72955e301fdSFilipe Brandenburger 					 * contents is illegal: this is an
73055e301fdSFilipe Brandenburger 					 * indication that the block was damaged
73155e301fdSFilipe Brandenburger 					 * during read or write, or written to
73255e301fdSFilipe Brandenburger 					 * wrong location or read from wrong
73355e301fdSFilipe Brandenburger 					 * location */
73455e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
73555e301fdSFilipe Brandenburger 					 * been written */
73655e301fdSFilipe Brandenburger 
73755e301fdSFilipe Brandenburger 	BTRFS_DEV_STAT_VALUES_MAX
73855e301fdSFilipe Brandenburger };
73955e301fdSFilipe Brandenburger 
74055e301fdSFilipe Brandenburger /* Reset statistics after reading; needs SYS_ADMIN capability */
74155e301fdSFilipe Brandenburger #define	BTRFS_DEV_STATS_RESET		(1ULL << 0)
74255e301fdSFilipe Brandenburger 
74355e301fdSFilipe Brandenburger struct btrfs_ioctl_get_dev_stats {
74455e301fdSFilipe Brandenburger 	__u64 devid;				/* in */
74555e301fdSFilipe Brandenburger 	__u64 nr_items;				/* in/out */
74655e301fdSFilipe Brandenburger 	__u64 flags;				/* in/out */
74755e301fdSFilipe Brandenburger 
74855e301fdSFilipe Brandenburger 	/* out values: */
74955e301fdSFilipe Brandenburger 	__u64 values[BTRFS_DEV_STAT_VALUES_MAX];
75055e301fdSFilipe Brandenburger 
75173a3ca20SHans van Kranenburg 	/*
75273a3ca20SHans van Kranenburg 	 * This pads the struct to 1032 bytes. It was originally meant to pad to
75373a3ca20SHans van Kranenburg 	 * 1024 bytes, but when adding the flags field, the padding calculation
75473a3ca20SHans van Kranenburg 	 * was not adjusted.
75573a3ca20SHans van Kranenburg 	 */
75673a3ca20SHans van Kranenburg 	__u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
75755e301fdSFilipe Brandenburger };
75855e301fdSFilipe Brandenburger 
75955e301fdSFilipe Brandenburger #define BTRFS_QUOTA_CTL_ENABLE	1
76055e301fdSFilipe Brandenburger #define BTRFS_QUOTA_CTL_DISABLE	2
7612f232036SJan Schmidt #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED	3
762182940f4SBoris Burkov #define BTRFS_QUOTA_CTL_ENABLE_SIMPLE_QUOTA 4
76355e301fdSFilipe Brandenburger struct btrfs_ioctl_quota_ctl_args {
76455e301fdSFilipe Brandenburger 	__u64 cmd;
76555e301fdSFilipe Brandenburger 	__u64 status;
76655e301fdSFilipe Brandenburger };
76755e301fdSFilipe Brandenburger 
7682f232036SJan Schmidt struct btrfs_ioctl_quota_rescan_args {
7692f232036SJan Schmidt 	__u64	flags;
7702f232036SJan Schmidt 	__u64   progress;
7712f232036SJan Schmidt 	__u64   reserved[6];
7722f232036SJan Schmidt };
7732f232036SJan Schmidt 
77455e301fdSFilipe Brandenburger struct btrfs_ioctl_qgroup_assign_args {
77555e301fdSFilipe Brandenburger 	__u64 assign;
77655e301fdSFilipe Brandenburger 	__u64 src;
77755e301fdSFilipe Brandenburger 	__u64 dst;
77855e301fdSFilipe Brandenburger };
77955e301fdSFilipe Brandenburger 
78055e301fdSFilipe Brandenburger struct btrfs_ioctl_qgroup_create_args {
78155e301fdSFilipe Brandenburger 	__u64 create;
78255e301fdSFilipe Brandenburger 	__u64 qgroupid;
78355e301fdSFilipe Brandenburger };
78455e301fdSFilipe Brandenburger struct btrfs_ioctl_timespec {
78555e301fdSFilipe Brandenburger 	__u64 sec;
78655e301fdSFilipe Brandenburger 	__u32 nsec;
78755e301fdSFilipe Brandenburger };
78855e301fdSFilipe Brandenburger 
78955e301fdSFilipe Brandenburger struct btrfs_ioctl_received_subvol_args {
79055e301fdSFilipe Brandenburger 	char	uuid[BTRFS_UUID_SIZE];	/* in */
79155e301fdSFilipe Brandenburger 	__u64	stransid;		/* in */
79255e301fdSFilipe Brandenburger 	__u64	rtransid;		/* out */
79355e301fdSFilipe Brandenburger 	struct btrfs_ioctl_timespec stime; /* in */
79455e301fdSFilipe Brandenburger 	struct btrfs_ioctl_timespec rtime; /* out */
79555e301fdSFilipe Brandenburger 	__u64	flags;			/* in */
79655e301fdSFilipe Brandenburger 	__u64	reserved[16];		/* in */
79755e301fdSFilipe Brandenburger };
79855e301fdSFilipe Brandenburger 
799cb95e7bfSMark Fasheh /*
800cb95e7bfSMark Fasheh  * Caller doesn't want file data in the send stream, even if the
801cb95e7bfSMark Fasheh  * search of clone sources doesn't find an extent. UPDATE_EXTENT
802cb95e7bfSMark Fasheh  * commands will be sent instead of WRITE commands.
803cb95e7bfSMark Fasheh  */
804cb95e7bfSMark Fasheh #define BTRFS_SEND_FLAG_NO_FILE_DATA		0x1
805c2c71324SStefan Behrens 
806c2c71324SStefan Behrens /*
807c2c71324SStefan Behrens  * Do not add the leading stream header. Used when multiple snapshots
808c2c71324SStefan Behrens  * are sent back to back.
809c2c71324SStefan Behrens  */
810c2c71324SStefan Behrens #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER	0x2
811c2c71324SStefan Behrens 
812c2c71324SStefan Behrens /*
813c2c71324SStefan Behrens  * Omit the command at the end of the stream that indicated the end
814c2c71324SStefan Behrens  * of the stream. This option is used when multiple snapshots are
815c2c71324SStefan Behrens  * sent back to back.
816c2c71324SStefan Behrens  */
817c2c71324SStefan Behrens #define BTRFS_SEND_FLAG_OMIT_END_CMD		0x4
818c2c71324SStefan Behrens 
819e77fbf99SDavid Sterba /*
820e77fbf99SDavid Sterba  * Read the protocol version in the structure
821e77fbf99SDavid Sterba  */
822e77fbf99SDavid Sterba #define BTRFS_SEND_FLAG_VERSION			0x8
823e77fbf99SDavid Sterba 
824b7c14f23SOmar Sandoval /*
825b7c14f23SOmar Sandoval  * Send compressed data using the ENCODED_WRITE command instead of decompressing
826b7c14f23SOmar Sandoval  * the data and sending it with the WRITE command. This requires protocol
827b7c14f23SOmar Sandoval  * version >= 2.
828b7c14f23SOmar Sandoval  */
829b7c14f23SOmar Sandoval #define BTRFS_SEND_FLAG_COMPRESSED		0x10
830b7c14f23SOmar Sandoval 
831c2c71324SStefan Behrens #define BTRFS_SEND_FLAG_MASK \
832c2c71324SStefan Behrens 	(BTRFS_SEND_FLAG_NO_FILE_DATA | \
833c2c71324SStefan Behrens 	 BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
834e77fbf99SDavid Sterba 	 BTRFS_SEND_FLAG_OMIT_END_CMD | \
835d6815592SOmar Sandoval 	 BTRFS_SEND_FLAG_VERSION | \
836d6815592SOmar Sandoval 	 BTRFS_SEND_FLAG_COMPRESSED)
837cb95e7bfSMark Fasheh 
83855e301fdSFilipe Brandenburger struct btrfs_ioctl_send_args {
83955e301fdSFilipe Brandenburger 	__s64 send_fd;			/* in */
84055e301fdSFilipe Brandenburger 	__u64 clone_sources_count;	/* in */
84155e301fdSFilipe Brandenburger 	__u64 __user *clone_sources;	/* in */
84255e301fdSFilipe Brandenburger 	__u64 parent_root;		/* in */
84355e301fdSFilipe Brandenburger 	__u64 flags;			/* in */
844e77fbf99SDavid Sterba 	__u32 version;			/* in */
845e77fbf99SDavid Sterba 	__u8  reserved[28];		/* in */
84655e301fdSFilipe Brandenburger };
84755e301fdSFilipe Brandenburger 
848b64ec075STomohiro Misono /*
849b64ec075STomohiro Misono  * Information about a fs tree root.
850b64ec075STomohiro Misono  *
851b64ec075STomohiro Misono  * All items are filled by the ioctl
852b64ec075STomohiro Misono  */
853b64ec075STomohiro Misono struct btrfs_ioctl_get_subvol_info_args {
854b64ec075STomohiro Misono 	/* Id of this subvolume */
855b64ec075STomohiro Misono 	__u64 treeid;
856b64ec075STomohiro Misono 
857b64ec075STomohiro Misono 	/* Name of this subvolume, used to get the real name at mount point */
858b64ec075STomohiro Misono 	char name[BTRFS_VOL_NAME_MAX + 1];
859b64ec075STomohiro Misono 
860b64ec075STomohiro Misono 	/*
861b64ec075STomohiro Misono 	 * Id of the subvolume which contains this subvolume.
862b64ec075STomohiro Misono 	 * Zero for top-level subvolume or a deleted subvolume.
863b64ec075STomohiro Misono 	 */
864b64ec075STomohiro Misono 	__u64 parent_id;
865b64ec075STomohiro Misono 
866b64ec075STomohiro Misono 	/*
867b64ec075STomohiro Misono 	 * Inode number of the directory which contains this subvolume.
868b64ec075STomohiro Misono 	 * Zero for top-level subvolume or a deleted subvolume
869b64ec075STomohiro Misono 	 */
870b64ec075STomohiro Misono 	__u64 dirid;
871b64ec075STomohiro Misono 
872b64ec075STomohiro Misono 	/* Latest transaction id of this subvolume */
873b64ec075STomohiro Misono 	__u64 generation;
874b64ec075STomohiro Misono 
875b64ec075STomohiro Misono 	/* Flags of this subvolume */
876b64ec075STomohiro Misono 	__u64 flags;
877b64ec075STomohiro Misono 
878b64ec075STomohiro Misono 	/* UUID of this subvolume */
879b64ec075STomohiro Misono 	__u8 uuid[BTRFS_UUID_SIZE];
880b64ec075STomohiro Misono 
881b64ec075STomohiro Misono 	/*
882b64ec075STomohiro Misono 	 * UUID of the subvolume of which this subvolume is a snapshot.
883b64ec075STomohiro Misono 	 * All zero for a non-snapshot subvolume.
884b64ec075STomohiro Misono 	 */
885b64ec075STomohiro Misono 	__u8 parent_uuid[BTRFS_UUID_SIZE];
886b64ec075STomohiro Misono 
887b64ec075STomohiro Misono 	/*
888b64ec075STomohiro Misono 	 * UUID of the subvolume from which this subvolume was received.
889b64ec075STomohiro Misono 	 * All zero for non-received subvolume.
890b64ec075STomohiro Misono 	 */
891b64ec075STomohiro Misono 	__u8 received_uuid[BTRFS_UUID_SIZE];
892b64ec075STomohiro Misono 
893b64ec075STomohiro Misono 	/* Transaction id indicating when change/create/send/receive happened */
894b64ec075STomohiro Misono 	__u64 ctransid;
895b64ec075STomohiro Misono 	__u64 otransid;
896b64ec075STomohiro Misono 	__u64 stransid;
897b64ec075STomohiro Misono 	__u64 rtransid;
898b64ec075STomohiro Misono 	/* Time corresponding to c/o/s/rtransid */
899b64ec075STomohiro Misono 	struct btrfs_ioctl_timespec ctime;
900b64ec075STomohiro Misono 	struct btrfs_ioctl_timespec otime;
901b64ec075STomohiro Misono 	struct btrfs_ioctl_timespec stime;
902b64ec075STomohiro Misono 	struct btrfs_ioctl_timespec rtime;
903b64ec075STomohiro Misono 
904b64ec075STomohiro Misono 	/* Must be zero */
905b64ec075STomohiro Misono 	__u64 reserved[8];
906b64ec075STomohiro Misono };
907b64ec075STomohiro Misono 
90842e4b520STomohiro Misono #define BTRFS_MAX_ROOTREF_BUFFER_NUM 255
90942e4b520STomohiro Misono struct btrfs_ioctl_get_subvol_rootref_args {
91042e4b520STomohiro Misono 		/* in/out, minimum id of rootref's treeid to be searched */
91142e4b520STomohiro Misono 		__u64 min_treeid;
91242e4b520STomohiro Misono 
91342e4b520STomohiro Misono 		/* out */
91442e4b520STomohiro Misono 		struct {
91542e4b520STomohiro Misono 			__u64 treeid;
91642e4b520STomohiro Misono 			__u64 dirid;
91742e4b520STomohiro Misono 		} rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
91842e4b520STomohiro Misono 
91942e4b520STomohiro Misono 		/* out, number of found items */
92042e4b520STomohiro Misono 		__u8 num_items;
92142e4b520STomohiro Misono 		__u8 align[7];
92242e4b520STomohiro Misono };
92342e4b520STomohiro Misono 
924dcb77a9aSOmar Sandoval /*
925dcb77a9aSOmar Sandoval  * Data and metadata for an encoded read or write.
926dcb77a9aSOmar Sandoval  *
927dcb77a9aSOmar Sandoval  * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g.,
928dcb77a9aSOmar Sandoval  * compression). This can be used to read the compressed contents of a file or
929dcb77a9aSOmar Sandoval  * write pre-compressed data directly to a file.
930dcb77a9aSOmar Sandoval  *
931dcb77a9aSOmar Sandoval  * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially
932dcb77a9aSOmar Sandoval  * preadv/pwritev with additional metadata about how the data is encoded and the
933dcb77a9aSOmar Sandoval  * size of the unencoded data.
934dcb77a9aSOmar Sandoval  *
935dcb77a9aSOmar Sandoval  * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills
936dcb77a9aSOmar Sandoval  * the metadata fields, and returns the size of the encoded data. It reads one
937dcb77a9aSOmar Sandoval  * extent per call. It can also read data which is not encoded.
938dcb77a9aSOmar Sandoval  *
939dcb77a9aSOmar Sandoval  * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data
940dcb77a9aSOmar Sandoval  * from the iovecs, and returns the size of the encoded data. Note that the
941dcb77a9aSOmar Sandoval  * encoded data is not validated when it is written; if it is not valid (e.g.,
942dcb77a9aSOmar Sandoval  * it cannot be decompressed), then a subsequent read may return an error.
943dcb77a9aSOmar Sandoval  *
944dcb77a9aSOmar Sandoval  * Since the filesystem page cache contains decoded data, encoded I/O bypasses
945dcb77a9aSOmar Sandoval  * the page cache. Encoded I/O requires CAP_SYS_ADMIN.
946dcb77a9aSOmar Sandoval  */
947dcb77a9aSOmar Sandoval struct btrfs_ioctl_encoded_io_args {
948dcb77a9aSOmar Sandoval 	/* Input parameters for both reads and writes. */
949dcb77a9aSOmar Sandoval 
950dcb77a9aSOmar Sandoval 	/*
951dcb77a9aSOmar Sandoval 	 * iovecs containing encoded data.
952dcb77a9aSOmar Sandoval 	 *
953dcb77a9aSOmar Sandoval 	 * For reads, if the size of the encoded data is larger than the sum of
954dcb77a9aSOmar Sandoval 	 * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with
955dcb77a9aSOmar Sandoval 	 * ENOBUFS.
956dcb77a9aSOmar Sandoval 	 *
957dcb77a9aSOmar Sandoval 	 * For writes, the size of the encoded data is the sum of iov[n].iov_len
958dcb77a9aSOmar Sandoval 	 * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may
959dcb77a9aSOmar Sandoval 	 * increase in the future). This must also be less than or equal to
960dcb77a9aSOmar Sandoval 	 * unencoded_len.
961dcb77a9aSOmar Sandoval 	 */
962dcb77a9aSOmar Sandoval 	const struct iovec __user *iov;
963dcb77a9aSOmar Sandoval 	/* Number of iovecs. */
964dcb77a9aSOmar Sandoval 	unsigned long iovcnt;
965dcb77a9aSOmar Sandoval 	/*
966dcb77a9aSOmar Sandoval 	 * Offset in file.
967dcb77a9aSOmar Sandoval 	 *
968dcb77a9aSOmar Sandoval 	 * For writes, must be aligned to the sector size of the filesystem.
969dcb77a9aSOmar Sandoval 	 */
970dcb77a9aSOmar Sandoval 	__s64 offset;
971dcb77a9aSOmar Sandoval 	/* Currently must be zero. */
972dcb77a9aSOmar Sandoval 	__u64 flags;
973dcb77a9aSOmar Sandoval 
974dcb77a9aSOmar Sandoval 	/*
975dcb77a9aSOmar Sandoval 	 * For reads, the following members are output parameters that will
976dcb77a9aSOmar Sandoval 	 * contain the returned metadata for the encoded data.
977dcb77a9aSOmar Sandoval 	 * For writes, the following members must be set to the metadata for the
978dcb77a9aSOmar Sandoval 	 * encoded data.
979dcb77a9aSOmar Sandoval 	 */
980dcb77a9aSOmar Sandoval 
981dcb77a9aSOmar Sandoval 	/*
982dcb77a9aSOmar Sandoval 	 * Length of the data in the file.
983dcb77a9aSOmar Sandoval 	 *
984dcb77a9aSOmar Sandoval 	 * Must be less than or equal to unencoded_len - unencoded_offset. For
985dcb77a9aSOmar Sandoval 	 * writes, must be aligned to the sector size of the filesystem unless
986dcb77a9aSOmar Sandoval 	 * the data ends at or beyond the current end of the file.
987dcb77a9aSOmar Sandoval 	 */
988dcb77a9aSOmar Sandoval 	__u64 len;
989dcb77a9aSOmar Sandoval 	/*
990dcb77a9aSOmar Sandoval 	 * Length of the unencoded (i.e., decrypted and decompressed) data.
991dcb77a9aSOmar Sandoval 	 *
992dcb77a9aSOmar Sandoval 	 * For writes, must be no more than 128 KiB (this limit may increase in
993dcb77a9aSOmar Sandoval 	 * the future). If the unencoded data is actually longer than
994dcb77a9aSOmar Sandoval 	 * unencoded_len, then it is truncated; if it is shorter, then it is
995dcb77a9aSOmar Sandoval 	 * extended with zeroes.
996dcb77a9aSOmar Sandoval 	 */
997dcb77a9aSOmar Sandoval 	__u64 unencoded_len;
998dcb77a9aSOmar Sandoval 	/*
999dcb77a9aSOmar Sandoval 	 * Offset from the first byte of the unencoded data to the first byte of
1000dcb77a9aSOmar Sandoval 	 * logical data in the file.
1001dcb77a9aSOmar Sandoval 	 *
1002dcb77a9aSOmar Sandoval 	 * Must be less than unencoded_len.
1003dcb77a9aSOmar Sandoval 	 */
1004dcb77a9aSOmar Sandoval 	__u64 unencoded_offset;
1005dcb77a9aSOmar Sandoval 	/*
1006dcb77a9aSOmar Sandoval 	 * BTRFS_ENCODED_IO_COMPRESSION_* type.
1007dcb77a9aSOmar Sandoval 	 *
1008dcb77a9aSOmar Sandoval 	 * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE.
1009dcb77a9aSOmar Sandoval 	 */
1010dcb77a9aSOmar Sandoval 	__u32 compression;
1011dcb77a9aSOmar Sandoval 	/* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */
1012dcb77a9aSOmar Sandoval 	__u32 encryption;
1013dcb77a9aSOmar Sandoval 	/*
1014dcb77a9aSOmar Sandoval 	 * Reserved for future expansion.
1015dcb77a9aSOmar Sandoval 	 *
1016dcb77a9aSOmar Sandoval 	 * For reads, always returned as zero. Users should check for non-zero
1017dcb77a9aSOmar Sandoval 	 * bytes. If there are any, then the kernel has a newer version of this
1018dcb77a9aSOmar Sandoval 	 * structure with additional information that the user definition is
1019dcb77a9aSOmar Sandoval 	 * missing.
1020dcb77a9aSOmar Sandoval 	 *
1021dcb77a9aSOmar Sandoval 	 * For writes, must be zeroed.
1022dcb77a9aSOmar Sandoval 	 */
1023dcb77a9aSOmar Sandoval 	__u8 reserved[64];
1024dcb77a9aSOmar Sandoval };
1025dcb77a9aSOmar Sandoval 
1026dcb77a9aSOmar Sandoval /* Data is not compressed. */
1027dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_NONE 0
1028dcb77a9aSOmar Sandoval /* Data is compressed as a single zlib stream. */
1029dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1
1030dcb77a9aSOmar Sandoval /*
1031dcb77a9aSOmar Sandoval  * Data is compressed as a single zstd frame with the windowLog compression
1032dcb77a9aSOmar Sandoval  * parameter set to no more than 17.
1033dcb77a9aSOmar Sandoval  */
1034dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2
1035dcb77a9aSOmar Sandoval /*
1036dcb77a9aSOmar Sandoval  * Data is compressed sector by sector (using the sector size indicated by the
1037dcb77a9aSOmar Sandoval  * name of the constant) with LZO1X and wrapped in the format documented in
1038dcb77a9aSOmar Sandoval  * fs/btrfs/lzo.c. For writes, the compression sector size must match the
1039dcb77a9aSOmar Sandoval  * filesystem sector size.
1040dcb77a9aSOmar Sandoval  */
1041dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3
1042dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4
1043dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5
1044dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6
1045dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7
1046dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8
1047dcb77a9aSOmar Sandoval 
1048dcb77a9aSOmar Sandoval /* Data is not encrypted. */
1049dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0
1050dcb77a9aSOmar Sandoval #define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1
1051dcb77a9aSOmar Sandoval 
1052183860f6SAnand Jain /* Error codes as returned by the kernel */
1053183860f6SAnand Jain enum btrfs_err_code {
1054eb710b15SSatoru Takeuchi 	BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
1055183860f6SAnand Jain 	BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
1056183860f6SAnand Jain 	BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
1057183860f6SAnand Jain 	BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
1058183860f6SAnand Jain 	BTRFS_ERROR_DEV_TGT_REPLACE,
1059183860f6SAnand Jain 	BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
1060183860f6SAnand Jain 	BTRFS_ERROR_DEV_ONLY_WRITABLE,
106147e6f742SDavid Sterba 	BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS,
106247e6f742SDavid Sterba 	BTRFS_ERROR_DEV_RAID1C3_MIN_NOT_MET,
10638d6fac00SDavid Sterba 	BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET,
1064183860f6SAnand Jain };
1065183860f6SAnand Jain 
106655e301fdSFilipe Brandenburger #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
106755e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
106855e301fdSFilipe Brandenburger #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
106955e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
107055e301fdSFilipe Brandenburger #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
107155e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
107255e301fdSFilipe Brandenburger #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
107355e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
1074228a73abSAnand Jain #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \
1075228a73abSAnand Jain 				   struct btrfs_ioctl_vol_args)
107655e301fdSFilipe Brandenburger /* trans start and trans end are dangerous, and only for
107755e301fdSFilipe Brandenburger  * use by applications that know how to avoid the
107855e301fdSFilipe Brandenburger  * resulting deadlocks
107955e301fdSFilipe Brandenburger  */
108055e301fdSFilipe Brandenburger #define BTRFS_IOC_TRANS_START  _IO(BTRFS_IOCTL_MAGIC, 6)
108155e301fdSFilipe Brandenburger #define BTRFS_IOC_TRANS_END    _IO(BTRFS_IOCTL_MAGIC, 7)
108255e301fdSFilipe Brandenburger #define BTRFS_IOC_SYNC         _IO(BTRFS_IOCTL_MAGIC, 8)
108355e301fdSFilipe Brandenburger 
108455e301fdSFilipe Brandenburger #define BTRFS_IOC_CLONE        _IOW(BTRFS_IOCTL_MAGIC, 9, int)
108555e301fdSFilipe Brandenburger #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
108655e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
108755e301fdSFilipe Brandenburger #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
108855e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
108955e301fdSFilipe Brandenburger #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
109055e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
109155e301fdSFilipe Brandenburger 
109255e301fdSFilipe Brandenburger #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
109355e301fdSFilipe Brandenburger 				  struct btrfs_ioctl_clone_range_args)
109455e301fdSFilipe Brandenburger 
109555e301fdSFilipe Brandenburger #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
109655e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args)
109755e301fdSFilipe Brandenburger #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
109855e301fdSFilipe Brandenburger 				struct btrfs_ioctl_vol_args)
109955e301fdSFilipe Brandenburger #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
110055e301fdSFilipe Brandenburger 				struct btrfs_ioctl_defrag_range_args)
110155e301fdSFilipe Brandenburger #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
110255e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_search_args)
1103cc68a8a5SGerhard Heift #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
1104cc68a8a5SGerhard Heift 					   struct btrfs_ioctl_search_args_v2)
110555e301fdSFilipe Brandenburger #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
110655e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_ino_lookup_args)
110768b823efSMike Frysinger #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
110855e301fdSFilipe Brandenburger #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
110955e301fdSFilipe Brandenburger 				    struct btrfs_ioctl_space_args)
111055e301fdSFilipe Brandenburger #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
111155e301fdSFilipe Brandenburger #define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
111255e301fdSFilipe Brandenburger #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
111355e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args_v2)
111455e301fdSFilipe Brandenburger #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
111555e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_vol_args_v2)
111655e301fdSFilipe Brandenburger #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
111755e301fdSFilipe Brandenburger #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
111855e301fdSFilipe Brandenburger #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
111955e301fdSFilipe Brandenburger 			      struct btrfs_ioctl_scrub_args)
112055e301fdSFilipe Brandenburger #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
112155e301fdSFilipe Brandenburger #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
112255e301fdSFilipe Brandenburger 				       struct btrfs_ioctl_scrub_args)
112355e301fdSFilipe Brandenburger #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
112455e301fdSFilipe Brandenburger 				 struct btrfs_ioctl_dev_info_args)
112555e301fdSFilipe Brandenburger #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
112655e301fdSFilipe Brandenburger 			       struct btrfs_ioctl_fs_info_args)
112755e301fdSFilipe Brandenburger #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
112855e301fdSFilipe Brandenburger 				   struct btrfs_ioctl_balance_args)
112955e301fdSFilipe Brandenburger #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
113055e301fdSFilipe Brandenburger #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
113155e301fdSFilipe Brandenburger 					struct btrfs_ioctl_balance_args)
113255e301fdSFilipe Brandenburger #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
113355e301fdSFilipe Brandenburger 					struct btrfs_ioctl_ino_path_args)
113455e301fdSFilipe Brandenburger #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
11357af7c616SHans van Kranenburg 					struct btrfs_ioctl_logical_ino_args)
113655e301fdSFilipe Brandenburger #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
113755e301fdSFilipe Brandenburger 				struct btrfs_ioctl_received_subvol_args)
113855e301fdSFilipe Brandenburger #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
113955e301fdSFilipe Brandenburger #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
114055e301fdSFilipe Brandenburger 				     struct btrfs_ioctl_vol_args)
114155e301fdSFilipe Brandenburger #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
114255e301fdSFilipe Brandenburger 			       struct btrfs_ioctl_quota_ctl_args)
114355e301fdSFilipe Brandenburger #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
114455e301fdSFilipe Brandenburger 			       struct btrfs_ioctl_qgroup_assign_args)
114555e301fdSFilipe Brandenburger #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
114655e301fdSFilipe Brandenburger 			       struct btrfs_ioctl_qgroup_create_args)
114755e301fdSFilipe Brandenburger #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
114855e301fdSFilipe Brandenburger 			       struct btrfs_ioctl_qgroup_limit_args)
11492f232036SJan Schmidt #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
11502f232036SJan Schmidt 			       struct btrfs_ioctl_quota_rescan_args)
11512f232036SJan Schmidt #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
11522f232036SJan Schmidt 			       struct btrfs_ioctl_quota_rescan_args)
115357254b6eSJan Schmidt #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
115440cf931fSEric Sandeen #define BTRFS_IOC_GET_FSLABEL 	FS_IOC_GETFSLABEL
115540cf931fSEric Sandeen #define BTRFS_IOC_SET_FSLABEL	FS_IOC_SETFSLABEL
115655e301fdSFilipe Brandenburger #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
115755e301fdSFilipe Brandenburger 				      struct btrfs_ioctl_get_dev_stats)
115855e301fdSFilipe Brandenburger #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
115955e301fdSFilipe Brandenburger 				    struct btrfs_ioctl_dev_replace_args)
1160416161dbSMark Fasheh #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
1161416161dbSMark Fasheh 					 struct btrfs_ioctl_same_args)
11622eaa055fSJeff Mahoney #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
11632eaa055fSJeff Mahoney 				   struct btrfs_ioctl_feature_flags)
11642eaa055fSJeff Mahoney #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
11652eaa055fSJeff Mahoney 				   struct btrfs_ioctl_feature_flags[2])
11662eaa055fSJeff Mahoney #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
11672eaa055fSJeff Mahoney 				   struct btrfs_ioctl_feature_flags[3])
11686b526ed7SAnand Jain #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \
11696b526ed7SAnand Jain 				   struct btrfs_ioctl_vol_args_v2)
1170d24a67b2SZygo Blaxell #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \
1171d24a67b2SZygo Blaxell 					struct btrfs_ioctl_logical_ino_args)
1172b64ec075STomohiro Misono #define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \
1173b64ec075STomohiro Misono 				struct btrfs_ioctl_get_subvol_info_args)
117442e4b520STomohiro Misono #define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \
117542e4b520STomohiro Misono 				struct btrfs_ioctl_get_subvol_rootref_args)
117623d0b79dSTomohiro Misono #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
117723d0b79dSTomohiro Misono 				struct btrfs_ioctl_ino_lookup_user_args)
1178949964c9SMarcos Paulo de Souza #define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
1179949964c9SMarcos Paulo de Souza 				struct btrfs_ioctl_vol_args_v2)
1180dcb77a9aSOmar Sandoval #define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \
1181dcb77a9aSOmar Sandoval 				    struct btrfs_ioctl_encoded_io_args)
1182dcb77a9aSOmar Sandoval #define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \
1183dcb77a9aSOmar Sandoval 				     struct btrfs_ioctl_encoded_io_args)
1184416161dbSMark Fasheh 
1185a2813530SJosef Bacik #ifdef __cplusplus
1186a2813530SJosef Bacik }
1187a2813530SJosef Bacik #endif
1188a2813530SJosef Bacik 
118955e301fdSFilipe Brandenburger #endif /* _UAPI_LINUX_BTRFS_H */
1190