Greg Kroah-Hartman | e2be04c | 2017-11-01 15:09:13 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ |
Chris Mason | 6cbd557 | 2007-06-12 09:07:21 -0400 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2007 Oracle. All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public |
| 7 | * License v2 as published by the Free Software Foundation. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | * General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public |
| 15 | * License along with this program; if not, write to the |
| 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
| 17 | * Boston, MA 021110-1307, USA. |
| 18 | */ |
| 19 | |
Filipe Brandenburger | 55e301f | 2013-01-29 06:04:50 +0000 | [diff] [blame] | 20 | #ifndef _UAPI_LINUX_BTRFS_H |
| 21 | #define _UAPI_LINUX_BTRFS_H |
| 22 | #include <linux/types.h> |
Chris Mason | c5739bb | 2007-04-10 09:27:04 -0400 | [diff] [blame] | 23 | #include <linux/ioctl.h> |
| 24 | |
| 25 | #define BTRFS_IOCTL_MAGIC 0x94 |
| 26 | #define BTRFS_VOL_NAME_MAX 255 |
Jeff Mahoney | d4ae133 | 2016-04-01 16:14:23 -0400 | [diff] [blame] | 27 | #define BTRFS_LABEL_SIZE 256 |
Chris Mason | 8a4b83c | 2008-03-24 15:02:07 -0400 | [diff] [blame] | 28 | |
Chris Mason | c071fcf | 2009-01-16 11:59:08 -0500 | [diff] [blame] | 29 | /* this should be 4k */ |
Sage Weil | 72fd032 | 2010-10-29 15:41:32 -0400 | [diff] [blame] | 30 | #define BTRFS_PATH_NAME_MAX 4087 |
Chris Mason | c5739bb | 2007-04-10 09:27:04 -0400 | [diff] [blame] | 31 | struct btrfs_ioctl_vol_args { |
Chris Mason | 3de4586 | 2008-11-17 21:02:50 -0500 | [diff] [blame] | 32 | __s64 fd; |
Chris Mason | 8a4b83c | 2008-03-24 15:02:07 -0400 | [diff] [blame] | 33 | char name[BTRFS_PATH_NAME_MAX + 1]; |
Chris Mason | c5739bb | 2007-04-10 09:27:04 -0400 | [diff] [blame] | 34 | }; |
| 35 | |
Anand Jain | ad8bc4d | 2017-12-06 11:40:10 +0800 | [diff] [blame] | 36 | #define BTRFS_DEVICE_PATH_NAME_MAX 1024 |
| 37 | #define BTRFS_SUBVOL_NAME_MAX 4039 |
| 38 | |
| 39 | #define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0) |
| 40 | #define BTRFS_SUBVOL_RDONLY (1ULL << 1) |
| 41 | #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2) |
Stefan Behrens | 3f6bcfb | 2012-11-06 15:08:53 +0100 | [diff] [blame] | 42 | |
David Sterba | 735654e | 2016-02-15 18:15:21 +0100 | [diff] [blame] | 43 | #define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3) |
| 44 | |
| 45 | #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \ |
Anand Jain | 6b526ed | 2016-02-13 10:01:39 +0800 | [diff] [blame] | 46 | (BTRFS_SUBVOL_CREATE_ASYNC | \ |
| 47 | BTRFS_SUBVOL_RDONLY | \ |
| 48 | BTRFS_SUBVOL_QGROUP_INHERIT | \ |
David Sterba | 735654e | 2016-02-15 18:15:21 +0100 | [diff] [blame] | 49 | BTRFS_DEVICE_SPEC_BY_ID) |
Anand Jain | 6b526ed | 2016-02-13 10:01:39 +0800 | [diff] [blame] | 50 | |
Jan Schmidt | 475f638 | 2011-03-11 15:41:01 +0100 | [diff] [blame] | 51 | #define BTRFS_FSID_SIZE 16 |
| 52 | #define BTRFS_UUID_SIZE 16 |
Anand Jain | b2373f2 | 2014-06-03 11:36:03 +0800 | [diff] [blame] | 53 | #define BTRFS_UUID_UNPARSED_SIZE 37 |
Li Zefan | fdfb1e4 | 2010-12-10 06:41:56 +0000 | [diff] [blame] | 54 | |
Jeff Mahoney | 83288b6 | 2016-04-01 16:14:24 -0400 | [diff] [blame] | 55 | /* |
| 56 | * flags definition for qgroup limits |
| 57 | * |
| 58 | * Used by: |
| 59 | * struct btrfs_qgroup_limit.flags |
| 60 | * struct btrfs_qgroup_limit_item.flags |
| 61 | */ |
| 62 | #define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0) |
| 63 | #define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1) |
| 64 | #define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2) |
| 65 | #define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3) |
| 66 | #define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4) |
| 67 | #define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5) |
Arne Jansen | bed92ea | 2012-06-28 18:03:02 +0200 | [diff] [blame] | 68 | |
| 69 | struct btrfs_qgroup_limit { |
| 70 | __u64 flags; |
| 71 | __u64 max_rfer; |
| 72 | __u64 max_excl; |
| 73 | __u64 rsv_rfer; |
| 74 | __u64 rsv_excl; |
| 75 | }; |
| 76 | |
Jeff Mahoney | 83288b6 | 2016-04-01 16:14:24 -0400 | [diff] [blame] | 77 | /* |
| 78 | * flags definition for qgroup inheritance |
| 79 | * |
| 80 | * Used by: |
| 81 | * struct btrfs_qgroup_inherit.flags |
| 82 | */ |
| 83 | #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0) |
| 84 | |
Arne Jansen | bed92ea | 2012-06-28 18:03:02 +0200 | [diff] [blame] | 85 | struct btrfs_qgroup_inherit { |
| 86 | __u64 flags; |
| 87 | __u64 num_qgroups; |
| 88 | __u64 num_ref_copies; |
| 89 | __u64 num_excl_copies; |
| 90 | struct btrfs_qgroup_limit lim; |
| 91 | __u64 qgroups[0]; |
| 92 | }; |
| 93 | |
| 94 | struct btrfs_ioctl_qgroup_limit_args { |
| 95 | __u64 qgroupid; |
| 96 | struct btrfs_qgroup_limit lim; |
| 97 | }; |
| 98 | |
Jeff Mahoney | 884f6ec | 2016-04-01 16:14:25 -0400 | [diff] [blame] | 99 | /* |
| 100 | * flags for subvolumes |
| 101 | * |
| 102 | * Used by: |
| 103 | * struct btrfs_ioctl_vol_args_v2.flags |
| 104 | * |
| 105 | * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls: |
| 106 | * - BTRFS_IOC_SUBVOL_GETFLAGS |
| 107 | * - BTRFS_IOC_SUBVOL_SETFLAGS |
| 108 | */ |
Jeff Mahoney | 884f6ec | 2016-04-01 16:14:25 -0400 | [diff] [blame] | 109 | |
Li Zefan | fdfb1e4 | 2010-12-10 06:41:56 +0000 | [diff] [blame] | 110 | struct btrfs_ioctl_vol_args_v2 { |
Sage Weil | 72fd032 | 2010-10-29 15:41:32 -0400 | [diff] [blame] | 111 | __s64 fd; |
| 112 | __u64 transid; |
Li Zefan | fdfb1e4 | 2010-12-10 06:41:56 +0000 | [diff] [blame] | 113 | __u64 flags; |
Arne Jansen | 6f72c7e | 2011-09-14 15:58:21 +0200 | [diff] [blame] | 114 | union { |
| 115 | struct { |
| 116 | __u64 size; |
| 117 | struct btrfs_qgroup_inherit __user *qgroup_inherit; |
| 118 | }; |
| 119 | __u64 unused[4]; |
| 120 | }; |
Anand Jain | 6b526ed | 2016-02-13 10:01:39 +0800 | [diff] [blame] | 121 | union { |
| 122 | char name[BTRFS_SUBVOL_NAME_MAX + 1]; |
Vinson Lee | 1691cf1 | 2016-05-28 07:04:38 +0000 | [diff] [blame] | 123 | __u64 devid; |
Anand Jain | 6b526ed | 2016-02-13 10:01:39 +0800 | [diff] [blame] | 124 | }; |
Sage Weil | 72fd032 | 2010-10-29 15:41:32 -0400 | [diff] [blame] | 125 | }; |
| 126 | |
Arne Jansen | a2de733 | 2011-03-08 14:14:00 +0100 | [diff] [blame] | 127 | /* |
| 128 | * structure to report errors and progress to userspace, either as a |
| 129 | * result of a finished scrub, a canceled scrub or a progress inquiry |
| 130 | */ |
| 131 | struct btrfs_scrub_progress { |
| 132 | __u64 data_extents_scrubbed; /* # of data extents scrubbed */ |
| 133 | __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */ |
| 134 | __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */ |
| 135 | __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */ |
| 136 | __u64 read_errors; /* # of read errors encountered (EIO) */ |
| 137 | __u64 csum_errors; /* # of failed csum checks */ |
| 138 | __u64 verify_errors; /* # of occurences, where the metadata |
| 139 | * of a tree block did not match the |
| 140 | * expected values, like generation or |
| 141 | * logical */ |
| 142 | __u64 no_csum; /* # of 4k data block for which no csum |
| 143 | * is present, probably the result of |
| 144 | * data written with nodatasum */ |
| 145 | __u64 csum_discards; /* # of csum for which no data was found |
| 146 | * in the extent tree. */ |
| 147 | __u64 super_errors; /* # of bad super blocks encountered */ |
| 148 | __u64 malloc_errors; /* # of internal kmalloc errors. These |
| 149 | * will likely cause an incomplete |
| 150 | * scrub */ |
| 151 | __u64 uncorrectable_errors; /* # of errors where either no intact |
| 152 | * copy was found or the writeback |
| 153 | * failed */ |
| 154 | __u64 corrected_errors; /* # of errors corrected */ |
| 155 | __u64 last_physical; /* last physical address scrubbed. In |
| 156 | * case a scrub was aborted, this can |
| 157 | * be used to restart the scrub */ |
| 158 | __u64 unverified_errors; /* # of occurences where a read for a |
| 159 | * full (64k) bio failed, but the re- |
| 160 | * check succeeded for each 4k piece. |
| 161 | * Intermittent error. */ |
| 162 | }; |
| 163 | |
Arne Jansen | 8628764 | 2011-03-23 16:34:19 +0100 | [diff] [blame] | 164 | #define BTRFS_SCRUB_READONLY 1 |
Jan Schmidt | 475f638 | 2011-03-11 15:41:01 +0100 | [diff] [blame] | 165 | struct btrfs_ioctl_scrub_args { |
| 166 | __u64 devid; /* in */ |
| 167 | __u64 start; /* in */ |
| 168 | __u64 end; /* in */ |
| 169 | __u64 flags; /* in */ |
| 170 | struct btrfs_scrub_progress progress; /* out */ |
| 171 | /* pad to 1k */ |
| 172 | __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8]; |
| 173 | }; |
| 174 | |
Stefan Behrens | e93c89c | 2012-11-05 17:33:06 +0100 | [diff] [blame] | 175 | #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0 |
| 176 | #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1 |
| 177 | struct btrfs_ioctl_dev_replace_start_params { |
| 178 | __u64 srcdevid; /* in, if 0, use srcdev_name instead */ |
Stefan Behrens | e93c89c | 2012-11-05 17:33:06 +0100 | [diff] [blame] | 179 | __u64 cont_reading_from_srcdev_mode; /* in, see #define |
| 180 | * above */ |
Stefan Behrens | 3f6bcfb | 2012-11-06 15:08:53 +0100 | [diff] [blame] | 181 | __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ |
| 182 | __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */ |
Stefan Behrens | e93c89c | 2012-11-05 17:33:06 +0100 | [diff] [blame] | 183 | }; |
| 184 | |
| 185 | #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0 |
| 186 | #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1 |
| 187 | #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2 |
| 188 | #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3 |
| 189 | #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4 |
| 190 | struct btrfs_ioctl_dev_replace_status_params { |
| 191 | __u64 replace_state; /* out, see #define above */ |
| 192 | __u64 progress_1000; /* out, 0 <= x <= 1000 */ |
| 193 | __u64 time_started; /* out, seconds since 1-Jan-1970 */ |
| 194 | __u64 time_stopped; /* out, seconds since 1-Jan-1970 */ |
| 195 | __u64 num_write_errors; /* out */ |
| 196 | __u64 num_uncorrectable_read_errors; /* out */ |
| 197 | }; |
| 198 | |
| 199 | #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0 |
| 200 | #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1 |
| 201 | #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2 |
| 202 | #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0 |
| 203 | #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1 |
| 204 | #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2 |
Eryu Guan | 2fc9f6b | 2014-10-13 12:42:12 +0800 | [diff] [blame] | 205 | #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3 |
Stefan Behrens | e93c89c | 2012-11-05 17:33:06 +0100 | [diff] [blame] | 206 | struct btrfs_ioctl_dev_replace_args { |
| 207 | __u64 cmd; /* in */ |
| 208 | __u64 result; /* out */ |
| 209 | |
| 210 | union { |
| 211 | struct btrfs_ioctl_dev_replace_start_params start; |
| 212 | struct btrfs_ioctl_dev_replace_status_params status; |
| 213 | }; /* in/out */ |
| 214 | |
| 215 | __u64 spare[64]; |
| 216 | }; |
| 217 | |
Jan Schmidt | 475f638 | 2011-03-11 15:41:01 +0100 | [diff] [blame] | 218 | struct btrfs_ioctl_dev_info_args { |
| 219 | __u64 devid; /* in/out */ |
| 220 | __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */ |
| 221 | __u64 bytes_used; /* out */ |
| 222 | __u64 total_bytes; /* out */ |
| 223 | __u64 unused[379]; /* pad to 4k */ |
| 224 | __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */ |
| 225 | }; |
| 226 | |
| 227 | struct btrfs_ioctl_fs_info_args { |
| 228 | __u64 max_id; /* out */ |
| 229 | __u64 num_devices; /* out */ |
| 230 | __u8 fsid[BTRFS_FSID_SIZE]; /* out */ |
David Sterba | 80a773f | 2014-05-07 18:17:06 +0200 | [diff] [blame] | 231 | __u32 nodesize; /* out */ |
| 232 | __u32 sectorsize; /* out */ |
| 233 | __u32 clone_alignment; /* out */ |
| 234 | __u32 reserved32; |
| 235 | __u64 reserved[122]; /* pad to 1k */ |
Jan Schmidt | 475f638 | 2011-03-11 15:41:01 +0100 | [diff] [blame] | 236 | }; |
| 237 | |
Jeff Mahoney | 18db9ac | 2016-04-01 16:14:26 -0400 | [diff] [blame] | 238 | /* |
| 239 | * feature flags |
| 240 | * |
| 241 | * Used by: |
| 242 | * struct btrfs_ioctl_feature_flags |
| 243 | */ |
Omar Sandoval | 6675df3 | 2016-09-22 17:24:22 -0700 | [diff] [blame] | 244 | #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0) |
| 245 | /* |
| 246 | * Older kernels (< 4.9) on big-endian systems produced broken free space tree |
| 247 | * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions |
| 248 | * < 4.7.3). If this bit is clear, then the free space tree cannot be trusted. |
| 249 | * btrfs-progs can also intentionally clear this bit to ask the kernel to |
| 250 | * rebuild the free space tree, however this might not work on older kernels |
| 251 | * that do not know about this bit. If not sure, clear the cache manually on |
| 252 | * first mount when booting older kernel versions. |
| 253 | */ |
| 254 | #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1) |
Jeff Mahoney | 18db9ac | 2016-04-01 16:14:26 -0400 | [diff] [blame] | 255 | |
| 256 | #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0) |
| 257 | #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1) |
| 258 | #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2) |
| 259 | #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3) |
Nick Terrell | 5c1aab1 | 2017-08-09 19:39:02 -0700 | [diff] [blame] | 260 | #define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4) |
Jeff Mahoney | 18db9ac | 2016-04-01 16:14:26 -0400 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * older kernels tried to do bigger metadata blocks, but the |
| 264 | * code was pretty buggy. Lets not let them try anymore. |
| 265 | */ |
| 266 | #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5) |
| 267 | |
| 268 | #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6) |
| 269 | #define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7) |
| 270 | #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8) |
| 271 | #define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9) |
Nikolay Borisov | 7239ff4 | 2018-10-30 16:43:23 +0200 | [diff] [blame] | 272 | #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10) |
Jeff Mahoney | 18db9ac | 2016-04-01 16:14:26 -0400 | [diff] [blame] | 273 | |
Jeff Mahoney | 2eaa055 | 2013-11-15 15:33:55 -0500 | [diff] [blame] | 274 | struct btrfs_ioctl_feature_flags { |
| 275 | __u64 compat_flags; |
| 276 | __u64 compat_ro_flags; |
| 277 | __u64 incompat_flags; |
| 278 | }; |
| 279 | |
Ilya Dryomov | 837d5b6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 280 | /* balance control ioctl modes */ |
| 281 | #define BTRFS_BALANCE_CTL_PAUSE 1 |
Ilya Dryomov | a7e99c6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 282 | #define BTRFS_BALANCE_CTL_CANCEL 2 |
Ilya Dryomov | 837d5b6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 283 | |
Ilya Dryomov | c9e9f97 | 2012-01-16 22:04:47 +0200 | [diff] [blame] | 284 | /* |
| 285 | * this is packed, because it should be exactly the same as its disk |
| 286 | * byte order counterpart (struct btrfs_disk_balance_args) |
| 287 | */ |
| 288 | struct btrfs_balance_args { |
| 289 | __u64 profiles; |
David Sterba | bc30946 | 2015-10-20 18:22:13 +0200 | [diff] [blame] | 290 | union { |
Hans van Kranenburg | 261cc2c | 2017-03-08 18:58:43 +0100 | [diff] [blame] | 291 | __u64 usage; |
David Sterba | bc30946 | 2015-10-20 18:22:13 +0200 | [diff] [blame] | 292 | struct { |
Hans van Kranenburg | 261cc2c | 2017-03-08 18:58:43 +0100 | [diff] [blame] | 293 | __u32 usage_min; |
| 294 | __u32 usage_max; |
David Sterba | bc30946 | 2015-10-20 18:22:13 +0200 | [diff] [blame] | 295 | }; |
| 296 | }; |
Ilya Dryomov | c9e9f97 | 2012-01-16 22:04:47 +0200 | [diff] [blame] | 297 | __u64 devid; |
| 298 | __u64 pstart; |
| 299 | __u64 pend; |
| 300 | __u64 vstart; |
| 301 | __u64 vend; |
| 302 | |
| 303 | __u64 target; |
| 304 | |
| 305 | __u64 flags; |
| 306 | |
David Sterba | 12907fc | 2015-10-10 17:16:50 +0200 | [diff] [blame] | 307 | /* |
| 308 | * BTRFS_BALANCE_ARGS_LIMIT with value 'limit' |
| 309 | * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum |
| 310 | * and maximum |
| 311 | */ |
| 312 | union { |
| 313 | __u64 limit; /* limit number of processed chunks */ |
| 314 | struct { |
| 315 | __u32 limit_min; |
| 316 | __u32 limit_max; |
| 317 | }; |
| 318 | }; |
GabrÃel Arthúr Pétursson | dee32d0 | 2015-09-28 22:32:41 +0000 | [diff] [blame] | 319 | |
| 320 | /* |
| 321 | * Process chunks that cross stripes_min..stripes_max devices, |
| 322 | * BTRFS_BALANCE_ARGS_STRIPES_RANGE |
| 323 | */ |
Hans van Kranenburg | 261cc2c | 2017-03-08 18:58:43 +0100 | [diff] [blame] | 324 | __u32 stripes_min; |
| 325 | __u32 stripes_max; |
GabrÃel Arthúr Pétursson | dee32d0 | 2015-09-28 22:32:41 +0000 | [diff] [blame] | 326 | |
| 327 | __u64 unused[6]; |
Ilya Dryomov | c9e9f97 | 2012-01-16 22:04:47 +0200 | [diff] [blame] | 328 | } __attribute__ ((__packed__)); |
| 329 | |
| 330 | /* report balance progress to userspace */ |
| 331 | struct btrfs_balance_progress { |
| 332 | __u64 expected; /* estimated # of chunks that will be |
| 333 | * relocated to fulfill the request */ |
| 334 | __u64 considered; /* # of chunks we have considered so far */ |
| 335 | __u64 completed; /* # of chunks relocated so far */ |
| 336 | }; |
| 337 | |
Jeff Mahoney | 04cd01d | 2016-04-01 16:14:27 -0400 | [diff] [blame] | 338 | /* |
| 339 | * flags definition for balance |
| 340 | * |
| 341 | * Restriper's general type filter |
| 342 | * |
| 343 | * Used by: |
| 344 | * btrfs_ioctl_balance_args.flags |
| 345 | * btrfs_balance_control.flags (internal) |
| 346 | */ |
| 347 | #define BTRFS_BALANCE_DATA (1ULL << 0) |
| 348 | #define BTRFS_BALANCE_SYSTEM (1ULL << 1) |
| 349 | #define BTRFS_BALANCE_METADATA (1ULL << 2) |
| 350 | |
| 351 | #define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \ |
| 352 | BTRFS_BALANCE_SYSTEM | \ |
| 353 | BTRFS_BALANCE_METADATA) |
| 354 | |
| 355 | #define BTRFS_BALANCE_FORCE (1ULL << 3) |
| 356 | #define BTRFS_BALANCE_RESUME (1ULL << 4) |
| 357 | |
| 358 | /* |
| 359 | * flags definitions for per-type balance args |
| 360 | * |
| 361 | * Balance filters |
| 362 | * |
| 363 | * Used by: |
| 364 | * struct btrfs_balance_args |
| 365 | */ |
| 366 | #define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0) |
| 367 | #define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1) |
| 368 | #define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2) |
| 369 | #define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3) |
| 370 | #define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4) |
| 371 | #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5) |
| 372 | #define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6) |
| 373 | #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7) |
| 374 | #define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10) |
| 375 | |
| 376 | #define BTRFS_BALANCE_ARGS_MASK \ |
| 377 | (BTRFS_BALANCE_ARGS_PROFILES | \ |
| 378 | BTRFS_BALANCE_ARGS_USAGE | \ |
| 379 | BTRFS_BALANCE_ARGS_DEVID | \ |
| 380 | BTRFS_BALANCE_ARGS_DRANGE | \ |
| 381 | BTRFS_BALANCE_ARGS_VRANGE | \ |
| 382 | BTRFS_BALANCE_ARGS_LIMIT | \ |
| 383 | BTRFS_BALANCE_ARGS_LIMIT_RANGE | \ |
| 384 | BTRFS_BALANCE_ARGS_STRIPES_RANGE | \ |
| 385 | BTRFS_BALANCE_ARGS_USAGE_RANGE) |
| 386 | |
| 387 | /* |
| 388 | * Profile changing flags. When SOFT is set we won't relocate chunk if |
| 389 | * it already has the target profile (even though it may be |
| 390 | * half-filled). |
| 391 | */ |
| 392 | #define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8) |
| 393 | #define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9) |
| 394 | |
| 395 | |
| 396 | /* |
| 397 | * flags definition for balance state |
| 398 | * |
| 399 | * Used by: |
| 400 | * struct btrfs_ioctl_balance_args.state |
| 401 | */ |
Ilya Dryomov | 837d5b6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 402 | #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0) |
| 403 | #define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1) |
Ilya Dryomov | a7e99c6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 404 | #define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2) |
Ilya Dryomov | 837d5b6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 405 | |
Ilya Dryomov | c9e9f97 | 2012-01-16 22:04:47 +0200 | [diff] [blame] | 406 | struct btrfs_ioctl_balance_args { |
| 407 | __u64 flags; /* in/out */ |
| 408 | __u64 state; /* out */ |
| 409 | |
| 410 | struct btrfs_balance_args data; /* in/out */ |
| 411 | struct btrfs_balance_args meta; /* in/out */ |
| 412 | struct btrfs_balance_args sys; /* in/out */ |
| 413 | |
| 414 | struct btrfs_balance_progress stat; /* out */ |
| 415 | |
| 416 | __u64 unused[72]; /* pad to 1k */ |
| 417 | }; |
| 418 | |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 419 | #define BTRFS_INO_LOOKUP_PATH_MAX 4080 |
| 420 | struct btrfs_ioctl_ino_lookup_args { |
| 421 | __u64 treeid; |
| 422 | __u64 objectid; |
| 423 | char name[BTRFS_INO_LOOKUP_PATH_MAX]; |
| 424 | }; |
| 425 | |
Tomohiro Misono | 23d0b79 | 2018-05-21 10:09:44 +0900 | [diff] [blame] | 426 | #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1) |
| 427 | struct btrfs_ioctl_ino_lookup_user_args { |
| 428 | /* in, inode number containing the subvolume of 'subvolid' */ |
| 429 | __u64 dirid; |
| 430 | /* in */ |
| 431 | __u64 treeid; |
| 432 | /* out, name of the subvolume of 'treeid' */ |
| 433 | char name[BTRFS_VOL_NAME_MAX + 1]; |
| 434 | /* |
| 435 | * out, constructed path from the directory with which the ioctl is |
| 436 | * called to dirid |
| 437 | */ |
| 438 | char path[BTRFS_INO_LOOKUP_USER_PATH_MAX]; |
| 439 | }; |
| 440 | |
Hans van Kranenburg | 1a63143 | 2017-06-06 00:20:32 +0200 | [diff] [blame] | 441 | /* Search criteria for the btrfs SEARCH ioctl family. */ |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 442 | struct btrfs_ioctl_search_key { |
Hans van Kranenburg | 1a63143 | 2017-06-06 00:20:32 +0200 | [diff] [blame] | 443 | /* |
| 444 | * The tree we're searching in. 1 is the tree of tree roots, 2 is the |
| 445 | * extent tree, etc... |
| 446 | * |
| 447 | * A special tree_id value of 0 will cause a search in the subvolume |
| 448 | * tree that the inode which is passed to the ioctl is part of. |
| 449 | */ |
| 450 | __u64 tree_id; /* in */ |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 451 | |
| 452 | /* |
Hans van Kranenburg | 1a63143 | 2017-06-06 00:20:32 +0200 | [diff] [blame] | 453 | * When doing a tree search, we're actually taking a slice from a |
| 454 | * linear search space of 136-bit keys. |
| 455 | * |
| 456 | * A full 136-bit tree key is composed as: |
| 457 | * (objectid << 72) + (type << 64) + offset |
| 458 | * |
| 459 | * The individual min and max values for objectid, type and offset |
| 460 | * define the min_key and max_key values for the search range. All |
| 461 | * metadata items with a key in the interval [min_key, max_key] will be |
| 462 | * returned. |
| 463 | * |
| 464 | * Additionally, we can filter the items returned on transaction id of |
| 465 | * the metadata block they're stored in by specifying a transid range. |
| 466 | * Be aware that this transaction id only denotes when the metadata |
| 467 | * page that currently contains the item got written the last time as |
| 468 | * result of a COW operation. The number does not have any meaning |
| 469 | * related to the transaction in which an individual item that is being |
| 470 | * returned was created or changed. |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 471 | */ |
Hans van Kranenburg | 1a63143 | 2017-06-06 00:20:32 +0200 | [diff] [blame] | 472 | __u64 min_objectid; /* in */ |
| 473 | __u64 max_objectid; /* in */ |
| 474 | __u64 min_offset; /* in */ |
| 475 | __u64 max_offset; /* in */ |
| 476 | __u64 min_transid; /* in */ |
| 477 | __u64 max_transid; /* in */ |
| 478 | __u32 min_type; /* in */ |
| 479 | __u32 max_type; /* in */ |
| 480 | |
| 481 | /* |
| 482 | * input: The maximum amount of results desired. |
| 483 | * output: The actual amount of items returned, restricted by any of: |
| 484 | * - reaching the upper bound of the search range |
| 485 | * - reaching the input nr_items amount of items |
| 486 | * - completely filling the supplied memory buffer |
| 487 | */ |
| 488 | __u32 nr_items; /* in/out */ |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 489 | |
| 490 | /* align to 64 bits */ |
| 491 | __u32 unused; |
| 492 | |
| 493 | /* some extra for later */ |
| 494 | __u64 unused1; |
| 495 | __u64 unused2; |
| 496 | __u64 unused3; |
| 497 | __u64 unused4; |
| 498 | }; |
| 499 | |
| 500 | struct btrfs_ioctl_search_header { |
| 501 | __u64 transid; |
| 502 | __u64 objectid; |
| 503 | __u64 offset; |
| 504 | __u32 type; |
| 505 | __u32 len; |
| 506 | }; |
| 507 | |
| 508 | #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key)) |
| 509 | /* |
| 510 | * the buf is an array of search headers where |
| 511 | * each header is followed by the actual item |
| 512 | * the type field is expanded to 32 bits for alignment |
| 513 | */ |
| 514 | struct btrfs_ioctl_search_args { |
| 515 | struct btrfs_ioctl_search_key key; |
| 516 | char buf[BTRFS_SEARCH_ARGS_BUFSIZE]; |
| 517 | }; |
| 518 | |
Gerhard Heift | cc68a8a | 2014-01-30 16:24:03 +0100 | [diff] [blame] | 519 | struct btrfs_ioctl_search_args_v2 { |
| 520 | struct btrfs_ioctl_search_key key; /* in/out - search parameters */ |
| 521 | __u64 buf_size; /* in - size of buffer |
| 522 | * out - on EOVERFLOW: needed size |
| 523 | * to store item */ |
| 524 | __u64 buf[0]; /* out - found items */ |
| 525 | }; |
| 526 | |
Chris Mason | c071fcf | 2009-01-16 11:59:08 -0500 | [diff] [blame] | 527 | struct btrfs_ioctl_clone_range_args { |
| 528 | __s64 src_fd; |
| 529 | __u64 src_offset, src_length; |
| 530 | __u64 dest_offset; |
| 531 | }; |
| 532 | |
Jeff Mahoney | 33ca913 | 2016-04-01 16:14:28 -0400 | [diff] [blame] | 533 | /* |
| 534 | * flags definition for the defrag range ioctl |
| 535 | * |
| 536 | * Used by: |
| 537 | * struct btrfs_ioctl_defrag_range_args.flags |
| 538 | */ |
Chris Mason | 1e701a3 | 2010-03-11 09:42:04 -0500 | [diff] [blame] | 539 | #define BTRFS_DEFRAG_RANGE_COMPRESS 1 |
| 540 | #define BTRFS_DEFRAG_RANGE_START_IO 2 |
Jeff Mahoney | 33ca913 | 2016-04-01 16:14:28 -0400 | [diff] [blame] | 541 | struct btrfs_ioctl_defrag_range_args { |
| 542 | /* start of the defrag operation */ |
| 543 | __u64 start; |
| 544 | |
| 545 | /* number of bytes to defrag, use (u64)-1 to say all */ |
| 546 | __u64 len; |
| 547 | |
| 548 | /* |
| 549 | * flags for the operation, which can include turning |
| 550 | * on compression for this one defrag |
| 551 | */ |
| 552 | __u64 flags; |
| 553 | |
| 554 | /* |
| 555 | * any extent bigger than this will be considered |
| 556 | * already defragged. Use 0 to take the kernel default |
| 557 | * Use 1 to say every single extent must be rewritten |
| 558 | */ |
| 559 | __u32 extent_thresh; |
| 560 | |
| 561 | /* |
| 562 | * which compression method to use if turning on compression |
| 563 | * for this defrag operation. If unspecified, zlib will |
| 564 | * be used |
| 565 | */ |
| 566 | __u32 compress_type; |
| 567 | |
| 568 | /* spare for later */ |
| 569 | __u32 unused[4]; |
| 570 | }; |
| 571 | |
Chris Mason | 1e701a3 | 2010-03-11 09:42:04 -0500 | [diff] [blame] | 572 | |
Mark Fasheh | 416161d | 2013-08-06 11:42:51 -0700 | [diff] [blame] | 573 | #define BTRFS_SAME_DATA_DIFFERS 1 |
| 574 | /* For extent-same ioctl */ |
| 575 | struct btrfs_ioctl_same_extent_info { |
| 576 | __s64 fd; /* in - destination file */ |
| 577 | __u64 logical_offset; /* in - start of extent in destination */ |
| 578 | __u64 bytes_deduped; /* out - total # of bytes we were able |
| 579 | * to dedupe from this file */ |
| 580 | /* status of this dedupe operation: |
| 581 | * 0 if dedup succeeds |
| 582 | * < 0 for error |
| 583 | * == BTRFS_SAME_DATA_DIFFERS if data differs |
| 584 | */ |
| 585 | __s32 status; /* out - see above description */ |
| 586 | __u32 reserved; |
| 587 | }; |
| 588 | |
| 589 | struct btrfs_ioctl_same_args { |
| 590 | __u64 logical_offset; /* in - start of extent in source */ |
| 591 | __u64 length; /* in - length of extent */ |
| 592 | __u16 dest_count; /* in - total elements in info array */ |
| 593 | __u16 reserved1; |
| 594 | __u32 reserved2; |
| 595 | struct btrfs_ioctl_same_extent_info info[0]; |
| 596 | }; |
| 597 | |
Josef Bacik | 1406e43 | 2010-01-13 18:19:06 +0000 | [diff] [blame] | 598 | struct btrfs_ioctl_space_info { |
Sage Weil | ce769a2 | 2010-03-16 00:02:26 +0000 | [diff] [blame] | 599 | __u64 flags; |
| 600 | __u64 total_bytes; |
| 601 | __u64 used_bytes; |
Josef Bacik | 1406e43 | 2010-01-13 18:19:06 +0000 | [diff] [blame] | 602 | }; |
| 603 | |
| 604 | struct btrfs_ioctl_space_args { |
Sage Weil | ce769a2 | 2010-03-16 00:02:26 +0000 | [diff] [blame] | 605 | __u64 space_slots; |
| 606 | __u64 total_spaces; |
Josef Bacik | 1406e43 | 2010-01-13 18:19:06 +0000 | [diff] [blame] | 607 | struct btrfs_ioctl_space_info spaces[0]; |
| 608 | }; |
Chris Mason | 1e701a3 | 2010-03-11 09:42:04 -0500 | [diff] [blame] | 609 | |
Jan Schmidt | a542ad1 | 2011-06-13 19:52:59 +0200 | [diff] [blame] | 610 | struct btrfs_data_container { |
| 611 | __u32 bytes_left; /* out -- bytes not needed to deliver output */ |
| 612 | __u32 bytes_missing; /* out -- additional bytes needed for result */ |
| 613 | __u32 elem_cnt; /* out */ |
| 614 | __u32 elem_missed; /* out */ |
Chris Mason | 740c3d2 | 2011-11-02 15:48:34 -0400 | [diff] [blame] | 615 | __u64 val[0]; /* out */ |
Jan Schmidt | a542ad1 | 2011-06-13 19:52:59 +0200 | [diff] [blame] | 616 | }; |
| 617 | |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 618 | struct btrfs_ioctl_ino_path_args { |
| 619 | __u64 inum; /* in */ |
Alexander Block | d04b1de | 2012-05-04 15:16:06 -0400 | [diff] [blame] | 620 | __u64 size; /* in */ |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 621 | __u64 reserved[4]; |
Chris Mason | 740c3d2 | 2011-11-02 15:48:34 -0400 | [diff] [blame] | 622 | /* struct btrfs_data_container *fspath; out */ |
| 623 | __u64 fspath; /* out */ |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 624 | }; |
| 625 | |
| 626 | struct btrfs_ioctl_logical_ino_args { |
| 627 | __u64 logical; /* in */ |
Alexander Block | d04b1de | 2012-05-04 15:16:06 -0400 | [diff] [blame] | 628 | __u64 size; /* in */ |
Zygo Blaxell | d24a67b | 2017-09-22 13:58:46 -0400 | [diff] [blame] | 629 | __u64 reserved[3]; /* must be 0 for now */ |
| 630 | __u64 flags; /* in, v2 only */ |
Chris Mason | 740c3d2 | 2011-11-02 15:48:34 -0400 | [diff] [blame] | 631 | /* struct btrfs_data_container *inodes; out */ |
| 632 | __u64 inodes; |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 633 | }; |
Zygo Blaxell | d24a67b | 2017-09-22 13:58:46 -0400 | [diff] [blame] | 634 | /* Return every ref to the extent, not just those containing logical block. |
| 635 | * Requires logical == extent bytenr. */ |
| 636 | #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0) |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 637 | |
Stefan Behrens | 442a4f6 | 2012-05-25 16:06:08 +0200 | [diff] [blame] | 638 | enum btrfs_dev_stat_values { |
| 639 | /* disk I/O failure stats */ |
| 640 | BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */ |
| 641 | BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */ |
| 642 | BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */ |
| 643 | |
| 644 | /* stats for indirect indications for I/O failures */ |
| 645 | BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or |
| 646 | * contents is illegal: this is an |
| 647 | * indication that the block was damaged |
| 648 | * during read or write, or written to |
| 649 | * wrong location or read from wrong |
| 650 | * location */ |
| 651 | BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not |
| 652 | * been written */ |
| 653 | |
| 654 | BTRFS_DEV_STAT_VALUES_MAX |
| 655 | }; |
| 656 | |
David Sterba | b27f7c0 | 2012-06-22 06:30:39 -0600 | [diff] [blame] | 657 | /* Reset statistics after reading; needs SYS_ADMIN capability */ |
| 658 | #define BTRFS_DEV_STATS_RESET (1ULL << 0) |
| 659 | |
Stefan Behrens | c11d2c2 | 2012-05-25 16:06:09 +0200 | [diff] [blame] | 660 | struct btrfs_ioctl_get_dev_stats { |
| 661 | __u64 devid; /* in */ |
| 662 | __u64 nr_items; /* in/out */ |
David Sterba | b27f7c0 | 2012-06-22 06:30:39 -0600 | [diff] [blame] | 663 | __u64 flags; /* in/out */ |
Stefan Behrens | c11d2c2 | 2012-05-25 16:06:09 +0200 | [diff] [blame] | 664 | |
| 665 | /* out values: */ |
| 666 | __u64 values[BTRFS_DEV_STAT_VALUES_MAX]; |
| 667 | |
| 668 | __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */ |
| 669 | }; |
| 670 | |
Arne Jansen | 5d13a37 | 2011-09-14 15:53:51 +0200 | [diff] [blame] | 671 | #define BTRFS_QUOTA_CTL_ENABLE 1 |
| 672 | #define BTRFS_QUOTA_CTL_DISABLE 2 |
Jan Schmidt | 2f23203 | 2013-04-25 16:04:51 +0000 | [diff] [blame] | 673 | #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3 |
Arne Jansen | 5d13a37 | 2011-09-14 15:53:51 +0200 | [diff] [blame] | 674 | struct btrfs_ioctl_quota_ctl_args { |
| 675 | __u64 cmd; |
| 676 | __u64 status; |
| 677 | }; |
| 678 | |
Jan Schmidt | 2f23203 | 2013-04-25 16:04:51 +0000 | [diff] [blame] | 679 | struct btrfs_ioctl_quota_rescan_args { |
| 680 | __u64 flags; |
| 681 | __u64 progress; |
| 682 | __u64 reserved[6]; |
| 683 | }; |
| 684 | |
Arne Jansen | 5d13a37 | 2011-09-14 15:53:51 +0200 | [diff] [blame] | 685 | struct btrfs_ioctl_qgroup_assign_args { |
| 686 | __u64 assign; |
| 687 | __u64 src; |
| 688 | __u64 dst; |
| 689 | }; |
| 690 | |
| 691 | struct btrfs_ioctl_qgroup_create_args { |
| 692 | __u64 create; |
| 693 | __u64 qgroupid; |
| 694 | }; |
Alexander Block | 8ea05e3 | 2012-07-25 17:35:53 +0200 | [diff] [blame] | 695 | struct btrfs_ioctl_timespec { |
| 696 | __u64 sec; |
| 697 | __u32 nsec; |
| 698 | }; |
| 699 | |
| 700 | struct btrfs_ioctl_received_subvol_args { |
| 701 | char uuid[BTRFS_UUID_SIZE]; /* in */ |
| 702 | __u64 stransid; /* in */ |
| 703 | __u64 rtransid; /* out */ |
| 704 | struct btrfs_ioctl_timespec stime; /* in */ |
| 705 | struct btrfs_ioctl_timespec rtime; /* out */ |
| 706 | __u64 flags; /* in */ |
| 707 | __u64 reserved[16]; /* in */ |
| 708 | }; |
| 709 | |
Mark Fasheh | cb95e7b | 2013-02-04 20:54:57 +0000 | [diff] [blame] | 710 | /* |
| 711 | * Caller doesn't want file data in the send stream, even if the |
| 712 | * search of clone sources doesn't find an extent. UPDATE_EXTENT |
| 713 | * commands will be sent instead of WRITE commands. |
| 714 | */ |
Stefan Behrens | c2c7132 | 2013-04-10 17:10:52 +0000 | [diff] [blame] | 715 | #define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1 |
| 716 | |
| 717 | /* |
| 718 | * Do not add the leading stream header. Used when multiple snapshots |
| 719 | * are sent back to back. |
| 720 | */ |
| 721 | #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2 |
| 722 | |
| 723 | /* |
| 724 | * Omit the command at the end of the stream that indicated the end |
| 725 | * of the stream. This option is used when multiple snapshots are |
| 726 | * sent back to back. |
| 727 | */ |
| 728 | #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4 |
| 729 | |
| 730 | #define BTRFS_SEND_FLAG_MASK \ |
| 731 | (BTRFS_SEND_FLAG_NO_FILE_DATA | \ |
| 732 | BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \ |
| 733 | BTRFS_SEND_FLAG_OMIT_END_CMD) |
Mark Fasheh | cb95e7b | 2013-02-04 20:54:57 +0000 | [diff] [blame] | 734 | |
Alexander Block | 31db9f7 | 2012-07-25 23:19:24 +0200 | [diff] [blame] | 735 | struct btrfs_ioctl_send_args { |
| 736 | __s64 send_fd; /* in */ |
| 737 | __u64 clone_sources_count; /* in */ |
| 738 | __u64 __user *clone_sources; /* in */ |
| 739 | __u64 parent_root; /* in */ |
| 740 | __u64 flags; /* in */ |
| 741 | __u64 reserved[4]; /* in */ |
| 742 | }; |
Arne Jansen | 5d13a37 | 2011-09-14 15:53:51 +0200 | [diff] [blame] | 743 | |
Tomohiro Misono | b64ec07 | 2018-05-21 10:09:42 +0900 | [diff] [blame] | 744 | /* |
| 745 | * Information about a fs tree root. |
| 746 | * |
| 747 | * All items are filled by the ioctl |
| 748 | */ |
| 749 | struct btrfs_ioctl_get_subvol_info_args { |
| 750 | /* Id of this subvolume */ |
| 751 | __u64 treeid; |
| 752 | |
| 753 | /* Name of this subvolume, used to get the real name at mount point */ |
| 754 | char name[BTRFS_VOL_NAME_MAX + 1]; |
| 755 | |
| 756 | /* |
| 757 | * Id of the subvolume which contains this subvolume. |
| 758 | * Zero for top-level subvolume or a deleted subvolume. |
| 759 | */ |
| 760 | __u64 parent_id; |
| 761 | |
| 762 | /* |
| 763 | * Inode number of the directory which contains this subvolume. |
| 764 | * Zero for top-level subvolume or a deleted subvolume |
| 765 | */ |
| 766 | __u64 dirid; |
| 767 | |
| 768 | /* Latest transaction id of this subvolume */ |
| 769 | __u64 generation; |
| 770 | |
| 771 | /* Flags of this subvolume */ |
| 772 | __u64 flags; |
| 773 | |
| 774 | /* UUID of this subvolume */ |
| 775 | __u8 uuid[BTRFS_UUID_SIZE]; |
| 776 | |
| 777 | /* |
| 778 | * UUID of the subvolume of which this subvolume is a snapshot. |
| 779 | * All zero for a non-snapshot subvolume. |
| 780 | */ |
| 781 | __u8 parent_uuid[BTRFS_UUID_SIZE]; |
| 782 | |
| 783 | /* |
| 784 | * UUID of the subvolume from which this subvolume was received. |
| 785 | * All zero for non-received subvolume. |
| 786 | */ |
| 787 | __u8 received_uuid[BTRFS_UUID_SIZE]; |
| 788 | |
| 789 | /* Transaction id indicating when change/create/send/receive happened */ |
| 790 | __u64 ctransid; |
| 791 | __u64 otransid; |
| 792 | __u64 stransid; |
| 793 | __u64 rtransid; |
| 794 | /* Time corresponding to c/o/s/rtransid */ |
| 795 | struct btrfs_ioctl_timespec ctime; |
| 796 | struct btrfs_ioctl_timespec otime; |
| 797 | struct btrfs_ioctl_timespec stime; |
| 798 | struct btrfs_ioctl_timespec rtime; |
| 799 | |
| 800 | /* Must be zero */ |
| 801 | __u64 reserved[8]; |
| 802 | }; |
| 803 | |
Tomohiro Misono | 42e4b52 | 2018-05-21 10:09:43 +0900 | [diff] [blame] | 804 | #define BTRFS_MAX_ROOTREF_BUFFER_NUM 255 |
| 805 | struct btrfs_ioctl_get_subvol_rootref_args { |
| 806 | /* in/out, minimum id of rootref's treeid to be searched */ |
| 807 | __u64 min_treeid; |
| 808 | |
| 809 | /* out */ |
| 810 | struct { |
| 811 | __u64 treeid; |
| 812 | __u64 dirid; |
| 813 | } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM]; |
| 814 | |
| 815 | /* out, number of found items */ |
| 816 | __u8 num_items; |
| 817 | __u8 align[7]; |
| 818 | }; |
| 819 | |
Anand Jain | 183860f | 2013-05-17 10:52:45 +0000 | [diff] [blame] | 820 | /* Error codes as returned by the kernel */ |
| 821 | enum btrfs_err_code { |
Satoru Takeuchi | eb710b1 | 2014-12-24 14:52:04 +0900 | [diff] [blame] | 822 | BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1, |
Anand Jain | 183860f | 2013-05-17 10:52:45 +0000 | [diff] [blame] | 823 | BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET, |
| 824 | BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET, |
| 825 | BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET, |
| 826 | BTRFS_ERROR_DEV_TGT_REPLACE, |
| 827 | BTRFS_ERROR_DEV_MISSING_NOT_FOUND, |
| 828 | BTRFS_ERROR_DEV_ONLY_WRITABLE, |
| 829 | BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS |
| 830 | }; |
Anand Jain | 183860f | 2013-05-17 10:52:45 +0000 | [diff] [blame] | 831 | |
Chris Mason | c5739bb | 2007-04-10 09:27:04 -0400 | [diff] [blame] | 832 | #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \ |
| 833 | struct btrfs_ioctl_vol_args) |
Chris Mason | 6702ed4 | 2007-08-07 16:15:09 -0400 | [diff] [blame] | 834 | #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \ |
Chris Mason | 8352d8a | 2007-04-12 10:43:05 -0400 | [diff] [blame] | 835 | struct btrfs_ioctl_vol_args) |
Chris Mason | edbd8d4 | 2007-12-21 16:27:24 -0500 | [diff] [blame] | 836 | #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \ |
| 837 | struct btrfs_ioctl_vol_args) |
Chris Mason | 8a4b83c | 2008-03-24 15:02:07 -0400 | [diff] [blame] | 838 | #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \ |
| 839 | struct btrfs_ioctl_vol_args) |
Anand Jain | 228a73a | 2019-01-04 13:31:54 +0800 | [diff] [blame] | 840 | #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \ |
| 841 | struct btrfs_ioctl_vol_args) |
Sage Weil | 6bf13c0 | 2008-06-10 10:07:39 -0400 | [diff] [blame] | 842 | /* trans start and trans end are dangerous, and only for |
| 843 | * use by applications that know how to avoid the |
| 844 | * resulting deadlocks |
| 845 | */ |
| 846 | #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6) |
| 847 | #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7) |
| 848 | #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8) |
| 849 | |
Sage Weil | f2eb0a2 | 2008-05-02 14:43:14 -0400 | [diff] [blame] | 850 | #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int) |
Chris Mason | 788f20e | 2008-04-28 15:29:42 -0400 | [diff] [blame] | 851 | #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \ |
| 852 | struct btrfs_ioctl_vol_args) |
| 853 | #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \ |
| 854 | struct btrfs_ioctl_vol_args) |
| 855 | #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \ |
| 856 | struct btrfs_ioctl_vol_args) |
Sage Weil | c5c9cd4 | 2008-11-12 14:32:25 -0500 | [diff] [blame] | 857 | |
| 858 | #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \ |
| 859 | struct btrfs_ioctl_clone_range_args) |
| 860 | |
Chris Mason | 3de4586 | 2008-11-17 21:02:50 -0500 | [diff] [blame] | 861 | #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \ |
| 862 | struct btrfs_ioctl_vol_args) |
Yan, Zheng | 76dda93 | 2009-09-21 16:00:26 -0400 | [diff] [blame] | 863 | #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \ |
| 864 | struct btrfs_ioctl_vol_args) |
Chris Mason | 1e701a3 | 2010-03-11 09:42:04 -0500 | [diff] [blame] | 865 | #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \ |
| 866 | struct btrfs_ioctl_defrag_range_args) |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 867 | #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \ |
| 868 | struct btrfs_ioctl_search_args) |
Gerhard Heift | cc68a8a | 2014-01-30 16:24:03 +0100 | [diff] [blame] | 869 | #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \ |
| 870 | struct btrfs_ioctl_search_args_v2) |
Chris Mason | ac8e981 | 2010-02-28 15:39:26 -0500 | [diff] [blame] | 871 | #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \ |
| 872 | struct btrfs_ioctl_ino_lookup_args) |
Mike Frysinger | 68b823e | 2013-08-16 14:02:33 -0400 | [diff] [blame] | 873 | #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64) |
Josef Bacik | 1406e43 | 2010-01-13 18:19:06 +0000 | [diff] [blame] | 874 | #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \ |
| 875 | struct btrfs_ioctl_space_args) |
Sage Weil | 4620459 | 2010-10-29 15:41:32 -0400 | [diff] [blame] | 876 | #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64) |
| 877 | #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64) |
Li Zefan | fdfb1e4 | 2010-12-10 06:41:56 +0000 | [diff] [blame] | 878 | #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \ |
| 879 | struct btrfs_ioctl_vol_args_v2) |
Arne Jansen | 6f72c7e | 2011-09-14 15:58:21 +0200 | [diff] [blame] | 880 | #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \ |
| 881 | struct btrfs_ioctl_vol_args_v2) |
Alexander Block | d3a9404 | 2012-06-25 15:36:12 -0600 | [diff] [blame] | 882 | #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64) |
Li Zefan | 0caa102 | 2010-12-20 16:30:25 +0800 | [diff] [blame] | 883 | #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64) |
Jan Schmidt | 475f638 | 2011-03-11 15:41:01 +0100 | [diff] [blame] | 884 | #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \ |
| 885 | struct btrfs_ioctl_scrub_args) |
| 886 | #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28) |
| 887 | #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \ |
| 888 | struct btrfs_ioctl_scrub_args) |
| 889 | #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \ |
| 890 | struct btrfs_ioctl_dev_info_args) |
| 891 | #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \ |
| 892 | struct btrfs_ioctl_fs_info_args) |
Ilya Dryomov | c9e9f97 | 2012-01-16 22:04:47 +0200 | [diff] [blame] | 893 | #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \ |
| 894 | struct btrfs_ioctl_balance_args) |
Ilya Dryomov | 837d5b6 | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 895 | #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int) |
Ilya Dryomov | 19a39dc | 2012-01-16 22:04:49 +0200 | [diff] [blame] | 896 | #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \ |
| 897 | struct btrfs_ioctl_balance_args) |
Jan Schmidt | d7728c9 | 2011-07-07 16:48:38 +0200 | [diff] [blame] | 898 | #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \ |
| 899 | struct btrfs_ioctl_ino_path_args) |
| 900 | #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \ |
Hans van Kranenburg | 7af7c61 | 2016-07-03 23:23:06 +0200 | [diff] [blame] | 901 | struct btrfs_ioctl_logical_ino_args) |
Alexander Block | 8ea05e3 | 2012-07-25 17:35:53 +0200 | [diff] [blame] | 902 | #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \ |
| 903 | struct btrfs_ioctl_received_subvol_args) |
Alexander Block | 31db9f7 | 2012-07-25 23:19:24 +0200 | [diff] [blame] | 904 | #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args) |
Josef Bacik | 02db084 | 2012-06-21 16:03:58 -0400 | [diff] [blame] | 905 | #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \ |
| 906 | struct btrfs_ioctl_vol_args) |
Arne Jansen | 5d13a37 | 2011-09-14 15:53:51 +0200 | [diff] [blame] | 907 | #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \ |
| 908 | struct btrfs_ioctl_quota_ctl_args) |
| 909 | #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \ |
| 910 | struct btrfs_ioctl_qgroup_assign_args) |
| 911 | #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \ |
| 912 | struct btrfs_ioctl_qgroup_create_args) |
| 913 | #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \ |
| 914 | struct btrfs_ioctl_qgroup_limit_args) |
Jan Schmidt | 2f23203 | 2013-04-25 16:04:51 +0000 | [diff] [blame] | 915 | #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \ |
| 916 | struct btrfs_ioctl_quota_rescan_args) |
| 917 | #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \ |
| 918 | struct btrfs_ioctl_quota_rescan_args) |
Jan Schmidt | 57254b6e | 2013-05-06 19:14:17 +0000 | [diff] [blame] | 919 | #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46) |
jeff.liu | 867ab66 | 2013-01-05 02:48:01 +0000 | [diff] [blame] | 920 | #define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, \ |
| 921 | char[BTRFS_LABEL_SIZE]) |
jeff.liu | a8bfd4a | 2013-01-05 02:48:08 +0000 | [diff] [blame] | 922 | #define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, \ |
| 923 | char[BTRFS_LABEL_SIZE]) |
Stefan Behrens | c11d2c2 | 2012-05-25 16:06:09 +0200 | [diff] [blame] | 924 | #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \ |
| 925 | struct btrfs_ioctl_get_dev_stats) |
Stefan Behrens | e93c89c | 2012-11-05 17:33:06 +0100 | [diff] [blame] | 926 | #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \ |
| 927 | struct btrfs_ioctl_dev_replace_args) |
Mark Fasheh | 416161d | 2013-08-06 11:42:51 -0700 | [diff] [blame] | 928 | #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \ |
| 929 | struct btrfs_ioctl_same_args) |
Jeff Mahoney | 2eaa055 | 2013-11-15 15:33:55 -0500 | [diff] [blame] | 930 | #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ |
| 931 | struct btrfs_ioctl_feature_flags) |
| 932 | #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \ |
| 933 | struct btrfs_ioctl_feature_flags[2]) |
| 934 | #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \ |
| 935 | struct btrfs_ioctl_feature_flags[3]) |
Anand Jain | 6b526ed | 2016-02-13 10:01:39 +0800 | [diff] [blame] | 936 | #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \ |
| 937 | struct btrfs_ioctl_vol_args_v2) |
Zygo Blaxell | d24a67b | 2017-09-22 13:58:46 -0400 | [diff] [blame] | 938 | #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \ |
| 939 | struct btrfs_ioctl_logical_ino_args) |
Tomohiro Misono | b64ec07 | 2018-05-21 10:09:42 +0900 | [diff] [blame] | 940 | #define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \ |
| 941 | struct btrfs_ioctl_get_subvol_info_args) |
Tomohiro Misono | 42e4b52 | 2018-05-21 10:09:43 +0900 | [diff] [blame] | 942 | #define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \ |
| 943 | struct btrfs_ioctl_get_subvol_rootref_args) |
Tomohiro Misono | 23d0b79 | 2018-05-21 10:09:44 +0900 | [diff] [blame] | 944 | #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \ |
| 945 | struct btrfs_ioctl_ino_lookup_user_args) |
Mark Fasheh | 416161d | 2013-08-06 11:42:51 -0700 | [diff] [blame] | 946 | |
Filipe Brandenburger | 55e301f | 2013-01-29 06:04:50 +0000 | [diff] [blame] | 947 | #endif /* _UAPI_LINUX_BTRFS_H */ |