Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 /*
0003  * Copyright (C) 2007 Oracle.  All rights reserved.
0004  *
0005  * This program is free software; you can redistribute it and/or
0006  * modify it under the terms of the GNU General Public
0007  * License v2 as published by the Free Software Foundation.
0008  *
0009  * This program is distributed in the hope that it will be useful,
0010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0012  * General Public License for more details.
0013  *
0014  * You should have received a copy of the GNU General Public
0015  * License along with this program; if not, write to the
0016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0017  * Boston, MA 021110-1307, USA.
0018  */
0019 
0020 #ifndef _UAPI_LINUX_BTRFS_H
0021 #define _UAPI_LINUX_BTRFS_H
0022 #include <linux/types.h>
0023 #include <linux/ioctl.h>
0024 
0025 #define BTRFS_IOCTL_MAGIC 0x94
0026 #define BTRFS_VOL_NAME_MAX 255
0027 #define BTRFS_LABEL_SIZE 256
0028 
0029 /* this should be 4k */
0030 #define BTRFS_PATH_NAME_MAX 4087
0031 struct btrfs_ioctl_vol_args {
0032     __s64 fd;
0033     char name[BTRFS_PATH_NAME_MAX + 1];
0034 };
0035 
0036 #define BTRFS_DEVICE_PATH_NAME_MAX  1024
0037 #define BTRFS_SUBVOL_NAME_MAX       4039
0038 
0039 #ifndef __KERNEL__
0040 /* Deprecated since 5.7 */
0041 # define BTRFS_SUBVOL_CREATE_ASYNC  (1ULL << 0)
0042 #endif
0043 #define BTRFS_SUBVOL_RDONLY     (1ULL << 1)
0044 #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
0045 
0046 #define BTRFS_DEVICE_SPEC_BY_ID     (1ULL << 3)
0047 
0048 #define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4)
0049 
0050 #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED        \
0051             (BTRFS_SUBVOL_RDONLY |      \
0052             BTRFS_SUBVOL_QGROUP_INHERIT |   \
0053             BTRFS_DEVICE_SPEC_BY_ID |   \
0054             BTRFS_SUBVOL_SPEC_BY_ID)
0055 
0056 #define BTRFS_FSID_SIZE 16
0057 #define BTRFS_UUID_SIZE 16
0058 #define BTRFS_UUID_UNPARSED_SIZE    37
0059 
0060 /*
0061  * flags definition for qgroup limits
0062  *
0063  * Used by:
0064  * struct btrfs_qgroup_limit.flags
0065  * struct btrfs_qgroup_limit_item.flags
0066  */
0067 #define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
0068 #define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
0069 #define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
0070 #define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
0071 #define BTRFS_QGROUP_LIMIT_RFER_CMPR    (1ULL << 4)
0072 #define BTRFS_QGROUP_LIMIT_EXCL_CMPR    (1ULL << 5)
0073 
0074 struct btrfs_qgroup_limit {
0075     __u64   flags;
0076     __u64   max_rfer;
0077     __u64   max_excl;
0078     __u64   rsv_rfer;
0079     __u64   rsv_excl;
0080 };
0081 
0082 /*
0083  * flags definition for qgroup inheritance
0084  *
0085  * Used by:
0086  * struct btrfs_qgroup_inherit.flags
0087  */
0088 #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
0089 
0090 struct btrfs_qgroup_inherit {
0091     __u64   flags;
0092     __u64   num_qgroups;
0093     __u64   num_ref_copies;
0094     __u64   num_excl_copies;
0095     struct btrfs_qgroup_limit lim;
0096     __u64   qgroups[];
0097 };
0098 
0099 struct btrfs_ioctl_qgroup_limit_args {
0100     __u64   qgroupid;
0101     struct btrfs_qgroup_limit lim;
0102 };
0103 
0104 /*
0105  * Arguments for specification of subvolumes or devices, supporting by-name or
0106  * by-id and flags
0107  *
0108  * The set of supported flags depends on the ioctl
0109  *
0110  * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
0111  * - BTRFS_IOC_SUBVOL_GETFLAGS
0112  * - BTRFS_IOC_SUBVOL_SETFLAGS
0113  */
0114 
0115 /* Supported flags for BTRFS_IOC_RM_DEV_V2 */
0116 #define BTRFS_DEVICE_REMOVE_ARGS_MASK                   \
0117     (BTRFS_DEVICE_SPEC_BY_ID)
0118 
0119 /* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */
0120 #define BTRFS_SUBVOL_CREATE_ARGS_MASK                   \
0121      (BTRFS_SUBVOL_RDONLY |                     \
0122      BTRFS_SUBVOL_QGROUP_INHERIT)
0123 
0124 /* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
0125 #define BTRFS_SUBVOL_DELETE_ARGS_MASK                   \
0126     (BTRFS_SUBVOL_SPEC_BY_ID)
0127 
0128 struct btrfs_ioctl_vol_args_v2 {
0129     __s64 fd;
0130     __u64 transid;
0131     __u64 flags;
0132     union {
0133         struct {
0134             __u64 size;
0135             struct btrfs_qgroup_inherit __user *qgroup_inherit;
0136         };
0137         __u64 unused[4];
0138     };
0139     union {
0140         char name[BTRFS_SUBVOL_NAME_MAX + 1];
0141         __u64 devid;
0142         __u64 subvolid;
0143     };
0144 };
0145 
0146 /*
0147  * structure to report errors and progress to userspace, either as a
0148  * result of a finished scrub, a canceled scrub or a progress inquiry
0149  */
0150 struct btrfs_scrub_progress {
0151     __u64 data_extents_scrubbed;    /* # of data extents scrubbed */
0152     __u64 tree_extents_scrubbed;    /* # of tree extents scrubbed */
0153     __u64 data_bytes_scrubbed;  /* # of data bytes scrubbed */
0154     __u64 tree_bytes_scrubbed;  /* # of tree bytes scrubbed */
0155     __u64 read_errors;      /* # of read errors encountered (EIO) */
0156     __u64 csum_errors;      /* # of failed csum checks */
0157     __u64 verify_errors;        /* # of occurrences, where the metadata
0158                      * of a tree block did not match the
0159                      * expected values, like generation or
0160                      * logical */
0161     __u64 no_csum;          /* # of 4k data block for which no csum
0162                      * is present, probably the result of
0163                      * data written with nodatasum */
0164     __u64 csum_discards;        /* # of csum for which no data was found
0165                      * in the extent tree. */
0166     __u64 super_errors;     /* # of bad super blocks encountered */
0167     __u64 malloc_errors;        /* # of internal kmalloc errors. These
0168                      * will likely cause an incomplete
0169                      * scrub */
0170     __u64 uncorrectable_errors; /* # of errors where either no intact
0171                      * copy was found or the writeback
0172                      * failed */
0173     __u64 corrected_errors;     /* # of errors corrected */
0174     __u64 last_physical;        /* last physical address scrubbed. In
0175                      * case a scrub was aborted, this can
0176                      * be used to restart the scrub */
0177     __u64 unverified_errors;    /* # of occurrences where a read for a
0178                      * full (64k) bio failed, but the re-
0179                      * check succeeded for each 4k piece.
0180                      * Intermittent error. */
0181 };
0182 
0183 #define BTRFS_SCRUB_READONLY    1
0184 struct btrfs_ioctl_scrub_args {
0185     __u64 devid;                /* in */
0186     __u64 start;                /* in */
0187     __u64 end;              /* in */
0188     __u64 flags;                /* in */
0189     struct btrfs_scrub_progress progress;   /* out */
0190     /* pad to 1k */
0191     __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
0192 };
0193 
0194 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS    0
0195 #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
0196 struct btrfs_ioctl_dev_replace_start_params {
0197     __u64 srcdevid; /* in, if 0, use srcdev_name instead */
0198     __u64 cont_reading_from_srcdev_mode;    /* in, see #define
0199                          * above */
0200     __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];   /* in */
0201     __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1];   /* in */
0202 };
0203 
0204 #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
0205 #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED       1
0206 #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED      2
0207 #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED      3
0208 #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED     4
0209 struct btrfs_ioctl_dev_replace_status_params {
0210     __u64 replace_state;    /* out, see #define above */
0211     __u64 progress_1000;    /* out, 0 <= x <= 1000 */
0212     __u64 time_started; /* out, seconds since 1-Jan-1970 */
0213     __u64 time_stopped; /* out, seconds since 1-Jan-1970 */
0214     __u64 num_write_errors; /* out */
0215     __u64 num_uncorrectable_read_errors;    /* out */
0216 };
0217 
0218 #define BTRFS_IOCTL_DEV_REPLACE_CMD_START           0
0219 #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS          1
0220 #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL          2
0221 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR         0
0222 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED      1
0223 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED      2
0224 #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS     3
0225 struct btrfs_ioctl_dev_replace_args {
0226     __u64 cmd;  /* in */
0227     __u64 result;   /* out */
0228 
0229     union {
0230         struct btrfs_ioctl_dev_replace_start_params start;
0231         struct btrfs_ioctl_dev_replace_status_params status;
0232     };  /* in/out */
0233 
0234     __u64 spare[64];
0235 };
0236 
0237 struct btrfs_ioctl_dev_info_args {
0238     __u64 devid;                /* in/out */
0239     __u8 uuid[BTRFS_UUID_SIZE];     /* in/out */
0240     __u64 bytes_used;           /* out */
0241     __u64 total_bytes;          /* out */
0242     __u64 unused[379];          /* pad to 4k */
0243     __u8 path[BTRFS_DEVICE_PATH_NAME_MAX];  /* out */
0244 };
0245 
0246 /*
0247  * Retrieve information about the filesystem
0248  */
0249 
0250 /* Request information about checksum type and size */
0251 #define BTRFS_FS_INFO_FLAG_CSUM_INFO            (1 << 0)
0252 
0253 /* Request information about filesystem generation */
0254 #define BTRFS_FS_INFO_FLAG_GENERATION           (1 << 1)
0255 /* Request information about filesystem metadata UUID */
0256 #define BTRFS_FS_INFO_FLAG_METADATA_UUID        (1 << 2)
0257 
0258 struct btrfs_ioctl_fs_info_args {
0259     __u64 max_id;               /* out */
0260     __u64 num_devices;          /* out */
0261     __u8 fsid[BTRFS_FSID_SIZE];     /* out */
0262     __u32 nodesize;             /* out */
0263     __u32 sectorsize;           /* out */
0264     __u32 clone_alignment;          /* out */
0265     /* See BTRFS_FS_INFO_FLAG_* */
0266     __u16 csum_type;            /* out */
0267     __u16 csum_size;            /* out */
0268     __u64 flags;                /* in/out */
0269     __u64 generation;           /* out */
0270     __u8 metadata_uuid[BTRFS_FSID_SIZE];    /* out */
0271     __u8 reserved[944];         /* pad to 1k */
0272 };
0273 
0274 /*
0275  * feature flags
0276  *
0277  * Used by:
0278  * struct btrfs_ioctl_feature_flags
0279  */
0280 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE     (1ULL << 0)
0281 /*
0282  * Older kernels (< 4.9) on big-endian systems produced broken free space tree
0283  * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
0284  * < 4.7.3).  If this bit is clear, then the free space tree cannot be trusted.
0285  * btrfs-progs can also intentionally clear this bit to ask the kernel to
0286  * rebuild the free space tree, however this might not work on older kernels
0287  * that do not know about this bit. If not sure, clear the cache manually on
0288  * first mount when booting older kernel versions.
0289  */
0290 #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID   (1ULL << 1)
0291 #define BTRFS_FEATURE_COMPAT_RO_VERITY          (1ULL << 2)
0292 
0293 #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF    (1ULL << 0)
0294 #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL   (1ULL << 1)
0295 #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
0296 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
0297 #define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD    (1ULL << 4)
0298 
0299 /*
0300  * older kernels tried to do bigger metadata blocks, but the
0301  * code was pretty buggy.  Lets not let them try anymore.
0302  */
0303 #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
0304 
0305 #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF    (1ULL << 6)
0306 #define BTRFS_FEATURE_INCOMPAT_RAID56       (1ULL << 7)
0307 #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA  (1ULL << 8)
0308 #define BTRFS_FEATURE_INCOMPAT_NO_HOLES     (1ULL << 9)
0309 #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID    (1ULL << 10)
0310 #define BTRFS_FEATURE_INCOMPAT_RAID1C34     (1ULL << 11)
0311 #define BTRFS_FEATURE_INCOMPAT_ZONED        (1ULL << 12)
0312 #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2   (1ULL << 13)
0313 
0314 struct btrfs_ioctl_feature_flags {
0315     __u64 compat_flags;
0316     __u64 compat_ro_flags;
0317     __u64 incompat_flags;
0318 };
0319 
0320 /* balance control ioctl modes */
0321 #define BTRFS_BALANCE_CTL_PAUSE     1
0322 #define BTRFS_BALANCE_CTL_CANCEL    2
0323 
0324 /*
0325  * this is packed, because it should be exactly the same as its disk
0326  * byte order counterpart (struct btrfs_disk_balance_args)
0327  */
0328 struct btrfs_balance_args {
0329     __u64 profiles;
0330     union {
0331         __u64 usage;
0332         struct {
0333             __u32 usage_min;
0334             __u32 usage_max;
0335         };
0336     };
0337     __u64 devid;
0338     __u64 pstart;
0339     __u64 pend;
0340     __u64 vstart;
0341     __u64 vend;
0342 
0343     __u64 target;
0344 
0345     __u64 flags;
0346 
0347     /*
0348      * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
0349      * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
0350      * and maximum
0351      */
0352     union {
0353         __u64 limit;        /* limit number of processed chunks */
0354         struct {
0355             __u32 limit_min;
0356             __u32 limit_max;
0357         };
0358     };
0359 
0360     /*
0361      * Process chunks that cross stripes_min..stripes_max devices,
0362      * BTRFS_BALANCE_ARGS_STRIPES_RANGE
0363      */
0364     __u32 stripes_min;
0365     __u32 stripes_max;
0366 
0367     __u64 unused[6];
0368 } __attribute__ ((__packed__));
0369 
0370 /* report balance progress to userspace */
0371 struct btrfs_balance_progress {
0372     __u64 expected;     /* estimated # of chunks that will be
0373                  * relocated to fulfill the request */
0374     __u64 considered;   /* # of chunks we have considered so far */
0375     __u64 completed;    /* # of chunks relocated so far */
0376 };
0377 
0378 /*
0379  * flags definition for balance
0380  *
0381  * Restriper's general type filter
0382  *
0383  * Used by:
0384  * btrfs_ioctl_balance_args.flags
0385  * btrfs_balance_control.flags (internal)
0386  */
0387 #define BTRFS_BALANCE_DATA      (1ULL << 0)
0388 #define BTRFS_BALANCE_SYSTEM        (1ULL << 1)
0389 #define BTRFS_BALANCE_METADATA      (1ULL << 2)
0390 
0391 #define BTRFS_BALANCE_TYPE_MASK     (BTRFS_BALANCE_DATA |       \
0392                      BTRFS_BALANCE_SYSTEM |     \
0393                      BTRFS_BALANCE_METADATA)
0394 
0395 #define BTRFS_BALANCE_FORCE     (1ULL << 3)
0396 #define BTRFS_BALANCE_RESUME        (1ULL << 4)
0397 
0398 /*
0399  * flags definitions for per-type balance args
0400  *
0401  * Balance filters
0402  *
0403  * Used by:
0404  * struct btrfs_balance_args
0405  */
0406 #define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
0407 #define BTRFS_BALANCE_ARGS_USAGE    (1ULL << 1)
0408 #define BTRFS_BALANCE_ARGS_DEVID    (1ULL << 2)
0409 #define BTRFS_BALANCE_ARGS_DRANGE   (1ULL << 3)
0410 #define BTRFS_BALANCE_ARGS_VRANGE   (1ULL << 4)
0411 #define BTRFS_BALANCE_ARGS_LIMIT    (1ULL << 5)
0412 #define BTRFS_BALANCE_ARGS_LIMIT_RANGE  (1ULL << 6)
0413 #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
0414 #define BTRFS_BALANCE_ARGS_USAGE_RANGE  (1ULL << 10)
0415 
0416 #define BTRFS_BALANCE_ARGS_MASK         \
0417     (BTRFS_BALANCE_ARGS_PROFILES |      \
0418      BTRFS_BALANCE_ARGS_USAGE |     \
0419      BTRFS_BALANCE_ARGS_DEVID |         \
0420      BTRFS_BALANCE_ARGS_DRANGE |        \
0421      BTRFS_BALANCE_ARGS_VRANGE |        \
0422      BTRFS_BALANCE_ARGS_LIMIT |     \
0423      BTRFS_BALANCE_ARGS_LIMIT_RANGE |   \
0424      BTRFS_BALANCE_ARGS_STRIPES_RANGE | \
0425      BTRFS_BALANCE_ARGS_USAGE_RANGE)
0426 
0427 /*
0428  * Profile changing flags.  When SOFT is set we won't relocate chunk if
0429  * it already has the target profile (even though it may be
0430  * half-filled).
0431  */
0432 #define BTRFS_BALANCE_ARGS_CONVERT  (1ULL << 8)
0433 #define BTRFS_BALANCE_ARGS_SOFT     (1ULL << 9)
0434 
0435 
0436 /*
0437  * flags definition for balance state
0438  *
0439  * Used by:
0440  * struct btrfs_ioctl_balance_args.state
0441  */
0442 #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
0443 #define BTRFS_BALANCE_STATE_PAUSE_REQ   (1ULL << 1)
0444 #define BTRFS_BALANCE_STATE_CANCEL_REQ  (1ULL << 2)
0445 
0446 struct btrfs_ioctl_balance_args {
0447     __u64 flags;                /* in/out */
0448     __u64 state;                /* out */
0449 
0450     struct btrfs_balance_args data;     /* in/out */
0451     struct btrfs_balance_args meta;     /* in/out */
0452     struct btrfs_balance_args sys;      /* in/out */
0453 
0454     struct btrfs_balance_progress stat; /* out */
0455 
0456     __u64 unused[72];           /* pad to 1k */
0457 };
0458 
0459 #define BTRFS_INO_LOOKUP_PATH_MAX 4080
0460 struct btrfs_ioctl_ino_lookup_args {
0461     __u64 treeid;
0462     __u64 objectid;
0463     char name[BTRFS_INO_LOOKUP_PATH_MAX];
0464 };
0465 
0466 #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
0467 struct btrfs_ioctl_ino_lookup_user_args {
0468     /* in, inode number containing the subvolume of 'subvolid' */
0469     __u64 dirid;
0470     /* in */
0471     __u64 treeid;
0472     /* out, name of the subvolume of 'treeid' */
0473     char name[BTRFS_VOL_NAME_MAX + 1];
0474     /*
0475      * out, constructed path from the directory with which the ioctl is
0476      * called to dirid
0477      */
0478     char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
0479 };
0480 
0481 /* Search criteria for the btrfs SEARCH ioctl family. */
0482 struct btrfs_ioctl_search_key {
0483     /*
0484      * The tree we're searching in. 1 is the tree of tree roots, 2 is the
0485      * extent tree, etc...
0486      *
0487      * A special tree_id value of 0 will cause a search in the subvolume
0488      * tree that the inode which is passed to the ioctl is part of.
0489      */
0490     __u64 tree_id;      /* in */
0491 
0492     /*
0493      * When doing a tree search, we're actually taking a slice from a
0494      * linear search space of 136-bit keys.
0495      *
0496      * A full 136-bit tree key is composed as:
0497      *   (objectid << 72) + (type << 64) + offset
0498      *
0499      * The individual min and max values for objectid, type and offset
0500      * define the min_key and max_key values for the search range. All
0501      * metadata items with a key in the interval [min_key, max_key] will be
0502      * returned.
0503      *
0504      * Additionally, we can filter the items returned on transaction id of
0505      * the metadata block they're stored in by specifying a transid range.
0506      * Be aware that this transaction id only denotes when the metadata
0507      * page that currently contains the item got written the last time as
0508      * result of a COW operation.  The number does not have any meaning
0509      * related to the transaction in which an individual item that is being
0510      * returned was created or changed.
0511      */
0512     __u64 min_objectid; /* in */
0513     __u64 max_objectid; /* in */
0514     __u64 min_offset;   /* in */
0515     __u64 max_offset;   /* in */
0516     __u64 min_transid;  /* in */
0517     __u64 max_transid;  /* in */
0518     __u32 min_type;     /* in */
0519     __u32 max_type;     /* in */
0520 
0521     /*
0522      * input: The maximum amount of results desired.
0523      * output: The actual amount of items returned, restricted by any of:
0524      *  - reaching the upper bound of the search range
0525      *  - reaching the input nr_items amount of items
0526      *  - completely filling the supplied memory buffer
0527      */
0528     __u32 nr_items;     /* in/out */
0529 
0530     /* align to 64 bits */
0531     __u32 unused;
0532 
0533     /* some extra for later */
0534     __u64 unused1;
0535     __u64 unused2;
0536     __u64 unused3;
0537     __u64 unused4;
0538 };
0539 
0540 struct btrfs_ioctl_search_header {
0541     __u64 transid;
0542     __u64 objectid;
0543     __u64 offset;
0544     __u32 type;
0545     __u32 len;
0546 };
0547 
0548 #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
0549 /*
0550  * the buf is an array of search headers where
0551  * each header is followed by the actual item
0552  * the type field is expanded to 32 bits for alignment
0553  */
0554 struct btrfs_ioctl_search_args {
0555     struct btrfs_ioctl_search_key key;
0556     char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
0557 };
0558 
0559 struct btrfs_ioctl_search_args_v2 {
0560     struct btrfs_ioctl_search_key key; /* in/out - search parameters */
0561     __u64 buf_size;        /* in - size of buffer
0562                         * out - on EOVERFLOW: needed size
0563                         *       to store item */
0564     __u64 buf[];                       /* out - found items */
0565 };
0566 
0567 struct btrfs_ioctl_clone_range_args {
0568   __s64 src_fd;
0569   __u64 src_offset, src_length;
0570   __u64 dest_offset;
0571 };
0572 
0573 /*
0574  * flags definition for the defrag range ioctl
0575  *
0576  * Used by:
0577  * struct btrfs_ioctl_defrag_range_args.flags
0578  */
0579 #define BTRFS_DEFRAG_RANGE_COMPRESS 1
0580 #define BTRFS_DEFRAG_RANGE_START_IO 2
0581 struct btrfs_ioctl_defrag_range_args {
0582     /* start of the defrag operation */
0583     __u64 start;
0584 
0585     /* number of bytes to defrag, use (u64)-1 to say all */
0586     __u64 len;
0587 
0588     /*
0589      * flags for the operation, which can include turning
0590      * on compression for this one defrag
0591      */
0592     __u64 flags;
0593 
0594     /*
0595      * any extent bigger than this will be considered
0596      * already defragged.  Use 0 to take the kernel default
0597      * Use 1 to say every single extent must be rewritten
0598      */
0599     __u32 extent_thresh;
0600 
0601     /*
0602      * which compression method to use if turning on compression
0603      * for this defrag operation.  If unspecified, zlib will
0604      * be used
0605      */
0606     __u32 compress_type;
0607 
0608     /* spare for later */
0609     __u32 unused[4];
0610 };
0611 
0612 
0613 #define BTRFS_SAME_DATA_DIFFERS 1
0614 /* For extent-same ioctl */
0615 struct btrfs_ioctl_same_extent_info {
0616     __s64 fd;       /* in - destination file */
0617     __u64 logical_offset;   /* in - start of extent in destination */
0618     __u64 bytes_deduped;    /* out - total # of bytes we were able
0619                  * to dedupe from this file */
0620     /* status of this dedupe operation:
0621      * 0 if dedup succeeds
0622      * < 0 for error
0623      * == BTRFS_SAME_DATA_DIFFERS if data differs
0624      */
0625     __s32 status;       /* out - see above description */
0626     __u32 reserved;
0627 };
0628 
0629 struct btrfs_ioctl_same_args {
0630     __u64 logical_offset;   /* in - start of extent in source */
0631     __u64 length;       /* in - length of extent */
0632     __u16 dest_count;   /* in - total elements in info array */
0633     __u16 reserved1;
0634     __u32 reserved2;
0635     struct btrfs_ioctl_same_extent_info info[];
0636 };
0637 
0638 struct btrfs_ioctl_space_info {
0639     __u64 flags;
0640     __u64 total_bytes;
0641     __u64 used_bytes;
0642 };
0643 
0644 struct btrfs_ioctl_space_args {
0645     __u64 space_slots;
0646     __u64 total_spaces;
0647     struct btrfs_ioctl_space_info spaces[];
0648 };
0649 
0650 struct btrfs_data_container {
0651     __u32   bytes_left; /* out -- bytes not needed to deliver output */
0652     __u32   bytes_missing;  /* out -- additional bytes needed for result */
0653     __u32   elem_cnt;   /* out */
0654     __u32   elem_missed;    /* out */
0655     __u64   val[];      /* out */
0656 };
0657 
0658 struct btrfs_ioctl_ino_path_args {
0659     __u64               inum;       /* in */
0660     __u64               size;       /* in */
0661     __u64               reserved[4];
0662     /* struct btrfs_data_container  *fspath;       out */
0663     __u64               fspath;     /* out */
0664 };
0665 
0666 struct btrfs_ioctl_logical_ino_args {
0667     __u64               logical;    /* in */
0668     __u64               size;       /* in */
0669     __u64               reserved[3];    /* must be 0 for now */
0670     __u64               flags;      /* in, v2 only */
0671     /* struct btrfs_data_container  *inodes;    out   */
0672     __u64               inodes;
0673 };
0674 /* Return every ref to the extent, not just those containing logical block.
0675  * Requires logical == extent bytenr. */
0676 #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET    (1ULL << 0)
0677 
0678 enum btrfs_dev_stat_values {
0679     /* disk I/O failure stats */
0680     BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
0681     BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
0682     BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
0683 
0684     /* stats for indirect indications for I/O failures */
0685     BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
0686                      * contents is illegal: this is an
0687                      * indication that the block was damaged
0688                      * during read or write, or written to
0689                      * wrong location or read from wrong
0690                      * location */
0691     BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
0692                      * been written */
0693 
0694     BTRFS_DEV_STAT_VALUES_MAX
0695 };
0696 
0697 /* Reset statistics after reading; needs SYS_ADMIN capability */
0698 #define BTRFS_DEV_STATS_RESET       (1ULL << 0)
0699 
0700 struct btrfs_ioctl_get_dev_stats {
0701     __u64 devid;                /* in */
0702     __u64 nr_items;             /* in/out */
0703     __u64 flags;                /* in/out */
0704 
0705     /* out values: */
0706     __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
0707 
0708     /*
0709      * This pads the struct to 1032 bytes. It was originally meant to pad to
0710      * 1024 bytes, but when adding the flags field, the padding calculation
0711      * was not adjusted.
0712      */
0713     __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
0714 };
0715 
0716 #define BTRFS_QUOTA_CTL_ENABLE  1
0717 #define BTRFS_QUOTA_CTL_DISABLE 2
0718 #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
0719 struct btrfs_ioctl_quota_ctl_args {
0720     __u64 cmd;
0721     __u64 status;
0722 };
0723 
0724 struct btrfs_ioctl_quota_rescan_args {
0725     __u64   flags;
0726     __u64   progress;
0727     __u64   reserved[6];
0728 };
0729 
0730 struct btrfs_ioctl_qgroup_assign_args {
0731     __u64 assign;
0732     __u64 src;
0733     __u64 dst;
0734 };
0735 
0736 struct btrfs_ioctl_qgroup_create_args {
0737     __u64 create;
0738     __u64 qgroupid;
0739 };
0740 struct btrfs_ioctl_timespec {
0741     __u64 sec;
0742     __u32 nsec;
0743 };
0744 
0745 struct btrfs_ioctl_received_subvol_args {
0746     char    uuid[BTRFS_UUID_SIZE];  /* in */
0747     __u64   stransid;       /* in */
0748     __u64   rtransid;       /* out */
0749     struct btrfs_ioctl_timespec stime; /* in */
0750     struct btrfs_ioctl_timespec rtime; /* out */
0751     __u64   flags;          /* in */
0752     __u64   reserved[16];       /* in */
0753 };
0754 
0755 /*
0756  * Caller doesn't want file data in the send stream, even if the
0757  * search of clone sources doesn't find an extent. UPDATE_EXTENT
0758  * commands will be sent instead of WRITE commands.
0759  */
0760 #define BTRFS_SEND_FLAG_NO_FILE_DATA        0x1
0761 
0762 /*
0763  * Do not add the leading stream header. Used when multiple snapshots
0764  * are sent back to back.
0765  */
0766 #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER  0x2
0767 
0768 /*
0769  * Omit the command at the end of the stream that indicated the end
0770  * of the stream. This option is used when multiple snapshots are
0771  * sent back to back.
0772  */
0773 #define BTRFS_SEND_FLAG_OMIT_END_CMD        0x4
0774 
0775 /*
0776  * Read the protocol version in the structure
0777  */
0778 #define BTRFS_SEND_FLAG_VERSION         0x8
0779 
0780 /*
0781  * Send compressed data using the ENCODED_WRITE command instead of decompressing
0782  * the data and sending it with the WRITE command. This requires protocol
0783  * version >= 2.
0784  */
0785 #define BTRFS_SEND_FLAG_COMPRESSED      0x10
0786 
0787 #define BTRFS_SEND_FLAG_MASK \
0788     (BTRFS_SEND_FLAG_NO_FILE_DATA | \
0789      BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
0790      BTRFS_SEND_FLAG_OMIT_END_CMD | \
0791      BTRFS_SEND_FLAG_VERSION | \
0792      BTRFS_SEND_FLAG_COMPRESSED)
0793 
0794 struct btrfs_ioctl_send_args {
0795     __s64 send_fd;          /* in */
0796     __u64 clone_sources_count;  /* in */
0797     __u64 __user *clone_sources;    /* in */
0798     __u64 parent_root;      /* in */
0799     __u64 flags;            /* in */
0800     __u32 version;          /* in */
0801     __u8  reserved[28];     /* in */
0802 };
0803 
0804 /*
0805  * Information about a fs tree root.
0806  *
0807  * All items are filled by the ioctl
0808  */
0809 struct btrfs_ioctl_get_subvol_info_args {
0810     /* Id of this subvolume */
0811     __u64 treeid;
0812 
0813     /* Name of this subvolume, used to get the real name at mount point */
0814     char name[BTRFS_VOL_NAME_MAX + 1];
0815 
0816     /*
0817      * Id of the subvolume which contains this subvolume.
0818      * Zero for top-level subvolume or a deleted subvolume.
0819      */
0820     __u64 parent_id;
0821 
0822     /*
0823      * Inode number of the directory which contains this subvolume.
0824      * Zero for top-level subvolume or a deleted subvolume
0825      */
0826     __u64 dirid;
0827 
0828     /* Latest transaction id of this subvolume */
0829     __u64 generation;
0830 
0831     /* Flags of this subvolume */
0832     __u64 flags;
0833 
0834     /* UUID of this subvolume */
0835     __u8 uuid[BTRFS_UUID_SIZE];
0836 
0837     /*
0838      * UUID of the subvolume of which this subvolume is a snapshot.
0839      * All zero for a non-snapshot subvolume.
0840      */
0841     __u8 parent_uuid[BTRFS_UUID_SIZE];
0842 
0843     /*
0844      * UUID of the subvolume from which this subvolume was received.
0845      * All zero for non-received subvolume.
0846      */
0847     __u8 received_uuid[BTRFS_UUID_SIZE];
0848 
0849     /* Transaction id indicating when change/create/send/receive happened */
0850     __u64 ctransid;
0851     __u64 otransid;
0852     __u64 stransid;
0853     __u64 rtransid;
0854     /* Time corresponding to c/o/s/rtransid */
0855     struct btrfs_ioctl_timespec ctime;
0856     struct btrfs_ioctl_timespec otime;
0857     struct btrfs_ioctl_timespec stime;
0858     struct btrfs_ioctl_timespec rtime;
0859 
0860     /* Must be zero */
0861     __u64 reserved[8];
0862 };
0863 
0864 #define BTRFS_MAX_ROOTREF_BUFFER_NUM 255
0865 struct btrfs_ioctl_get_subvol_rootref_args {
0866         /* in/out, minimum id of rootref's treeid to be searched */
0867         __u64 min_treeid;
0868 
0869         /* out */
0870         struct {
0871             __u64 treeid;
0872             __u64 dirid;
0873         } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
0874 
0875         /* out, number of found items */
0876         __u8 num_items;
0877         __u8 align[7];
0878 };
0879 
0880 /*
0881  * Data and metadata for an encoded read or write.
0882  *
0883  * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g.,
0884  * compression). This can be used to read the compressed contents of a file or
0885  * write pre-compressed data directly to a file.
0886  *
0887  * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially
0888  * preadv/pwritev with additional metadata about how the data is encoded and the
0889  * size of the unencoded data.
0890  *
0891  * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills
0892  * the metadata fields, and returns the size of the encoded data. It reads one
0893  * extent per call. It can also read data which is not encoded.
0894  *
0895  * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data
0896  * from the iovecs, and returns the size of the encoded data. Note that the
0897  * encoded data is not validated when it is written; if it is not valid (e.g.,
0898  * it cannot be decompressed), then a subsequent read may return an error.
0899  *
0900  * Since the filesystem page cache contains decoded data, encoded I/O bypasses
0901  * the page cache. Encoded I/O requires CAP_SYS_ADMIN.
0902  */
0903 struct btrfs_ioctl_encoded_io_args {
0904     /* Input parameters for both reads and writes. */
0905 
0906     /*
0907      * iovecs containing encoded data.
0908      *
0909      * For reads, if the size of the encoded data is larger than the sum of
0910      * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with
0911      * ENOBUFS.
0912      *
0913      * For writes, the size of the encoded data is the sum of iov[n].iov_len
0914      * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may
0915      * increase in the future). This must also be less than or equal to
0916      * unencoded_len.
0917      */
0918     const struct iovec __user *iov;
0919     /* Number of iovecs. */
0920     unsigned long iovcnt;
0921     /*
0922      * Offset in file.
0923      *
0924      * For writes, must be aligned to the sector size of the filesystem.
0925      */
0926     __s64 offset;
0927     /* Currently must be zero. */
0928     __u64 flags;
0929 
0930     /*
0931      * For reads, the following members are output parameters that will
0932      * contain the returned metadata for the encoded data.
0933      * For writes, the following members must be set to the metadata for the
0934      * encoded data.
0935      */
0936 
0937     /*
0938      * Length of the data in the file.
0939      *
0940      * Must be less than or equal to unencoded_len - unencoded_offset. For
0941      * writes, must be aligned to the sector size of the filesystem unless
0942      * the data ends at or beyond the current end of the file.
0943      */
0944     __u64 len;
0945     /*
0946      * Length of the unencoded (i.e., decrypted and decompressed) data.
0947      *
0948      * For writes, must be no more than 128 KiB (this limit may increase in
0949      * the future). If the unencoded data is actually longer than
0950      * unencoded_len, then it is truncated; if it is shorter, then it is
0951      * extended with zeroes.
0952      */
0953     __u64 unencoded_len;
0954     /*
0955      * Offset from the first byte of the unencoded data to the first byte of
0956      * logical data in the file.
0957      *
0958      * Must be less than unencoded_len.
0959      */
0960     __u64 unencoded_offset;
0961     /*
0962      * BTRFS_ENCODED_IO_COMPRESSION_* type.
0963      *
0964      * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE.
0965      */
0966     __u32 compression;
0967     /* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */
0968     __u32 encryption;
0969     /*
0970      * Reserved for future expansion.
0971      *
0972      * For reads, always returned as zero. Users should check for non-zero
0973      * bytes. If there are any, then the kernel has a newer version of this
0974      * structure with additional information that the user definition is
0975      * missing.
0976      *
0977      * For writes, must be zeroed.
0978      */
0979     __u8 reserved[64];
0980 };
0981 
0982 /* Data is not compressed. */
0983 #define BTRFS_ENCODED_IO_COMPRESSION_NONE 0
0984 /* Data is compressed as a single zlib stream. */
0985 #define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1
0986 /*
0987  * Data is compressed as a single zstd frame with the windowLog compression
0988  * parameter set to no more than 17.
0989  */
0990 #define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2
0991 /*
0992  * Data is compressed sector by sector (using the sector size indicated by the
0993  * name of the constant) with LZO1X and wrapped in the format documented in
0994  * fs/btrfs/lzo.c. For writes, the compression sector size must match the
0995  * filesystem sector size.
0996  */
0997 #define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3
0998 #define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4
0999 #define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5
1000 #define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6
1001 #define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7
1002 #define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8
1003 
1004 /* Data is not encrypted. */
1005 #define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0
1006 #define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1
1007 
1008 /* Error codes as returned by the kernel */
1009 enum btrfs_err_code {
1010     BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
1011     BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
1012     BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
1013     BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
1014     BTRFS_ERROR_DEV_TGT_REPLACE,
1015     BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
1016     BTRFS_ERROR_DEV_ONLY_WRITABLE,
1017     BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS,
1018     BTRFS_ERROR_DEV_RAID1C3_MIN_NOT_MET,
1019     BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET,
1020 };
1021 
1022 #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
1023                    struct btrfs_ioctl_vol_args)
1024 #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
1025                    struct btrfs_ioctl_vol_args)
1026 #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
1027                    struct btrfs_ioctl_vol_args)
1028 #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
1029                    struct btrfs_ioctl_vol_args)
1030 #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \
1031                    struct btrfs_ioctl_vol_args)
1032 /* trans start and trans end are dangerous, and only for
1033  * use by applications that know how to avoid the
1034  * resulting deadlocks
1035  */
1036 #define BTRFS_IOC_TRANS_START  _IO(BTRFS_IOCTL_MAGIC, 6)
1037 #define BTRFS_IOC_TRANS_END    _IO(BTRFS_IOCTL_MAGIC, 7)
1038 #define BTRFS_IOC_SYNC         _IO(BTRFS_IOCTL_MAGIC, 8)
1039 
1040 #define BTRFS_IOC_CLONE        _IOW(BTRFS_IOCTL_MAGIC, 9, int)
1041 #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
1042                    struct btrfs_ioctl_vol_args)
1043 #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
1044                    struct btrfs_ioctl_vol_args)
1045 #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
1046                    struct btrfs_ioctl_vol_args)
1047 
1048 #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
1049                   struct btrfs_ioctl_clone_range_args)
1050 
1051 #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
1052                    struct btrfs_ioctl_vol_args)
1053 #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
1054                 struct btrfs_ioctl_vol_args)
1055 #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
1056                 struct btrfs_ioctl_defrag_range_args)
1057 #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
1058                    struct btrfs_ioctl_search_args)
1059 #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
1060                        struct btrfs_ioctl_search_args_v2)
1061 #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
1062                    struct btrfs_ioctl_ino_lookup_args)
1063 #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
1064 #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
1065                     struct btrfs_ioctl_space_args)
1066 #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
1067 #define BTRFS_IOC_WAIT_SYNC  _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
1068 #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
1069                    struct btrfs_ioctl_vol_args_v2)
1070 #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
1071                    struct btrfs_ioctl_vol_args_v2)
1072 #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
1073 #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
1074 #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
1075                   struct btrfs_ioctl_scrub_args)
1076 #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
1077 #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
1078                        struct btrfs_ioctl_scrub_args)
1079 #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
1080                  struct btrfs_ioctl_dev_info_args)
1081 #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
1082                    struct btrfs_ioctl_fs_info_args)
1083 #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
1084                    struct btrfs_ioctl_balance_args)
1085 #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
1086 #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
1087                     struct btrfs_ioctl_balance_args)
1088 #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
1089                     struct btrfs_ioctl_ino_path_args)
1090 #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
1091                     struct btrfs_ioctl_logical_ino_args)
1092 #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
1093                 struct btrfs_ioctl_received_subvol_args)
1094 #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
1095 #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
1096                      struct btrfs_ioctl_vol_args)
1097 #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
1098                    struct btrfs_ioctl_quota_ctl_args)
1099 #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
1100                    struct btrfs_ioctl_qgroup_assign_args)
1101 #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
1102                    struct btrfs_ioctl_qgroup_create_args)
1103 #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
1104                    struct btrfs_ioctl_qgroup_limit_args)
1105 #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
1106                    struct btrfs_ioctl_quota_rescan_args)
1107 #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
1108                    struct btrfs_ioctl_quota_rescan_args)
1109 #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
1110 #define BTRFS_IOC_GET_FSLABEL   FS_IOC_GETFSLABEL
1111 #define BTRFS_IOC_SET_FSLABEL   FS_IOC_SETFSLABEL
1112 #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
1113                       struct btrfs_ioctl_get_dev_stats)
1114 #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
1115                     struct btrfs_ioctl_dev_replace_args)
1116 #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
1117                      struct btrfs_ioctl_same_args)
1118 #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
1119                    struct btrfs_ioctl_feature_flags)
1120 #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
1121                    struct btrfs_ioctl_feature_flags[2])
1122 #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
1123                    struct btrfs_ioctl_feature_flags[3])
1124 #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \
1125                    struct btrfs_ioctl_vol_args_v2)
1126 #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \
1127                     struct btrfs_ioctl_logical_ino_args)
1128 #define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \
1129                 struct btrfs_ioctl_get_subvol_info_args)
1130 #define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \
1131                 struct btrfs_ioctl_get_subvol_rootref_args)
1132 #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
1133                 struct btrfs_ioctl_ino_lookup_user_args)
1134 #define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
1135                 struct btrfs_ioctl_vol_args_v2)
1136 #define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \
1137                     struct btrfs_ioctl_encoded_io_args)
1138 #define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \
1139                      struct btrfs_ioctl_encoded_io_args)
1140 
1141 #endif /* _UAPI_LINUX_BTRFS_H */