162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2007 Oracle. All rights reserved. 462306a36Sopenharmony_ci * 562306a36Sopenharmony_ci * This program is free software; you can redistribute it and/or 662306a36Sopenharmony_ci * modify it under the terms of the GNU General Public 762306a36Sopenharmony_ci * License v2 as published by the Free Software Foundation. 862306a36Sopenharmony_ci * 962306a36Sopenharmony_ci * This program is distributed in the hope that it will be useful, 1062306a36Sopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 1162306a36Sopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1262306a36Sopenharmony_ci * General Public License for more details. 1362306a36Sopenharmony_ci * 1462306a36Sopenharmony_ci * You should have received a copy of the GNU General Public 1562306a36Sopenharmony_ci * License along with this program; if not, write to the 1662306a36Sopenharmony_ci * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 1762306a36Sopenharmony_ci * Boston, MA 021110-1307, USA. 1862306a36Sopenharmony_ci */ 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#ifndef _UAPI_LINUX_BTRFS_H 2162306a36Sopenharmony_ci#define _UAPI_LINUX_BTRFS_H 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci#ifdef __cplusplus 2462306a36Sopenharmony_ciextern "C" { 2562306a36Sopenharmony_ci#endif 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ci#include <linux/types.h> 2862306a36Sopenharmony_ci#include <linux/ioctl.h> 2962306a36Sopenharmony_ci#include <linux/fs.h> 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci#define BTRFS_IOCTL_MAGIC 0x94 3262306a36Sopenharmony_ci#define BTRFS_VOL_NAME_MAX 255 3362306a36Sopenharmony_ci#define BTRFS_LABEL_SIZE 256 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* this should be 4k */ 3662306a36Sopenharmony_ci#define BTRFS_PATH_NAME_MAX 4087 3762306a36Sopenharmony_cistruct btrfs_ioctl_vol_args { 3862306a36Sopenharmony_ci __s64 fd; 3962306a36Sopenharmony_ci char name[BTRFS_PATH_NAME_MAX + 1]; 4062306a36Sopenharmony_ci}; 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_ci#define BTRFS_DEVICE_PATH_NAME_MAX 1024 4362306a36Sopenharmony_ci#define BTRFS_SUBVOL_NAME_MAX 4039 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_ci#ifndef __KERNEL__ 4662306a36Sopenharmony_ci/* Deprecated since 5.7 */ 4762306a36Sopenharmony_ci# define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0) 4862306a36Sopenharmony_ci#endif 4962306a36Sopenharmony_ci#define BTRFS_SUBVOL_RDONLY (1ULL << 1) 5062306a36Sopenharmony_ci#define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_ci#define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3) 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci#define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4) 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ci#define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \ 5762306a36Sopenharmony_ci (BTRFS_SUBVOL_RDONLY | \ 5862306a36Sopenharmony_ci BTRFS_SUBVOL_QGROUP_INHERIT | \ 5962306a36Sopenharmony_ci BTRFS_DEVICE_SPEC_BY_ID | \ 6062306a36Sopenharmony_ci BTRFS_SUBVOL_SPEC_BY_ID) 6162306a36Sopenharmony_ci 6262306a36Sopenharmony_ci#define BTRFS_FSID_SIZE 16 6362306a36Sopenharmony_ci#define BTRFS_UUID_SIZE 16 6462306a36Sopenharmony_ci#define BTRFS_UUID_UNPARSED_SIZE 37 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ci/* 6762306a36Sopenharmony_ci * flags definition for qgroup limits 6862306a36Sopenharmony_ci * 6962306a36Sopenharmony_ci * Used by: 7062306a36Sopenharmony_ci * struct btrfs_qgroup_limit.flags 7162306a36Sopenharmony_ci * struct btrfs_qgroup_limit_item.flags 7262306a36Sopenharmony_ci */ 7362306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0) 7462306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1) 7562306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2) 7662306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3) 7762306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4) 7862306a36Sopenharmony_ci#define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5) 7962306a36Sopenharmony_ci 8062306a36Sopenharmony_cistruct btrfs_qgroup_limit { 8162306a36Sopenharmony_ci __u64 flags; 8262306a36Sopenharmony_ci __u64 max_rfer; 8362306a36Sopenharmony_ci __u64 max_excl; 8462306a36Sopenharmony_ci __u64 rsv_rfer; 8562306a36Sopenharmony_ci __u64 rsv_excl; 8662306a36Sopenharmony_ci}; 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_ci/* 8962306a36Sopenharmony_ci * flags definition for qgroup inheritance 9062306a36Sopenharmony_ci * 9162306a36Sopenharmony_ci * Used by: 9262306a36Sopenharmony_ci * struct btrfs_qgroup_inherit.flags 9362306a36Sopenharmony_ci */ 9462306a36Sopenharmony_ci#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_cistruct btrfs_qgroup_inherit { 9762306a36Sopenharmony_ci __u64 flags; 9862306a36Sopenharmony_ci __u64 num_qgroups; 9962306a36Sopenharmony_ci __u64 num_ref_copies; 10062306a36Sopenharmony_ci __u64 num_excl_copies; 10162306a36Sopenharmony_ci struct btrfs_qgroup_limit lim; 10262306a36Sopenharmony_ci __u64 qgroups[]; 10362306a36Sopenharmony_ci}; 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_cistruct btrfs_ioctl_qgroup_limit_args { 10662306a36Sopenharmony_ci __u64 qgroupid; 10762306a36Sopenharmony_ci struct btrfs_qgroup_limit lim; 10862306a36Sopenharmony_ci}; 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci/* 11162306a36Sopenharmony_ci * Arguments for specification of subvolumes or devices, supporting by-name or 11262306a36Sopenharmony_ci * by-id and flags 11362306a36Sopenharmony_ci * 11462306a36Sopenharmony_ci * The set of supported flags depends on the ioctl 11562306a36Sopenharmony_ci * 11662306a36Sopenharmony_ci * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls: 11762306a36Sopenharmony_ci * - BTRFS_IOC_SUBVOL_GETFLAGS 11862306a36Sopenharmony_ci * - BTRFS_IOC_SUBVOL_SETFLAGS 11962306a36Sopenharmony_ci */ 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci/* Supported flags for BTRFS_IOC_RM_DEV_V2 */ 12262306a36Sopenharmony_ci#define BTRFS_DEVICE_REMOVE_ARGS_MASK \ 12362306a36Sopenharmony_ci (BTRFS_DEVICE_SPEC_BY_ID) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci/* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */ 12662306a36Sopenharmony_ci#define BTRFS_SUBVOL_CREATE_ARGS_MASK \ 12762306a36Sopenharmony_ci (BTRFS_SUBVOL_RDONLY | \ 12862306a36Sopenharmony_ci BTRFS_SUBVOL_QGROUP_INHERIT) 12962306a36Sopenharmony_ci 13062306a36Sopenharmony_ci/* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */ 13162306a36Sopenharmony_ci#define BTRFS_SUBVOL_DELETE_ARGS_MASK \ 13262306a36Sopenharmony_ci (BTRFS_SUBVOL_SPEC_BY_ID) 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_cistruct btrfs_ioctl_vol_args_v2 { 13562306a36Sopenharmony_ci __s64 fd; 13662306a36Sopenharmony_ci __u64 transid; 13762306a36Sopenharmony_ci __u64 flags; 13862306a36Sopenharmony_ci union { 13962306a36Sopenharmony_ci struct { 14062306a36Sopenharmony_ci __u64 size; 14162306a36Sopenharmony_ci struct btrfs_qgroup_inherit __user *qgroup_inherit; 14262306a36Sopenharmony_ci }; 14362306a36Sopenharmony_ci __u64 unused[4]; 14462306a36Sopenharmony_ci }; 14562306a36Sopenharmony_ci union { 14662306a36Sopenharmony_ci char name[BTRFS_SUBVOL_NAME_MAX + 1]; 14762306a36Sopenharmony_ci __u64 devid; 14862306a36Sopenharmony_ci __u64 subvolid; 14962306a36Sopenharmony_ci }; 15062306a36Sopenharmony_ci}; 15162306a36Sopenharmony_ci 15262306a36Sopenharmony_ci/* 15362306a36Sopenharmony_ci * structure to report errors and progress to userspace, either as a 15462306a36Sopenharmony_ci * result of a finished scrub, a canceled scrub or a progress inquiry 15562306a36Sopenharmony_ci */ 15662306a36Sopenharmony_cistruct btrfs_scrub_progress { 15762306a36Sopenharmony_ci __u64 data_extents_scrubbed; /* # of data extents scrubbed */ 15862306a36Sopenharmony_ci __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */ 15962306a36Sopenharmony_ci __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */ 16062306a36Sopenharmony_ci __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */ 16162306a36Sopenharmony_ci __u64 read_errors; /* # of read errors encountered (EIO) */ 16262306a36Sopenharmony_ci __u64 csum_errors; /* # of failed csum checks */ 16362306a36Sopenharmony_ci __u64 verify_errors; /* # of occurrences, where the metadata 16462306a36Sopenharmony_ci * of a tree block did not match the 16562306a36Sopenharmony_ci * expected values, like generation or 16662306a36Sopenharmony_ci * logical */ 16762306a36Sopenharmony_ci __u64 no_csum; /* # of 4k data block for which no csum 16862306a36Sopenharmony_ci * is present, probably the result of 16962306a36Sopenharmony_ci * data written with nodatasum */ 17062306a36Sopenharmony_ci __u64 csum_discards; /* # of csum for which no data was found 17162306a36Sopenharmony_ci * in the extent tree. */ 17262306a36Sopenharmony_ci __u64 super_errors; /* # of bad super blocks encountered */ 17362306a36Sopenharmony_ci __u64 malloc_errors; /* # of internal kmalloc errors. These 17462306a36Sopenharmony_ci * will likely cause an incomplete 17562306a36Sopenharmony_ci * scrub */ 17662306a36Sopenharmony_ci __u64 uncorrectable_errors; /* # of errors where either no intact 17762306a36Sopenharmony_ci * copy was found or the writeback 17862306a36Sopenharmony_ci * failed */ 17962306a36Sopenharmony_ci __u64 corrected_errors; /* # of errors corrected */ 18062306a36Sopenharmony_ci __u64 last_physical; /* last physical address scrubbed. In 18162306a36Sopenharmony_ci * case a scrub was aborted, this can 18262306a36Sopenharmony_ci * be used to restart the scrub */ 18362306a36Sopenharmony_ci __u64 unverified_errors; /* # of occurrences where a read for a 18462306a36Sopenharmony_ci * full (64k) bio failed, but the re- 18562306a36Sopenharmony_ci * check succeeded for each 4k piece. 18662306a36Sopenharmony_ci * Intermittent error. */ 18762306a36Sopenharmony_ci}; 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci#define BTRFS_SCRUB_READONLY 1 19062306a36Sopenharmony_ci#define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY) 19162306a36Sopenharmony_cistruct btrfs_ioctl_scrub_args { 19262306a36Sopenharmony_ci __u64 devid; /* in */ 19362306a36Sopenharmony_ci __u64 start; /* in */ 19462306a36Sopenharmony_ci __u64 end; /* in */ 19562306a36Sopenharmony_ci __u64 flags; /* in */ 19662306a36Sopenharmony_ci struct btrfs_scrub_progress progress; /* out */ 19762306a36Sopenharmony_ci /* pad to 1k */ 19862306a36Sopenharmony_ci __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; 19962306a36Sopenharmony_ci}; 20062306a36Sopenharmony_ci 20162306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 20262306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 20362306a36Sopenharmony_cistruct btrfs_ioctl_dev_replace_start_params { 20462306a36Sopenharmony_ci __u64 srcdevid; /* in, if 0, use srcdev_name instead */ 20562306a36Sopenharmony_ci __u64 cont_reading_from_srcdev_mode; /* in, see #define 20662306a36Sopenharmony_ci * above */ 20762306a36Sopenharmony_ci __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ 20862306a36Sopenharmony_ci __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ 20962306a36Sopenharmony_ci}; 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0 21262306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1 21362306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2 21462306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3 21562306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4 21662306a36Sopenharmony_cistruct btrfs_ioctl_dev_replace_status_params { 21762306a36Sopenharmony_ci __u64 replace_state; /* out, see #define above */ 21862306a36Sopenharmony_ci __u64 progress_1000; /* out, 0 <= x <= 1000 */ 21962306a36Sopenharmony_ci __u64 time_started; /* out, seconds since 1-Jan-1970 */ 22062306a36Sopenharmony_ci __u64 time_stopped; /* out, seconds since 1-Jan-1970 */ 22162306a36Sopenharmony_ci __u64 num_write_errors; /* out */ 22262306a36Sopenharmony_ci __u64 num_uncorrectable_read_errors; /* out */ 22362306a36Sopenharmony_ci}; 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0 22662306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1 22762306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2 22862306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0 22962306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1 23062306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2 23162306a36Sopenharmony_ci#define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3 23262306a36Sopenharmony_cistruct btrfs_ioctl_dev_replace_args { 23362306a36Sopenharmony_ci __u64 cmd; /* in */ 23462306a36Sopenharmony_ci __u64 result; /* out */ 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ci union { 23762306a36Sopenharmony_ci struct btrfs_ioctl_dev_replace_start_params start; 23862306a36Sopenharmony_ci struct btrfs_ioctl_dev_replace_status_params status; 23962306a36Sopenharmony_ci }; /* in/out */ 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci __u64 spare[64]; 24262306a36Sopenharmony_ci}; 24362306a36Sopenharmony_ci 24462306a36Sopenharmony_cistruct btrfs_ioctl_dev_info_args { 24562306a36Sopenharmony_ci __u64 devid; /* in/out */ 24662306a36Sopenharmony_ci __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ 24762306a36Sopenharmony_ci __u64 bytes_used; /* out */ 24862306a36Sopenharmony_ci __u64 total_bytes; /* out */ 24962306a36Sopenharmony_ci /* 25062306a36Sopenharmony_ci * Optional, out. 25162306a36Sopenharmony_ci * 25262306a36Sopenharmony_ci * Showing the fsid of the device, allowing user space to check if this 25362306a36Sopenharmony_ci * device is a seeding one. 25462306a36Sopenharmony_ci * 25562306a36Sopenharmony_ci * Introduced in v6.3, thus user space still needs to check if kernel 25662306a36Sopenharmony_ci * changed this value. Older kernel will not touch the values here. 25762306a36Sopenharmony_ci */ 25862306a36Sopenharmony_ci __u8 fsid[BTRFS_UUID_SIZE]; 25962306a36Sopenharmony_ci __u64 unused[377]; /* pad to 4k */ 26062306a36Sopenharmony_ci __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ 26162306a36Sopenharmony_ci}; 26262306a36Sopenharmony_ci 26362306a36Sopenharmony_ci/* 26462306a36Sopenharmony_ci * Retrieve information about the filesystem 26562306a36Sopenharmony_ci */ 26662306a36Sopenharmony_ci 26762306a36Sopenharmony_ci/* Request information about checksum type and size */ 26862306a36Sopenharmony_ci#define BTRFS_FS_INFO_FLAG_CSUM_INFO (1 << 0) 26962306a36Sopenharmony_ci 27062306a36Sopenharmony_ci/* Request information about filesystem generation */ 27162306a36Sopenharmony_ci#define BTRFS_FS_INFO_FLAG_GENERATION (1 << 1) 27262306a36Sopenharmony_ci/* Request information about filesystem metadata UUID */ 27362306a36Sopenharmony_ci#define BTRFS_FS_INFO_FLAG_METADATA_UUID (1 << 2) 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_cistruct btrfs_ioctl_fs_info_args { 27662306a36Sopenharmony_ci __u64 max_id; /* out */ 27762306a36Sopenharmony_ci __u64 num_devices; /* out */ 27862306a36Sopenharmony_ci __u8 fsid[BTRFS_FSID_SIZE]; /* out */ 27962306a36Sopenharmony_ci __u32 nodesize; /* out */ 28062306a36Sopenharmony_ci __u32 sectorsize; /* out */ 28162306a36Sopenharmony_ci __u32 clone_alignment; /* out */ 28262306a36Sopenharmony_ci /* See BTRFS_FS_INFO_FLAG_* */ 28362306a36Sopenharmony_ci __u16 csum_type; /* out */ 28462306a36Sopenharmony_ci __u16 csum_size; /* out */ 28562306a36Sopenharmony_ci __u64 flags; /* in/out */ 28662306a36Sopenharmony_ci __u64 generation; /* out */ 28762306a36Sopenharmony_ci __u8 metadata_uuid[BTRFS_FSID_SIZE]; /* out */ 28862306a36Sopenharmony_ci __u8 reserved[944]; /* pad to 1k */ 28962306a36Sopenharmony_ci}; 29062306a36Sopenharmony_ci 29162306a36Sopenharmony_ci/* 29262306a36Sopenharmony_ci * feature flags 29362306a36Sopenharmony_ci * 29462306a36Sopenharmony_ci * Used by: 29562306a36Sopenharmony_ci * struct btrfs_ioctl_feature_flags 29662306a36Sopenharmony_ci */ 29762306a36Sopenharmony_ci#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0) 29862306a36Sopenharmony_ci/* 29962306a36Sopenharmony_ci * Older kernels (< 4.9) on big-endian systems produced broken free space tree 30062306a36Sopenharmony_ci * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions 30162306a36Sopenharmony_ci * < 4.7.3). If this bit is clear, then the free space tree cannot be trusted. 30262306a36Sopenharmony_ci * btrfs-progs can also intentionally clear this bit to ask the kernel to 30362306a36Sopenharmony_ci * rebuild the free space tree, however this might not work on older kernels 30462306a36Sopenharmony_ci * that do not know about this bit. If not sure, clear the cache manually on 30562306a36Sopenharmony_ci * first mount when booting older kernel versions. 30662306a36Sopenharmony_ci */ 30762306a36Sopenharmony_ci#define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1) 30862306a36Sopenharmony_ci#define BTRFS_FEATURE_COMPAT_RO_VERITY (1ULL << 2) 30962306a36Sopenharmony_ci 31062306a36Sopenharmony_ci/* 31162306a36Sopenharmony_ci * Put all block group items into a dedicated block group tree, greatly 31262306a36Sopenharmony_ci * reducing mount time for large filesystem due to better locality. 31362306a36Sopenharmony_ci */ 31462306a36Sopenharmony_ci#define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE (1ULL << 3) 31562306a36Sopenharmony_ci 31662306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0) 31762306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1) 31862306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2) 31962306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3) 32062306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4) 32162306a36Sopenharmony_ci 32262306a36Sopenharmony_ci/* 32362306a36Sopenharmony_ci * older kernels tried to do bigger metadata blocks, but the 32462306a36Sopenharmony_ci * code was pretty buggy. Lets not let them try anymore. 32562306a36Sopenharmony_ci */ 32662306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5) 32762306a36Sopenharmony_ci 32862306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6) 32962306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7) 33062306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8) 33162306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9) 33262306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10) 33362306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11) 33462306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12) 33562306a36Sopenharmony_ci#define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13) 33662306a36Sopenharmony_ci 33762306a36Sopenharmony_cistruct btrfs_ioctl_feature_flags { 33862306a36Sopenharmony_ci __u64 compat_flags; 33962306a36Sopenharmony_ci __u64 compat_ro_flags; 34062306a36Sopenharmony_ci __u64 incompat_flags; 34162306a36Sopenharmony_ci}; 34262306a36Sopenharmony_ci 34362306a36Sopenharmony_ci/* balance control ioctl modes */ 34462306a36Sopenharmony_ci#define BTRFS_BALANCE_CTL_PAUSE 1 34562306a36Sopenharmony_ci#define BTRFS_BALANCE_CTL_CANCEL 2 34662306a36Sopenharmony_ci 34762306a36Sopenharmony_ci/* 34862306a36Sopenharmony_ci * this is packed, because it should be exactly the same as its disk 34962306a36Sopenharmony_ci * byte order counterpart (struct btrfs_disk_balance_args) 35062306a36Sopenharmony_ci */ 35162306a36Sopenharmony_cistruct btrfs_balance_args { 35262306a36Sopenharmony_ci __u64 profiles; 35362306a36Sopenharmony_ci 35462306a36Sopenharmony_ci /* 35562306a36Sopenharmony_ci * usage filter 35662306a36Sopenharmony_ci * BTRFS_BALANCE_ARGS_USAGE with a single value means '0..N' 35762306a36Sopenharmony_ci * BTRFS_BALANCE_ARGS_USAGE_RANGE - range syntax, min..max 35862306a36Sopenharmony_ci */ 35962306a36Sopenharmony_ci union { 36062306a36Sopenharmony_ci __u64 usage; 36162306a36Sopenharmony_ci struct { 36262306a36Sopenharmony_ci __u32 usage_min; 36362306a36Sopenharmony_ci __u32 usage_max; 36462306a36Sopenharmony_ci }; 36562306a36Sopenharmony_ci }; 36662306a36Sopenharmony_ci __u64 devid; 36762306a36Sopenharmony_ci __u64 pstart; 36862306a36Sopenharmony_ci __u64 pend; 36962306a36Sopenharmony_ci __u64 vstart; 37062306a36Sopenharmony_ci __u64 vend; 37162306a36Sopenharmony_ci 37262306a36Sopenharmony_ci __u64 target; 37362306a36Sopenharmony_ci 37462306a36Sopenharmony_ci __u64 flags; 37562306a36Sopenharmony_ci 37662306a36Sopenharmony_ci /* 37762306a36Sopenharmony_ci * BTRFS_BALANCE_ARGS_LIMIT with value 'limit' 37862306a36Sopenharmony_ci * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum 37962306a36Sopenharmony_ci * and maximum 38062306a36Sopenharmony_ci */ 38162306a36Sopenharmony_ci union { 38262306a36Sopenharmony_ci __u64 limit; /* limit number of processed chunks */ 38362306a36Sopenharmony_ci struct { 38462306a36Sopenharmony_ci __u32 limit_min; 38562306a36Sopenharmony_ci __u32 limit_max; 38662306a36Sopenharmony_ci }; 38762306a36Sopenharmony_ci }; 38862306a36Sopenharmony_ci 38962306a36Sopenharmony_ci /* 39062306a36Sopenharmony_ci * Process chunks that cross stripes_min..stripes_max devices, 39162306a36Sopenharmony_ci * BTRFS_BALANCE_ARGS_STRIPES_RANGE 39262306a36Sopenharmony_ci */ 39362306a36Sopenharmony_ci __u32 stripes_min; 39462306a36Sopenharmony_ci __u32 stripes_max; 39562306a36Sopenharmony_ci 39662306a36Sopenharmony_ci __u64 unused[6]; 39762306a36Sopenharmony_ci} __attribute__ ((__packed__)); 39862306a36Sopenharmony_ci 39962306a36Sopenharmony_ci/* report balance progress to userspace */ 40062306a36Sopenharmony_cistruct btrfs_balance_progress { 40162306a36Sopenharmony_ci __u64 expected; /* estimated # of chunks that will be 40262306a36Sopenharmony_ci * relocated to fulfill the request */ 40362306a36Sopenharmony_ci __u64 considered; /* # of chunks we have considered so far */ 40462306a36Sopenharmony_ci __u64 completed; /* # of chunks relocated so far */ 40562306a36Sopenharmony_ci}; 40662306a36Sopenharmony_ci 40762306a36Sopenharmony_ci/* 40862306a36Sopenharmony_ci * flags definition for balance 40962306a36Sopenharmony_ci * 41062306a36Sopenharmony_ci * Restriper's general type filter 41162306a36Sopenharmony_ci * 41262306a36Sopenharmony_ci * Used by: 41362306a36Sopenharmony_ci * btrfs_ioctl_balance_args.flags 41462306a36Sopenharmony_ci * btrfs_balance_control.flags (internal) 41562306a36Sopenharmony_ci */ 41662306a36Sopenharmony_ci#define BTRFS_BALANCE_DATA (1ULL << 0) 41762306a36Sopenharmony_ci#define BTRFS_BALANCE_SYSTEM (1ULL << 1) 41862306a36Sopenharmony_ci#define BTRFS_BALANCE_METADATA (1ULL << 2) 41962306a36Sopenharmony_ci 42062306a36Sopenharmony_ci#define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \ 42162306a36Sopenharmony_ci BTRFS_BALANCE_SYSTEM | \ 42262306a36Sopenharmony_ci BTRFS_BALANCE_METADATA) 42362306a36Sopenharmony_ci 42462306a36Sopenharmony_ci#define BTRFS_BALANCE_FORCE (1ULL << 3) 42562306a36Sopenharmony_ci#define BTRFS_BALANCE_RESUME (1ULL << 4) 42662306a36Sopenharmony_ci 42762306a36Sopenharmony_ci/* 42862306a36Sopenharmony_ci * flags definitions for per-type balance args 42962306a36Sopenharmony_ci * 43062306a36Sopenharmony_ci * Balance filters 43162306a36Sopenharmony_ci * 43262306a36Sopenharmony_ci * Used by: 43362306a36Sopenharmony_ci * struct btrfs_balance_args 43462306a36Sopenharmony_ci */ 43562306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0) 43662306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1) 43762306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2) 43862306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3) 43962306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4) 44062306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) 44162306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6) 44262306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7) 44362306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10) 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_MASK \ 44662306a36Sopenharmony_ci (BTRFS_BALANCE_ARGS_PROFILES | \ 44762306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_USAGE | \ 44862306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_DEVID | \ 44962306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_DRANGE | \ 45062306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_VRANGE | \ 45162306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_LIMIT | \ 45262306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_LIMIT_RANGE | \ 45362306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_STRIPES_RANGE | \ 45462306a36Sopenharmony_ci BTRFS_BALANCE_ARGS_USAGE_RANGE) 45562306a36Sopenharmony_ci 45662306a36Sopenharmony_ci/* 45762306a36Sopenharmony_ci * Profile changing flags. When SOFT is set we won't relocate chunk if 45862306a36Sopenharmony_ci * it already has the target profile (even though it may be 45962306a36Sopenharmony_ci * half-filled). 46062306a36Sopenharmony_ci */ 46162306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8) 46262306a36Sopenharmony_ci#define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9) 46362306a36Sopenharmony_ci 46462306a36Sopenharmony_ci 46562306a36Sopenharmony_ci/* 46662306a36Sopenharmony_ci * flags definition for balance state 46762306a36Sopenharmony_ci * 46862306a36Sopenharmony_ci * Used by: 46962306a36Sopenharmony_ci * struct btrfs_ioctl_balance_args.state 47062306a36Sopenharmony_ci */ 47162306a36Sopenharmony_ci#define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0) 47262306a36Sopenharmony_ci#define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1) 47362306a36Sopenharmony_ci#define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2) 47462306a36Sopenharmony_ci 47562306a36Sopenharmony_cistruct btrfs_ioctl_balance_args { 47662306a36Sopenharmony_ci __u64 flags; /* in/out */ 47762306a36Sopenharmony_ci __u64 state; /* out */ 47862306a36Sopenharmony_ci 47962306a36Sopenharmony_ci struct btrfs_balance_args data; /* in/out */ 48062306a36Sopenharmony_ci struct btrfs_balance_args meta; /* in/out */ 48162306a36Sopenharmony_ci struct btrfs_balance_args sys; /* in/out */ 48262306a36Sopenharmony_ci 48362306a36Sopenharmony_ci struct btrfs_balance_progress stat; /* out */ 48462306a36Sopenharmony_ci 48562306a36Sopenharmony_ci __u64 unused[72]; /* pad to 1k */ 48662306a36Sopenharmony_ci}; 48762306a36Sopenharmony_ci 48862306a36Sopenharmony_ci#define BTRFS_INO_LOOKUP_PATH_MAX 4080 48962306a36Sopenharmony_cistruct btrfs_ioctl_ino_lookup_args { 49062306a36Sopenharmony_ci __u64 treeid; 49162306a36Sopenharmony_ci __u64 objectid; 49262306a36Sopenharmony_ci char name[BTRFS_INO_LOOKUP_PATH_MAX]; 49362306a36Sopenharmony_ci}; 49462306a36Sopenharmony_ci 49562306a36Sopenharmony_ci#define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1) 49662306a36Sopenharmony_cistruct btrfs_ioctl_ino_lookup_user_args { 49762306a36Sopenharmony_ci /* in, inode number containing the subvolume of 'subvolid' */ 49862306a36Sopenharmony_ci __u64 dirid; 49962306a36Sopenharmony_ci /* in */ 50062306a36Sopenharmony_ci __u64 treeid; 50162306a36Sopenharmony_ci /* out, name of the subvolume of 'treeid' */ 50262306a36Sopenharmony_ci char name[BTRFS_VOL_NAME_MAX + 1]; 50362306a36Sopenharmony_ci /* 50462306a36Sopenharmony_ci * out, constructed path from the directory with which the ioctl is 50562306a36Sopenharmony_ci * called to dirid 50662306a36Sopenharmony_ci */ 50762306a36Sopenharmony_ci char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; 50862306a36Sopenharmony_ci}; 50962306a36Sopenharmony_ci 51062306a36Sopenharmony_ci/* Search criteria for the btrfs SEARCH ioctl family. */ 51162306a36Sopenharmony_cistruct btrfs_ioctl_search_key { 51262306a36Sopenharmony_ci /* 51362306a36Sopenharmony_ci * The tree we're searching in. 1 is the tree of tree roots, 2 is the 51462306a36Sopenharmony_ci * extent tree, etc... 51562306a36Sopenharmony_ci * 51662306a36Sopenharmony_ci * A special tree_id value of 0 will cause a search in the subvolume 51762306a36Sopenharmony_ci * tree that the inode which is passed to the ioctl is part of. 51862306a36Sopenharmony_ci */ 51962306a36Sopenharmony_ci __u64 tree_id; /* in */ 52062306a36Sopenharmony_ci 52162306a36Sopenharmony_ci /* 52262306a36Sopenharmony_ci * When doing a tree search, we're actually taking a slice from a 52362306a36Sopenharmony_ci * linear search space of 136-bit keys. 52462306a36Sopenharmony_ci * 52562306a36Sopenharmony_ci * A full 136-bit tree key is composed as: 52662306a36Sopenharmony_ci * (objectid << 72) + (type << 64) + offset 52762306a36Sopenharmony_ci * 52862306a36Sopenharmony_ci * The individual min and max values for objectid, type and offset 52962306a36Sopenharmony_ci * define the min_key and max_key values for the search range. All 53062306a36Sopenharmony_ci * metadata items with a key in the interval [min_key, max_key] will be 53162306a36Sopenharmony_ci * returned. 53262306a36Sopenharmony_ci * 53362306a36Sopenharmony_ci * Additionally, we can filter the items returned on transaction id of 53462306a36Sopenharmony_ci * the metadata block they're stored in by specifying a transid range. 53562306a36Sopenharmony_ci * Be aware that this transaction id only denotes when the metadata 53662306a36Sopenharmony_ci * page that currently contains the item got written the last time as 53762306a36Sopenharmony_ci * result of a COW operation. The number does not have any meaning 53862306a36Sopenharmony_ci * related to the transaction in which an individual item that is being 53962306a36Sopenharmony_ci * returned was created or changed. 54062306a36Sopenharmony_ci */ 54162306a36Sopenharmony_ci __u64 min_objectid; /* in */ 54262306a36Sopenharmony_ci __u64 max_objectid; /* in */ 54362306a36Sopenharmony_ci __u64 min_offset; /* in */ 54462306a36Sopenharmony_ci __u64 max_offset; /* in */ 54562306a36Sopenharmony_ci __u64 min_transid; /* in */ 54662306a36Sopenharmony_ci __u64 max_transid; /* in */ 54762306a36Sopenharmony_ci __u32 min_type; /* in */ 54862306a36Sopenharmony_ci __u32 max_type; /* in */ 54962306a36Sopenharmony_ci 55062306a36Sopenharmony_ci /* 55162306a36Sopenharmony_ci * input: The maximum amount of results desired. 55262306a36Sopenharmony_ci * output: The actual amount of items returned, restricted by any of: 55362306a36Sopenharmony_ci * - reaching the upper bound of the search range 55462306a36Sopenharmony_ci * - reaching the input nr_items amount of items 55562306a36Sopenharmony_ci * - completely filling the supplied memory buffer 55662306a36Sopenharmony_ci */ 55762306a36Sopenharmony_ci __u32 nr_items; /* in/out */ 55862306a36Sopenharmony_ci 55962306a36Sopenharmony_ci /* align to 64 bits */ 56062306a36Sopenharmony_ci __u32 unused; 56162306a36Sopenharmony_ci 56262306a36Sopenharmony_ci /* some extra for later */ 56362306a36Sopenharmony_ci __u64 unused1; 56462306a36Sopenharmony_ci __u64 unused2; 56562306a36Sopenharmony_ci __u64 unused3; 56662306a36Sopenharmony_ci __u64 unused4; 56762306a36Sopenharmony_ci}; 56862306a36Sopenharmony_ci 56962306a36Sopenharmony_cistruct btrfs_ioctl_search_header { 57062306a36Sopenharmony_ci __u64 transid; 57162306a36Sopenharmony_ci __u64 objectid; 57262306a36Sopenharmony_ci __u64 offset; 57362306a36Sopenharmony_ci __u32 type; 57462306a36Sopenharmony_ci __u32 len; 57562306a36Sopenharmony_ci} __attribute__ ((__may_alias__)); 57662306a36Sopenharmony_ci 57762306a36Sopenharmony_ci#define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) 57862306a36Sopenharmony_ci/* 57962306a36Sopenharmony_ci * the buf is an array of search headers where 58062306a36Sopenharmony_ci * each header is followed by the actual item 58162306a36Sopenharmony_ci * the type field is expanded to 32 bits for alignment 58262306a36Sopenharmony_ci */ 58362306a36Sopenharmony_cistruct btrfs_ioctl_search_args { 58462306a36Sopenharmony_ci struct btrfs_ioctl_search_key key; 58562306a36Sopenharmony_ci char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; 58662306a36Sopenharmony_ci}; 58762306a36Sopenharmony_ci 58862306a36Sopenharmony_ci/* 58962306a36Sopenharmony_ci * Extended version of TREE_SEARCH ioctl that can return more than 4k of bytes. 59062306a36Sopenharmony_ci * The allocated size of the buffer is set in buf_size. 59162306a36Sopenharmony_ci */ 59262306a36Sopenharmony_cistruct btrfs_ioctl_search_args_v2 { 59362306a36Sopenharmony_ci struct btrfs_ioctl_search_key key; /* in/out - search parameters */ 59462306a36Sopenharmony_ci __u64 buf_size; /* in - size of buffer 59562306a36Sopenharmony_ci * out - on EOVERFLOW: needed size 59662306a36Sopenharmony_ci * to store item */ 59762306a36Sopenharmony_ci __u64 buf[]; /* out - found items */ 59862306a36Sopenharmony_ci}; 59962306a36Sopenharmony_ci 60062306a36Sopenharmony_ci/* With a @src_length of zero, the range from @src_offset->EOF is cloned! */ 60162306a36Sopenharmony_cistruct btrfs_ioctl_clone_range_args { 60262306a36Sopenharmony_ci __s64 src_fd; 60362306a36Sopenharmony_ci __u64 src_offset, src_length; 60462306a36Sopenharmony_ci __u64 dest_offset; 60562306a36Sopenharmony_ci}; 60662306a36Sopenharmony_ci 60762306a36Sopenharmony_ci/* 60862306a36Sopenharmony_ci * flags definition for the defrag range ioctl 60962306a36Sopenharmony_ci * 61062306a36Sopenharmony_ci * Used by: 61162306a36Sopenharmony_ci * struct btrfs_ioctl_defrag_range_args.flags 61262306a36Sopenharmony_ci */ 61362306a36Sopenharmony_ci#define BTRFS_DEFRAG_RANGE_COMPRESS 1 61462306a36Sopenharmony_ci#define BTRFS_DEFRAG_RANGE_START_IO 2 61562306a36Sopenharmony_ci#define BTRFS_DEFRAG_RANGE_FLAGS_SUPP (BTRFS_DEFRAG_RANGE_COMPRESS | \ 61662306a36Sopenharmony_ci BTRFS_DEFRAG_RANGE_START_IO) 61762306a36Sopenharmony_ci 61862306a36Sopenharmony_cistruct btrfs_ioctl_defrag_range_args { 61962306a36Sopenharmony_ci /* start of the defrag operation */ 62062306a36Sopenharmony_ci __u64 start; 62162306a36Sopenharmony_ci 62262306a36Sopenharmony_ci /* number of bytes to defrag, use (u64)-1 to say all */ 62362306a36Sopenharmony_ci __u64 len; 62462306a36Sopenharmony_ci 62562306a36Sopenharmony_ci /* 62662306a36Sopenharmony_ci * flags for the operation, which can include turning 62762306a36Sopenharmony_ci * on compression for this one defrag 62862306a36Sopenharmony_ci */ 62962306a36Sopenharmony_ci __u64 flags; 63062306a36Sopenharmony_ci 63162306a36Sopenharmony_ci /* 63262306a36Sopenharmony_ci * any extent bigger than this will be considered 63362306a36Sopenharmony_ci * already defragged. Use 0 to take the kernel default 63462306a36Sopenharmony_ci * Use 1 to say every single extent must be rewritten 63562306a36Sopenharmony_ci */ 63662306a36Sopenharmony_ci __u32 extent_thresh; 63762306a36Sopenharmony_ci 63862306a36Sopenharmony_ci /* 63962306a36Sopenharmony_ci * which compression method to use if turning on compression 64062306a36Sopenharmony_ci * for this defrag operation. If unspecified, zlib will 64162306a36Sopenharmony_ci * be used 64262306a36Sopenharmony_ci */ 64362306a36Sopenharmony_ci __u32 compress_type; 64462306a36Sopenharmony_ci 64562306a36Sopenharmony_ci /* spare for later */ 64662306a36Sopenharmony_ci __u32 unused[4]; 64762306a36Sopenharmony_ci}; 64862306a36Sopenharmony_ci 64962306a36Sopenharmony_ci 65062306a36Sopenharmony_ci#define BTRFS_SAME_DATA_DIFFERS 1 65162306a36Sopenharmony_ci/* For extent-same ioctl */ 65262306a36Sopenharmony_cistruct btrfs_ioctl_same_extent_info { 65362306a36Sopenharmony_ci __s64 fd; /* in - destination file */ 65462306a36Sopenharmony_ci __u64 logical_offset; /* in - start of extent in destination */ 65562306a36Sopenharmony_ci __u64 bytes_deduped; /* out - total # of bytes we were able 65662306a36Sopenharmony_ci * to dedupe from this file */ 65762306a36Sopenharmony_ci /* status of this dedupe operation: 65862306a36Sopenharmony_ci * 0 if dedup succeeds 65962306a36Sopenharmony_ci * < 0 for error 66062306a36Sopenharmony_ci * == BTRFS_SAME_DATA_DIFFERS if data differs 66162306a36Sopenharmony_ci */ 66262306a36Sopenharmony_ci __s32 status; /* out - see above description */ 66362306a36Sopenharmony_ci __u32 reserved; 66462306a36Sopenharmony_ci}; 66562306a36Sopenharmony_ci 66662306a36Sopenharmony_cistruct btrfs_ioctl_same_args { 66762306a36Sopenharmony_ci __u64 logical_offset; /* in - start of extent in source */ 66862306a36Sopenharmony_ci __u64 length; /* in - length of extent */ 66962306a36Sopenharmony_ci __u16 dest_count; /* in - total elements in info array */ 67062306a36Sopenharmony_ci __u16 reserved1; 67162306a36Sopenharmony_ci __u32 reserved2; 67262306a36Sopenharmony_ci struct btrfs_ioctl_same_extent_info info[]; 67362306a36Sopenharmony_ci}; 67462306a36Sopenharmony_ci 67562306a36Sopenharmony_cistruct btrfs_ioctl_space_info { 67662306a36Sopenharmony_ci __u64 flags; 67762306a36Sopenharmony_ci __u64 total_bytes; 67862306a36Sopenharmony_ci __u64 used_bytes; 67962306a36Sopenharmony_ci}; 68062306a36Sopenharmony_ci 68162306a36Sopenharmony_cistruct btrfs_ioctl_space_args { 68262306a36Sopenharmony_ci __u64 space_slots; 68362306a36Sopenharmony_ci __u64 total_spaces; 68462306a36Sopenharmony_ci struct btrfs_ioctl_space_info spaces[]; 68562306a36Sopenharmony_ci}; 68662306a36Sopenharmony_ci 68762306a36Sopenharmony_cistruct btrfs_data_container { 68862306a36Sopenharmony_ci __u32 bytes_left; /* out -- bytes not needed to deliver output */ 68962306a36Sopenharmony_ci __u32 bytes_missing; /* out -- additional bytes needed for result */ 69062306a36Sopenharmony_ci __u32 elem_cnt; /* out */ 69162306a36Sopenharmony_ci __u32 elem_missed; /* out */ 69262306a36Sopenharmony_ci __u64 val[]; /* out */ 69362306a36Sopenharmony_ci}; 69462306a36Sopenharmony_ci 69562306a36Sopenharmony_cistruct btrfs_ioctl_ino_path_args { 69662306a36Sopenharmony_ci __u64 inum; /* in */ 69762306a36Sopenharmony_ci __u64 size; /* in */ 69862306a36Sopenharmony_ci __u64 reserved[4]; 69962306a36Sopenharmony_ci /* struct btrfs_data_container *fspath; out */ 70062306a36Sopenharmony_ci __u64 fspath; /* out */ 70162306a36Sopenharmony_ci}; 70262306a36Sopenharmony_ci 70362306a36Sopenharmony_cistruct btrfs_ioctl_logical_ino_args { 70462306a36Sopenharmony_ci __u64 logical; /* in */ 70562306a36Sopenharmony_ci __u64 size; /* in */ 70662306a36Sopenharmony_ci __u64 reserved[3]; /* must be 0 for now */ 70762306a36Sopenharmony_ci __u64 flags; /* in, v2 only */ 70862306a36Sopenharmony_ci /* struct btrfs_data_container *inodes; out */ 70962306a36Sopenharmony_ci __u64 inodes; 71062306a36Sopenharmony_ci}; 71162306a36Sopenharmony_ci 71262306a36Sopenharmony_ci/* 71362306a36Sopenharmony_ci * Return every ref to the extent, not just those containing logical block. 71462306a36Sopenharmony_ci * Requires logical == extent bytenr. 71562306a36Sopenharmony_ci */ 71662306a36Sopenharmony_ci#define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0) 71762306a36Sopenharmony_ci 71862306a36Sopenharmony_cienum btrfs_dev_stat_values { 71962306a36Sopenharmony_ci /* disk I/O failure stats */ 72062306a36Sopenharmony_ci BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */ 72162306a36Sopenharmony_ci BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */ 72262306a36Sopenharmony_ci BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */ 72362306a36Sopenharmony_ci 72462306a36Sopenharmony_ci /* stats for indirect indications for I/O failures */ 72562306a36Sopenharmony_ci BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or 72662306a36Sopenharmony_ci * contents is illegal: this is an 72762306a36Sopenharmony_ci * indication that the block was damaged 72862306a36Sopenharmony_ci * during read or write, or written to 72962306a36Sopenharmony_ci * wrong location or read from wrong 73062306a36Sopenharmony_ci * location */ 73162306a36Sopenharmony_ci BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not 73262306a36Sopenharmony_ci * been written */ 73362306a36Sopenharmony_ci 73462306a36Sopenharmony_ci BTRFS_DEV_STAT_VALUES_MAX 73562306a36Sopenharmony_ci}; 73662306a36Sopenharmony_ci 73762306a36Sopenharmony_ci/* Reset statistics after reading; needs SYS_ADMIN capability */ 73862306a36Sopenharmony_ci#define BTRFS_DEV_STATS_RESET (1ULL << 0) 73962306a36Sopenharmony_ci 74062306a36Sopenharmony_cistruct btrfs_ioctl_get_dev_stats { 74162306a36Sopenharmony_ci __u64 devid; /* in */ 74262306a36Sopenharmony_ci __u64 nr_items; /* in/out */ 74362306a36Sopenharmony_ci __u64 flags; /* in/out */ 74462306a36Sopenharmony_ci 74562306a36Sopenharmony_ci /* out values: */ 74662306a36Sopenharmony_ci __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; 74762306a36Sopenharmony_ci 74862306a36Sopenharmony_ci /* 74962306a36Sopenharmony_ci * This pads the struct to 1032 bytes. It was originally meant to pad to 75062306a36Sopenharmony_ci * 1024 bytes, but when adding the flags field, the padding calculation 75162306a36Sopenharmony_ci * was not adjusted. 75262306a36Sopenharmony_ci */ 75362306a36Sopenharmony_ci __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; 75462306a36Sopenharmony_ci}; 75562306a36Sopenharmony_ci 75662306a36Sopenharmony_ci#define BTRFS_QUOTA_CTL_ENABLE 1 75762306a36Sopenharmony_ci#define BTRFS_QUOTA_CTL_DISABLE 2 75862306a36Sopenharmony_ci#define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3 75962306a36Sopenharmony_cistruct btrfs_ioctl_quota_ctl_args { 76062306a36Sopenharmony_ci __u64 cmd; 76162306a36Sopenharmony_ci __u64 status; 76262306a36Sopenharmony_ci}; 76362306a36Sopenharmony_ci 76462306a36Sopenharmony_cistruct btrfs_ioctl_quota_rescan_args { 76562306a36Sopenharmony_ci __u64 flags; 76662306a36Sopenharmony_ci __u64 progress; 76762306a36Sopenharmony_ci __u64 reserved[6]; 76862306a36Sopenharmony_ci}; 76962306a36Sopenharmony_ci 77062306a36Sopenharmony_cistruct btrfs_ioctl_qgroup_assign_args { 77162306a36Sopenharmony_ci __u64 assign; 77262306a36Sopenharmony_ci __u64 src; 77362306a36Sopenharmony_ci __u64 dst; 77462306a36Sopenharmony_ci}; 77562306a36Sopenharmony_ci 77662306a36Sopenharmony_cistruct btrfs_ioctl_qgroup_create_args { 77762306a36Sopenharmony_ci __u64 create; 77862306a36Sopenharmony_ci __u64 qgroupid; 77962306a36Sopenharmony_ci}; 78062306a36Sopenharmony_cistruct btrfs_ioctl_timespec { 78162306a36Sopenharmony_ci __u64 sec; 78262306a36Sopenharmony_ci __u32 nsec; 78362306a36Sopenharmony_ci}; 78462306a36Sopenharmony_ci 78562306a36Sopenharmony_cistruct btrfs_ioctl_received_subvol_args { 78662306a36Sopenharmony_ci char uuid[BTRFS_UUID_SIZE]; /* in */ 78762306a36Sopenharmony_ci __u64 stransid; /* in */ 78862306a36Sopenharmony_ci __u64 rtransid; /* out */ 78962306a36Sopenharmony_ci struct btrfs_ioctl_timespec stime; /* in */ 79062306a36Sopenharmony_ci struct btrfs_ioctl_timespec rtime; /* out */ 79162306a36Sopenharmony_ci __u64 flags; /* in */ 79262306a36Sopenharmony_ci __u64 reserved[16]; /* in */ 79362306a36Sopenharmony_ci}; 79462306a36Sopenharmony_ci 79562306a36Sopenharmony_ci/* 79662306a36Sopenharmony_ci * Caller doesn't want file data in the send stream, even if the 79762306a36Sopenharmony_ci * search of clone sources doesn't find an extent. UPDATE_EXTENT 79862306a36Sopenharmony_ci * commands will be sent instead of WRITE commands. 79962306a36Sopenharmony_ci */ 80062306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 80162306a36Sopenharmony_ci 80262306a36Sopenharmony_ci/* 80362306a36Sopenharmony_ci * Do not add the leading stream header. Used when multiple snapshots 80462306a36Sopenharmony_ci * are sent back to back. 80562306a36Sopenharmony_ci */ 80662306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2 80762306a36Sopenharmony_ci 80862306a36Sopenharmony_ci/* 80962306a36Sopenharmony_ci * Omit the command at the end of the stream that indicated the end 81062306a36Sopenharmony_ci * of the stream. This option is used when multiple snapshots are 81162306a36Sopenharmony_ci * sent back to back. 81262306a36Sopenharmony_ci */ 81362306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4 81462306a36Sopenharmony_ci 81562306a36Sopenharmony_ci/* 81662306a36Sopenharmony_ci * Read the protocol version in the structure 81762306a36Sopenharmony_ci */ 81862306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_VERSION 0x8 81962306a36Sopenharmony_ci 82062306a36Sopenharmony_ci/* 82162306a36Sopenharmony_ci * Send compressed data using the ENCODED_WRITE command instead of decompressing 82262306a36Sopenharmony_ci * the data and sending it with the WRITE command. This requires protocol 82362306a36Sopenharmony_ci * version >= 2. 82462306a36Sopenharmony_ci */ 82562306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_COMPRESSED 0x10 82662306a36Sopenharmony_ci 82762306a36Sopenharmony_ci#define BTRFS_SEND_FLAG_MASK \ 82862306a36Sopenharmony_ci (BTRFS_SEND_FLAG_NO_FILE_DATA | \ 82962306a36Sopenharmony_ci BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \ 83062306a36Sopenharmony_ci BTRFS_SEND_FLAG_OMIT_END_CMD | \ 83162306a36Sopenharmony_ci BTRFS_SEND_FLAG_VERSION | \ 83262306a36Sopenharmony_ci BTRFS_SEND_FLAG_COMPRESSED) 83362306a36Sopenharmony_ci 83462306a36Sopenharmony_cistruct btrfs_ioctl_send_args { 83562306a36Sopenharmony_ci __s64 send_fd; /* in */ 83662306a36Sopenharmony_ci __u64 clone_sources_count; /* in */ 83762306a36Sopenharmony_ci __u64 __user *clone_sources; /* in */ 83862306a36Sopenharmony_ci __u64 parent_root; /* in */ 83962306a36Sopenharmony_ci __u64 flags; /* in */ 84062306a36Sopenharmony_ci __u32 version; /* in */ 84162306a36Sopenharmony_ci __u8 reserved[28]; /* in */ 84262306a36Sopenharmony_ci}; 84362306a36Sopenharmony_ci 84462306a36Sopenharmony_ci/* 84562306a36Sopenharmony_ci * Information about a fs tree root. 84662306a36Sopenharmony_ci * 84762306a36Sopenharmony_ci * All items are filled by the ioctl 84862306a36Sopenharmony_ci */ 84962306a36Sopenharmony_cistruct btrfs_ioctl_get_subvol_info_args { 85062306a36Sopenharmony_ci /* Id of this subvolume */ 85162306a36Sopenharmony_ci __u64 treeid; 85262306a36Sopenharmony_ci 85362306a36Sopenharmony_ci /* Name of this subvolume, used to get the real name at mount point */ 85462306a36Sopenharmony_ci char name[BTRFS_VOL_NAME_MAX + 1]; 85562306a36Sopenharmony_ci 85662306a36Sopenharmony_ci /* 85762306a36Sopenharmony_ci * Id of the subvolume which contains this subvolume. 85862306a36Sopenharmony_ci * Zero for top-level subvolume or a deleted subvolume. 85962306a36Sopenharmony_ci */ 86062306a36Sopenharmony_ci __u64 parent_id; 86162306a36Sopenharmony_ci 86262306a36Sopenharmony_ci /* 86362306a36Sopenharmony_ci * Inode number of the directory which contains this subvolume. 86462306a36Sopenharmony_ci * Zero for top-level subvolume or a deleted subvolume 86562306a36Sopenharmony_ci */ 86662306a36Sopenharmony_ci __u64 dirid; 86762306a36Sopenharmony_ci 86862306a36Sopenharmony_ci /* Latest transaction id of this subvolume */ 86962306a36Sopenharmony_ci __u64 generation; 87062306a36Sopenharmony_ci 87162306a36Sopenharmony_ci /* Flags of this subvolume */ 87262306a36Sopenharmony_ci __u64 flags; 87362306a36Sopenharmony_ci 87462306a36Sopenharmony_ci /* UUID of this subvolume */ 87562306a36Sopenharmony_ci __u8 uuid[BTRFS_UUID_SIZE]; 87662306a36Sopenharmony_ci 87762306a36Sopenharmony_ci /* 87862306a36Sopenharmony_ci * UUID of the subvolume of which this subvolume is a snapshot. 87962306a36Sopenharmony_ci * All zero for a non-snapshot subvolume. 88062306a36Sopenharmony_ci */ 88162306a36Sopenharmony_ci __u8 parent_uuid[BTRFS_UUID_SIZE]; 88262306a36Sopenharmony_ci 88362306a36Sopenharmony_ci /* 88462306a36Sopenharmony_ci * UUID of the subvolume from which this subvolume was received. 88562306a36Sopenharmony_ci * All zero for non-received subvolume. 88662306a36Sopenharmony_ci */ 88762306a36Sopenharmony_ci __u8 received_uuid[BTRFS_UUID_SIZE]; 88862306a36Sopenharmony_ci 88962306a36Sopenharmony_ci /* Transaction id indicating when change/create/send/receive happened */ 89062306a36Sopenharmony_ci __u64 ctransid; 89162306a36Sopenharmony_ci __u64 otransid; 89262306a36Sopenharmony_ci __u64 stransid; 89362306a36Sopenharmony_ci __u64 rtransid; 89462306a36Sopenharmony_ci /* Time corresponding to c/o/s/rtransid */ 89562306a36Sopenharmony_ci struct btrfs_ioctl_timespec ctime; 89662306a36Sopenharmony_ci struct btrfs_ioctl_timespec otime; 89762306a36Sopenharmony_ci struct btrfs_ioctl_timespec stime; 89862306a36Sopenharmony_ci struct btrfs_ioctl_timespec rtime; 89962306a36Sopenharmony_ci 90062306a36Sopenharmony_ci /* Must be zero */ 90162306a36Sopenharmony_ci __u64 reserved[8]; 90262306a36Sopenharmony_ci}; 90362306a36Sopenharmony_ci 90462306a36Sopenharmony_ci#define BTRFS_MAX_ROOTREF_BUFFER_NUM 255 90562306a36Sopenharmony_cistruct btrfs_ioctl_get_subvol_rootref_args { 90662306a36Sopenharmony_ci /* in/out, minimum id of rootref's treeid to be searched */ 90762306a36Sopenharmony_ci __u64 min_treeid; 90862306a36Sopenharmony_ci 90962306a36Sopenharmony_ci /* out */ 91062306a36Sopenharmony_ci struct { 91162306a36Sopenharmony_ci __u64 treeid; 91262306a36Sopenharmony_ci __u64 dirid; 91362306a36Sopenharmony_ci } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; 91462306a36Sopenharmony_ci 91562306a36Sopenharmony_ci /* out, number of found items */ 91662306a36Sopenharmony_ci __u8 num_items; 91762306a36Sopenharmony_ci __u8 align[7]; 91862306a36Sopenharmony_ci}; 91962306a36Sopenharmony_ci 92062306a36Sopenharmony_ci/* 92162306a36Sopenharmony_ci * Data and metadata for an encoded read or write. 92262306a36Sopenharmony_ci * 92362306a36Sopenharmony_ci * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g., 92462306a36Sopenharmony_ci * compression). This can be used to read the compressed contents of a file or 92562306a36Sopenharmony_ci * write pre-compressed data directly to a file. 92662306a36Sopenharmony_ci * 92762306a36Sopenharmony_ci * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially 92862306a36Sopenharmony_ci * preadv/pwritev with additional metadata about how the data is encoded and the 92962306a36Sopenharmony_ci * size of the unencoded data. 93062306a36Sopenharmony_ci * 93162306a36Sopenharmony_ci * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills 93262306a36Sopenharmony_ci * the metadata fields, and returns the size of the encoded data. It reads one 93362306a36Sopenharmony_ci * extent per call. It can also read data which is not encoded. 93462306a36Sopenharmony_ci * 93562306a36Sopenharmony_ci * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data 93662306a36Sopenharmony_ci * from the iovecs, and returns the size of the encoded data. Note that the 93762306a36Sopenharmony_ci * encoded data is not validated when it is written; if it is not valid (e.g., 93862306a36Sopenharmony_ci * it cannot be decompressed), then a subsequent read may return an error. 93962306a36Sopenharmony_ci * 94062306a36Sopenharmony_ci * Since the filesystem page cache contains decoded data, encoded I/O bypasses 94162306a36Sopenharmony_ci * the page cache. Encoded I/O requires CAP_SYS_ADMIN. 94262306a36Sopenharmony_ci */ 94362306a36Sopenharmony_cistruct btrfs_ioctl_encoded_io_args { 94462306a36Sopenharmony_ci /* Input parameters for both reads and writes. */ 94562306a36Sopenharmony_ci 94662306a36Sopenharmony_ci /* 94762306a36Sopenharmony_ci * iovecs containing encoded data. 94862306a36Sopenharmony_ci * 94962306a36Sopenharmony_ci * For reads, if the size of the encoded data is larger than the sum of 95062306a36Sopenharmony_ci * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with 95162306a36Sopenharmony_ci * ENOBUFS. 95262306a36Sopenharmony_ci * 95362306a36Sopenharmony_ci * For writes, the size of the encoded data is the sum of iov[n].iov_len 95462306a36Sopenharmony_ci * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may 95562306a36Sopenharmony_ci * increase in the future). This must also be less than or equal to 95662306a36Sopenharmony_ci * unencoded_len. 95762306a36Sopenharmony_ci */ 95862306a36Sopenharmony_ci const struct iovec __user *iov; 95962306a36Sopenharmony_ci /* Number of iovecs. */ 96062306a36Sopenharmony_ci unsigned long iovcnt; 96162306a36Sopenharmony_ci /* 96262306a36Sopenharmony_ci * Offset in file. 96362306a36Sopenharmony_ci * 96462306a36Sopenharmony_ci * For writes, must be aligned to the sector size of the filesystem. 96562306a36Sopenharmony_ci */ 96662306a36Sopenharmony_ci __s64 offset; 96762306a36Sopenharmony_ci /* Currently must be zero. */ 96862306a36Sopenharmony_ci __u64 flags; 96962306a36Sopenharmony_ci 97062306a36Sopenharmony_ci /* 97162306a36Sopenharmony_ci * For reads, the following members are output parameters that will 97262306a36Sopenharmony_ci * contain the returned metadata for the encoded data. 97362306a36Sopenharmony_ci * For writes, the following members must be set to the metadata for the 97462306a36Sopenharmony_ci * encoded data. 97562306a36Sopenharmony_ci */ 97662306a36Sopenharmony_ci 97762306a36Sopenharmony_ci /* 97862306a36Sopenharmony_ci * Length of the data in the file. 97962306a36Sopenharmony_ci * 98062306a36Sopenharmony_ci * Must be less than or equal to unencoded_len - unencoded_offset. For 98162306a36Sopenharmony_ci * writes, must be aligned to the sector size of the filesystem unless 98262306a36Sopenharmony_ci * the data ends at or beyond the current end of the file. 98362306a36Sopenharmony_ci */ 98462306a36Sopenharmony_ci __u64 len; 98562306a36Sopenharmony_ci /* 98662306a36Sopenharmony_ci * Length of the unencoded (i.e., decrypted and decompressed) data. 98762306a36Sopenharmony_ci * 98862306a36Sopenharmony_ci * For writes, must be no more than 128 KiB (this limit may increase in 98962306a36Sopenharmony_ci * the future). If the unencoded data is actually longer than 99062306a36Sopenharmony_ci * unencoded_len, then it is truncated; if it is shorter, then it is 99162306a36Sopenharmony_ci * extended with zeroes. 99262306a36Sopenharmony_ci */ 99362306a36Sopenharmony_ci __u64 unencoded_len; 99462306a36Sopenharmony_ci /* 99562306a36Sopenharmony_ci * Offset from the first byte of the unencoded data to the first byte of 99662306a36Sopenharmony_ci * logical data in the file. 99762306a36Sopenharmony_ci * 99862306a36Sopenharmony_ci * Must be less than unencoded_len. 99962306a36Sopenharmony_ci */ 100062306a36Sopenharmony_ci __u64 unencoded_offset; 100162306a36Sopenharmony_ci /* 100262306a36Sopenharmony_ci * BTRFS_ENCODED_IO_COMPRESSION_* type. 100362306a36Sopenharmony_ci * 100462306a36Sopenharmony_ci * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE. 100562306a36Sopenharmony_ci */ 100662306a36Sopenharmony_ci __u32 compression; 100762306a36Sopenharmony_ci /* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */ 100862306a36Sopenharmony_ci __u32 encryption; 100962306a36Sopenharmony_ci /* 101062306a36Sopenharmony_ci * Reserved for future expansion. 101162306a36Sopenharmony_ci * 101262306a36Sopenharmony_ci * For reads, always returned as zero. Users should check for non-zero 101362306a36Sopenharmony_ci * bytes. If there are any, then the kernel has a newer version of this 101462306a36Sopenharmony_ci * structure with additional information that the user definition is 101562306a36Sopenharmony_ci * missing. 101662306a36Sopenharmony_ci * 101762306a36Sopenharmony_ci * For writes, must be zeroed. 101862306a36Sopenharmony_ci */ 101962306a36Sopenharmony_ci __u8 reserved[64]; 102062306a36Sopenharmony_ci}; 102162306a36Sopenharmony_ci 102262306a36Sopenharmony_ci/* Data is not compressed. */ 102362306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_NONE 0 102462306a36Sopenharmony_ci/* Data is compressed as a single zlib stream. */ 102562306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1 102662306a36Sopenharmony_ci/* 102762306a36Sopenharmony_ci * Data is compressed as a single zstd frame with the windowLog compression 102862306a36Sopenharmony_ci * parameter set to no more than 17. 102962306a36Sopenharmony_ci */ 103062306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2 103162306a36Sopenharmony_ci/* 103262306a36Sopenharmony_ci * Data is compressed sector by sector (using the sector size indicated by the 103362306a36Sopenharmony_ci * name of the constant) with LZO1X and wrapped in the format documented in 103462306a36Sopenharmony_ci * fs/btrfs/lzo.c. For writes, the compression sector size must match the 103562306a36Sopenharmony_ci * filesystem sector size. 103662306a36Sopenharmony_ci */ 103762306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3 103862306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4 103962306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5 104062306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6 104162306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7 104262306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8 104362306a36Sopenharmony_ci 104462306a36Sopenharmony_ci/* Data is not encrypted. */ 104562306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0 104662306a36Sopenharmony_ci#define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1 104762306a36Sopenharmony_ci 104862306a36Sopenharmony_ci/* Error codes as returned by the kernel */ 104962306a36Sopenharmony_cienum btrfs_err_code { 105062306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1, 105162306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET, 105262306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET, 105362306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET, 105462306a36Sopenharmony_ci BTRFS_ERROR_DEV_TGT_REPLACE, 105562306a36Sopenharmony_ci BTRFS_ERROR_DEV_MISSING_NOT_FOUND, 105662306a36Sopenharmony_ci BTRFS_ERROR_DEV_ONLY_WRITABLE, 105762306a36Sopenharmony_ci BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS, 105862306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID1C3_MIN_NOT_MET, 105962306a36Sopenharmony_ci BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET, 106062306a36Sopenharmony_ci}; 106162306a36Sopenharmony_ci 106262306a36Sopenharmony_ci#define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ 106362306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 106462306a36Sopenharmony_ci#define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ 106562306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 106662306a36Sopenharmony_ci#define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \ 106762306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 106862306a36Sopenharmony_ci#define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ 106962306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 107062306a36Sopenharmony_ci#define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ 107162306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 107262306a36Sopenharmony_ci/* trans start and trans end are dangerous, and only for 107362306a36Sopenharmony_ci * use by applications that know how to avoid the 107462306a36Sopenharmony_ci * resulting deadlocks 107562306a36Sopenharmony_ci */ 107662306a36Sopenharmony_ci#define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6) 107762306a36Sopenharmony_ci#define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7) 107862306a36Sopenharmony_ci#define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8) 107962306a36Sopenharmony_ci 108062306a36Sopenharmony_ci#define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int) 108162306a36Sopenharmony_ci#define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \ 108262306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 108362306a36Sopenharmony_ci#define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \ 108462306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 108562306a36Sopenharmony_ci#define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \ 108662306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 108762306a36Sopenharmony_ci 108862306a36Sopenharmony_ci#define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \ 108962306a36Sopenharmony_ci struct btrfs_ioctl_clone_range_args) 109062306a36Sopenharmony_ci 109162306a36Sopenharmony_ci#define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \ 109262306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 109362306a36Sopenharmony_ci#define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ 109462306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 109562306a36Sopenharmony_ci#define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \ 109662306a36Sopenharmony_ci struct btrfs_ioctl_defrag_range_args) 109762306a36Sopenharmony_ci#define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ 109862306a36Sopenharmony_ci struct btrfs_ioctl_search_args) 109962306a36Sopenharmony_ci#define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \ 110062306a36Sopenharmony_ci struct btrfs_ioctl_search_args_v2) 110162306a36Sopenharmony_ci#define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ 110262306a36Sopenharmony_ci struct btrfs_ioctl_ino_lookup_args) 110362306a36Sopenharmony_ci#define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64) 110462306a36Sopenharmony_ci#define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ 110562306a36Sopenharmony_ci struct btrfs_ioctl_space_args) 110662306a36Sopenharmony_ci#define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64) 110762306a36Sopenharmony_ci#define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64) 110862306a36Sopenharmony_ci#define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \ 110962306a36Sopenharmony_ci struct btrfs_ioctl_vol_args_v2) 111062306a36Sopenharmony_ci#define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \ 111162306a36Sopenharmony_ci struct btrfs_ioctl_vol_args_v2) 111262306a36Sopenharmony_ci#define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64) 111362306a36Sopenharmony_ci#define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64) 111462306a36Sopenharmony_ci#define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \ 111562306a36Sopenharmony_ci struct btrfs_ioctl_scrub_args) 111662306a36Sopenharmony_ci#define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28) 111762306a36Sopenharmony_ci#define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \ 111862306a36Sopenharmony_ci struct btrfs_ioctl_scrub_args) 111962306a36Sopenharmony_ci#define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \ 112062306a36Sopenharmony_ci struct btrfs_ioctl_dev_info_args) 112162306a36Sopenharmony_ci#define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \ 112262306a36Sopenharmony_ci struct btrfs_ioctl_fs_info_args) 112362306a36Sopenharmony_ci#define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \ 112462306a36Sopenharmony_ci struct btrfs_ioctl_balance_args) 112562306a36Sopenharmony_ci#define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int) 112662306a36Sopenharmony_ci#define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \ 112762306a36Sopenharmony_ci struct btrfs_ioctl_balance_args) 112862306a36Sopenharmony_ci#define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \ 112962306a36Sopenharmony_ci struct btrfs_ioctl_ino_path_args) 113062306a36Sopenharmony_ci#define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \ 113162306a36Sopenharmony_ci struct btrfs_ioctl_logical_ino_args) 113262306a36Sopenharmony_ci#define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \ 113362306a36Sopenharmony_ci struct btrfs_ioctl_received_subvol_args) 113462306a36Sopenharmony_ci#define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args) 113562306a36Sopenharmony_ci#define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \ 113662306a36Sopenharmony_ci struct btrfs_ioctl_vol_args) 113762306a36Sopenharmony_ci#define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \ 113862306a36Sopenharmony_ci struct btrfs_ioctl_quota_ctl_args) 113962306a36Sopenharmony_ci#define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \ 114062306a36Sopenharmony_ci struct btrfs_ioctl_qgroup_assign_args) 114162306a36Sopenharmony_ci#define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \ 114262306a36Sopenharmony_ci struct btrfs_ioctl_qgroup_create_args) 114362306a36Sopenharmony_ci#define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \ 114462306a36Sopenharmony_ci struct btrfs_ioctl_qgroup_limit_args) 114562306a36Sopenharmony_ci#define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \ 114662306a36Sopenharmony_ci struct btrfs_ioctl_quota_rescan_args) 114762306a36Sopenharmony_ci#define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \ 114862306a36Sopenharmony_ci struct btrfs_ioctl_quota_rescan_args) 114962306a36Sopenharmony_ci#define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46) 115062306a36Sopenharmony_ci#define BTRFS_IOC_GET_FSLABEL FS_IOC_GETFSLABEL 115162306a36Sopenharmony_ci#define BTRFS_IOC_SET_FSLABEL FS_IOC_SETFSLABEL 115262306a36Sopenharmony_ci#define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ 115362306a36Sopenharmony_ci struct btrfs_ioctl_get_dev_stats) 115462306a36Sopenharmony_ci#define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \ 115562306a36Sopenharmony_ci struct btrfs_ioctl_dev_replace_args) 115662306a36Sopenharmony_ci#define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \ 115762306a36Sopenharmony_ci struct btrfs_ioctl_same_args) 115862306a36Sopenharmony_ci#define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ 115962306a36Sopenharmony_ci struct btrfs_ioctl_feature_flags) 116062306a36Sopenharmony_ci#define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \ 116162306a36Sopenharmony_ci struct btrfs_ioctl_feature_flags[2]) 116262306a36Sopenharmony_ci#define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ 116362306a36Sopenharmony_ci struct btrfs_ioctl_feature_flags[3]) 116462306a36Sopenharmony_ci#define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ 116562306a36Sopenharmony_ci struct btrfs_ioctl_vol_args_v2) 116662306a36Sopenharmony_ci#define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \ 116762306a36Sopenharmony_ci struct btrfs_ioctl_logical_ino_args) 116862306a36Sopenharmony_ci#define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \ 116962306a36Sopenharmony_ci struct btrfs_ioctl_get_subvol_info_args) 117062306a36Sopenharmony_ci#define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \ 117162306a36Sopenharmony_ci struct btrfs_ioctl_get_subvol_rootref_args) 117262306a36Sopenharmony_ci#define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \ 117362306a36Sopenharmony_ci struct btrfs_ioctl_ino_lookup_user_args) 117462306a36Sopenharmony_ci#define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \ 117562306a36Sopenharmony_ci struct btrfs_ioctl_vol_args_v2) 117662306a36Sopenharmony_ci#define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \ 117762306a36Sopenharmony_ci struct btrfs_ioctl_encoded_io_args) 117862306a36Sopenharmony_ci#define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \ 117962306a36Sopenharmony_ci struct btrfs_ioctl_encoded_io_args) 118062306a36Sopenharmony_ci 118162306a36Sopenharmony_ci#ifdef __cplusplus 118262306a36Sopenharmony_ci} 118362306a36Sopenharmony_ci#endif 118462306a36Sopenharmony_ci 118562306a36Sopenharmony_ci#endif /* _UAPI_LINUX_BTRFS_H */ 1186