btrfs.h 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  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. #ifndef _UAPI_LINUX_BTRFS_H
  20. #define _UAPI_LINUX_BTRFS_H
  21. #include <linux/types.h>
  22. #include <linux/ioctl.h>
  23. #define BTRFS_IOCTL_MAGIC 0x94
  24. #define BTRFS_VOL_NAME_MAX 255
  25. #define BTRFS_LABEL_SIZE 256
  26. /* this should be 4k */
  27. #define BTRFS_PATH_NAME_MAX 4087
  28. struct btrfs_ioctl_vol_args {
  29. __s64 fd;
  30. char name[BTRFS_PATH_NAME_MAX + 1];
  31. };
  32. #define BTRFS_DEVICE_PATH_NAME_MAX 1024
  33. #define BTRFS_SUBVOL_NAME_MAX 4039
  34. #ifndef __KERNEL__
  35. /* Deprecated since 5.7 */
  36. # define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
  37. #endif
  38. #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
  39. #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
  40. #define BTRFS_DEVICE_SPEC_BY_ID (1ULL << 3)
  41. #define BTRFS_SUBVOL_SPEC_BY_ID (1ULL << 4)
  42. #define BTRFS_VOL_ARG_V2_FLAGS_SUPPORTED \
  43. (BTRFS_SUBVOL_RDONLY | \
  44. BTRFS_SUBVOL_QGROUP_INHERIT | \
  45. BTRFS_DEVICE_SPEC_BY_ID | \
  46. BTRFS_SUBVOL_SPEC_BY_ID)
  47. #define BTRFS_FSID_SIZE 16
  48. #define BTRFS_UUID_SIZE 16
  49. #define BTRFS_UUID_UNPARSED_SIZE 37
  50. /*
  51. * flags definition for qgroup limits
  52. *
  53. * Used by:
  54. * struct btrfs_qgroup_limit.flags
  55. * struct btrfs_qgroup_limit_item.flags
  56. */
  57. #define BTRFS_QGROUP_LIMIT_MAX_RFER (1ULL << 0)
  58. #define BTRFS_QGROUP_LIMIT_MAX_EXCL (1ULL << 1)
  59. #define BTRFS_QGROUP_LIMIT_RSV_RFER (1ULL << 2)
  60. #define BTRFS_QGROUP_LIMIT_RSV_EXCL (1ULL << 3)
  61. #define BTRFS_QGROUP_LIMIT_RFER_CMPR (1ULL << 4)
  62. #define BTRFS_QGROUP_LIMIT_EXCL_CMPR (1ULL << 5)
  63. struct btrfs_qgroup_limit {
  64. __u64 flags;
  65. __u64 max_rfer;
  66. __u64 max_excl;
  67. __u64 rsv_rfer;
  68. __u64 rsv_excl;
  69. };
  70. /*
  71. * flags definition for qgroup inheritance
  72. *
  73. * Used by:
  74. * struct btrfs_qgroup_inherit.flags
  75. */
  76. #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
  77. struct btrfs_qgroup_inherit {
  78. __u64 flags;
  79. __u64 num_qgroups;
  80. __u64 num_ref_copies;
  81. __u64 num_excl_copies;
  82. struct btrfs_qgroup_limit lim;
  83. __u64 qgroups[];
  84. };
  85. struct btrfs_ioctl_qgroup_limit_args {
  86. __u64 qgroupid;
  87. struct btrfs_qgroup_limit lim;
  88. };
  89. /*
  90. * Arguments for specification of subvolumes or devices, supporting by-name or
  91. * by-id and flags
  92. *
  93. * The set of supported flags depends on the ioctl
  94. *
  95. * BTRFS_SUBVOL_RDONLY is also provided/consumed by the following ioctls:
  96. * - BTRFS_IOC_SUBVOL_GETFLAGS
  97. * - BTRFS_IOC_SUBVOL_SETFLAGS
  98. */
  99. /* Supported flags for BTRFS_IOC_RM_DEV_V2 */
  100. #define BTRFS_DEVICE_REMOVE_ARGS_MASK \
  101. (BTRFS_DEVICE_SPEC_BY_ID)
  102. /* Supported flags for BTRFS_IOC_SNAP_CREATE_V2 and BTRFS_IOC_SUBVOL_CREATE_V2 */
  103. #define BTRFS_SUBVOL_CREATE_ARGS_MASK \
  104. (BTRFS_SUBVOL_RDONLY | \
  105. BTRFS_SUBVOL_QGROUP_INHERIT)
  106. /* Supported flags for BTRFS_IOC_SNAP_DESTROY_V2 */
  107. #define BTRFS_SUBVOL_DELETE_ARGS_MASK \
  108. (BTRFS_SUBVOL_SPEC_BY_ID)
  109. struct btrfs_ioctl_vol_args_v2 {
  110. __s64 fd;
  111. __u64 transid;
  112. __u64 flags;
  113. union {
  114. struct {
  115. __u64 size;
  116. struct btrfs_qgroup_inherit __user *qgroup_inherit;
  117. };
  118. __u64 unused[4];
  119. };
  120. union {
  121. char name[BTRFS_SUBVOL_NAME_MAX + 1];
  122. __u64 devid;
  123. __u64 subvolid;
  124. };
  125. };
  126. /*
  127. * structure to report errors and progress to userspace, either as a
  128. * result of a finished scrub, a canceled scrub or a progress inquiry
  129. */
  130. struct btrfs_scrub_progress {
  131. __u64 data_extents_scrubbed; /* # of data extents scrubbed */
  132. __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */
  133. __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */
  134. __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
  135. __u64 read_errors; /* # of read errors encountered (EIO) */
  136. __u64 csum_errors; /* # of failed csum checks */
  137. __u64 verify_errors; /* # of occurrences, where the metadata
  138. * of a tree block did not match the
  139. * expected values, like generation or
  140. * logical */
  141. __u64 no_csum; /* # of 4k data block for which no csum
  142. * is present, probably the result of
  143. * data written with nodatasum */
  144. __u64 csum_discards; /* # of csum for which no data was found
  145. * in the extent tree. */
  146. __u64 super_errors; /* # of bad super blocks encountered */
  147. __u64 malloc_errors; /* # of internal kmalloc errors. These
  148. * will likely cause an incomplete
  149. * scrub */
  150. __u64 uncorrectable_errors; /* # of errors where either no intact
  151. * copy was found or the writeback
  152. * failed */
  153. __u64 corrected_errors; /* # of errors corrected */
  154. __u64 last_physical; /* last physical address scrubbed. In
  155. * case a scrub was aborted, this can
  156. * be used to restart the scrub */
  157. __u64 unverified_errors; /* # of occurrences where a read for a
  158. * full (64k) bio failed, but the re-
  159. * check succeeded for each 4k piece.
  160. * Intermittent error. */
  161. };
  162. #define BTRFS_SCRUB_READONLY 1
  163. #define BTRFS_SCRUB_SUPPORTED_FLAGS (BTRFS_SCRUB_READONLY)
  164. struct btrfs_ioctl_scrub_args {
  165. __u64 devid; /* in */
  166. __u64 start; /* in */
  167. __u64 end; /* in */
  168. __u64 flags; /* in */
  169. struct btrfs_scrub_progress progress; /* out */
  170. /* pad to 1k */
  171. __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
  172. };
  173. #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
  174. #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
  175. struct btrfs_ioctl_dev_replace_start_params {
  176. __u64 srcdevid; /* in, if 0, use srcdev_name instead */
  177. __u64 cont_reading_from_srcdev_mode; /* in, see #define
  178. * above */
  179. __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
  180. __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
  181. };
  182. #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
  183. #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
  184. #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2
  185. #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3
  186. #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4
  187. struct btrfs_ioctl_dev_replace_status_params {
  188. __u64 replace_state; /* out, see #define above */
  189. __u64 progress_1000; /* out, 0 <= x <= 1000 */
  190. __u64 time_started; /* out, seconds since 1-Jan-1970 */
  191. __u64 time_stopped; /* out, seconds since 1-Jan-1970 */
  192. __u64 num_write_errors; /* out */
  193. __u64 num_uncorrectable_read_errors; /* out */
  194. };
  195. #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
  196. #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
  197. #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2
  198. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0
  199. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1
  200. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2
  201. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3
  202. struct btrfs_ioctl_dev_replace_args {
  203. __u64 cmd; /* in */
  204. __u64 result; /* out */
  205. union {
  206. struct btrfs_ioctl_dev_replace_start_params start;
  207. struct btrfs_ioctl_dev_replace_status_params status;
  208. }; /* in/out */
  209. __u64 spare[64];
  210. };
  211. struct btrfs_ioctl_dev_info_args {
  212. __u64 devid; /* in/out */
  213. __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
  214. __u64 bytes_used; /* out */
  215. __u64 total_bytes; /* out */
  216. __u64 unused[379]; /* pad to 4k */
  217. __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
  218. };
  219. /*
  220. * Retrieve information about the filesystem
  221. */
  222. /* Request information about checksum type and size */
  223. #define BTRFS_FS_INFO_FLAG_CSUM_INFO (1 << 0)
  224. /* Request information about filesystem generation */
  225. #define BTRFS_FS_INFO_FLAG_GENERATION (1 << 1)
  226. /* Request information about filesystem metadata UUID */
  227. #define BTRFS_FS_INFO_FLAG_METADATA_UUID (1 << 2)
  228. struct btrfs_ioctl_fs_info_args {
  229. __u64 max_id; /* out */
  230. __u64 num_devices; /* out */
  231. __u8 fsid[BTRFS_FSID_SIZE]; /* out */
  232. __u32 nodesize; /* out */
  233. __u32 sectorsize; /* out */
  234. __u32 clone_alignment; /* out */
  235. /* See BTRFS_FS_INFO_FLAG_* */
  236. __u16 csum_type; /* out */
  237. __u16 csum_size; /* out */
  238. __u64 flags; /* in/out */
  239. __u64 generation; /* out */
  240. __u8 metadata_uuid[BTRFS_FSID_SIZE]; /* out */
  241. __u8 reserved[944]; /* pad to 1k */
  242. };
  243. /*
  244. * feature flags
  245. *
  246. * Used by:
  247. * struct btrfs_ioctl_feature_flags
  248. */
  249. #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE (1ULL << 0)
  250. /*
  251. * Older kernels (< 4.9) on big-endian systems produced broken free space tree
  252. * bitmaps, and btrfs-progs also used to corrupt the free space tree (versions
  253. * < 4.7.3). If this bit is clear, then the free space tree cannot be trusted.
  254. * btrfs-progs can also intentionally clear this bit to ask the kernel to
  255. * rebuild the free space tree, however this might not work on older kernels
  256. * that do not know about this bit. If not sure, clear the cache manually on
  257. * first mount when booting older kernel versions.
  258. */
  259. #define BTRFS_FEATURE_COMPAT_RO_FREE_SPACE_TREE_VALID (1ULL << 1)
  260. #define BTRFS_FEATURE_COMPAT_RO_VERITY (1ULL << 2)
  261. /*
  262. * Put all block group items into a dedicated block group tree, greatly
  263. * reducing mount time for large filesystem due to better locality.
  264. */
  265. #define BTRFS_FEATURE_COMPAT_RO_BLOCK_GROUP_TREE (1ULL << 3)
  266. #define BTRFS_FEATURE_INCOMPAT_MIXED_BACKREF (1ULL << 0)
  267. #define BTRFS_FEATURE_INCOMPAT_DEFAULT_SUBVOL (1ULL << 1)
  268. #define BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS (1ULL << 2)
  269. #define BTRFS_FEATURE_INCOMPAT_COMPRESS_LZO (1ULL << 3)
  270. #define BTRFS_FEATURE_INCOMPAT_COMPRESS_ZSTD (1ULL << 4)
  271. /*
  272. * older kernels tried to do bigger metadata blocks, but the
  273. * code was pretty buggy. Lets not let them try anymore.
  274. */
  275. #define BTRFS_FEATURE_INCOMPAT_BIG_METADATA (1ULL << 5)
  276. #define BTRFS_FEATURE_INCOMPAT_EXTENDED_IREF (1ULL << 6)
  277. #define BTRFS_FEATURE_INCOMPAT_RAID56 (1ULL << 7)
  278. #define BTRFS_FEATURE_INCOMPAT_SKINNY_METADATA (1ULL << 8)
  279. #define BTRFS_FEATURE_INCOMPAT_NO_HOLES (1ULL << 9)
  280. #define BTRFS_FEATURE_INCOMPAT_METADATA_UUID (1ULL << 10)
  281. #define BTRFS_FEATURE_INCOMPAT_RAID1C34 (1ULL << 11)
  282. #define BTRFS_FEATURE_INCOMPAT_ZONED (1ULL << 12)
  283. #define BTRFS_FEATURE_INCOMPAT_EXTENT_TREE_V2 (1ULL << 13)
  284. struct btrfs_ioctl_feature_flags {
  285. __u64 compat_flags;
  286. __u64 compat_ro_flags;
  287. __u64 incompat_flags;
  288. };
  289. /* balance control ioctl modes */
  290. #define BTRFS_BALANCE_CTL_PAUSE 1
  291. #define BTRFS_BALANCE_CTL_CANCEL 2
  292. /*
  293. * this is packed, because it should be exactly the same as its disk
  294. * byte order counterpart (struct btrfs_disk_balance_args)
  295. */
  296. struct btrfs_balance_args {
  297. __u64 profiles;
  298. union {
  299. __u64 usage;
  300. struct {
  301. __u32 usage_min;
  302. __u32 usage_max;
  303. };
  304. };
  305. __u64 devid;
  306. __u64 pstart;
  307. __u64 pend;
  308. __u64 vstart;
  309. __u64 vend;
  310. __u64 target;
  311. __u64 flags;
  312. /*
  313. * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
  314. * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
  315. * and maximum
  316. */
  317. union {
  318. __u64 limit; /* limit number of processed chunks */
  319. struct {
  320. __u32 limit_min;
  321. __u32 limit_max;
  322. };
  323. };
  324. /*
  325. * Process chunks that cross stripes_min..stripes_max devices,
  326. * BTRFS_BALANCE_ARGS_STRIPES_RANGE
  327. */
  328. __u32 stripes_min;
  329. __u32 stripes_max;
  330. __u64 unused[6];
  331. } __attribute__ ((__packed__));
  332. /* report balance progress to userspace */
  333. struct btrfs_balance_progress {
  334. __u64 expected; /* estimated # of chunks that will be
  335. * relocated to fulfill the request */
  336. __u64 considered; /* # of chunks we have considered so far */
  337. __u64 completed; /* # of chunks relocated so far */
  338. };
  339. /*
  340. * flags definition for balance
  341. *
  342. * Restriper's general type filter
  343. *
  344. * Used by:
  345. * btrfs_ioctl_balance_args.flags
  346. * btrfs_balance_control.flags (internal)
  347. */
  348. #define BTRFS_BALANCE_DATA (1ULL << 0)
  349. #define BTRFS_BALANCE_SYSTEM (1ULL << 1)
  350. #define BTRFS_BALANCE_METADATA (1ULL << 2)
  351. #define BTRFS_BALANCE_TYPE_MASK (BTRFS_BALANCE_DATA | \
  352. BTRFS_BALANCE_SYSTEM | \
  353. BTRFS_BALANCE_METADATA)
  354. #define BTRFS_BALANCE_FORCE (1ULL << 3)
  355. #define BTRFS_BALANCE_RESUME (1ULL << 4)
  356. /*
  357. * flags definitions for per-type balance args
  358. *
  359. * Balance filters
  360. *
  361. * Used by:
  362. * struct btrfs_balance_args
  363. */
  364. #define BTRFS_BALANCE_ARGS_PROFILES (1ULL << 0)
  365. #define BTRFS_BALANCE_ARGS_USAGE (1ULL << 1)
  366. #define BTRFS_BALANCE_ARGS_DEVID (1ULL << 2)
  367. #define BTRFS_BALANCE_ARGS_DRANGE (1ULL << 3)
  368. #define BTRFS_BALANCE_ARGS_VRANGE (1ULL << 4)
  369. #define BTRFS_BALANCE_ARGS_LIMIT (1ULL << 5)
  370. #define BTRFS_BALANCE_ARGS_LIMIT_RANGE (1ULL << 6)
  371. #define BTRFS_BALANCE_ARGS_STRIPES_RANGE (1ULL << 7)
  372. #define BTRFS_BALANCE_ARGS_USAGE_RANGE (1ULL << 10)
  373. #define BTRFS_BALANCE_ARGS_MASK \
  374. (BTRFS_BALANCE_ARGS_PROFILES | \
  375. BTRFS_BALANCE_ARGS_USAGE | \
  376. BTRFS_BALANCE_ARGS_DEVID | \
  377. BTRFS_BALANCE_ARGS_DRANGE | \
  378. BTRFS_BALANCE_ARGS_VRANGE | \
  379. BTRFS_BALANCE_ARGS_LIMIT | \
  380. BTRFS_BALANCE_ARGS_LIMIT_RANGE | \
  381. BTRFS_BALANCE_ARGS_STRIPES_RANGE | \
  382. BTRFS_BALANCE_ARGS_USAGE_RANGE)
  383. /*
  384. * Profile changing flags. When SOFT is set we won't relocate chunk if
  385. * it already has the target profile (even though it may be
  386. * half-filled).
  387. */
  388. #define BTRFS_BALANCE_ARGS_CONVERT (1ULL << 8)
  389. #define BTRFS_BALANCE_ARGS_SOFT (1ULL << 9)
  390. /*
  391. * flags definition for balance state
  392. *
  393. * Used by:
  394. * struct btrfs_ioctl_balance_args.state
  395. */
  396. #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
  397. #define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
  398. #define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
  399. struct btrfs_ioctl_balance_args {
  400. __u64 flags; /* in/out */
  401. __u64 state; /* out */
  402. struct btrfs_balance_args data; /* in/out */
  403. struct btrfs_balance_args meta; /* in/out */
  404. struct btrfs_balance_args sys; /* in/out */
  405. struct btrfs_balance_progress stat; /* out */
  406. __u64 unused[72]; /* pad to 1k */
  407. };
  408. #define BTRFS_INO_LOOKUP_PATH_MAX 4080
  409. struct btrfs_ioctl_ino_lookup_args {
  410. __u64 treeid;
  411. __u64 objectid;
  412. char name[BTRFS_INO_LOOKUP_PATH_MAX];
  413. };
  414. #define BTRFS_INO_LOOKUP_USER_PATH_MAX (4080 - BTRFS_VOL_NAME_MAX - 1)
  415. struct btrfs_ioctl_ino_lookup_user_args {
  416. /* in, inode number containing the subvolume of 'subvolid' */
  417. __u64 dirid;
  418. /* in */
  419. __u64 treeid;
  420. /* out, name of the subvolume of 'treeid' */
  421. char name[BTRFS_VOL_NAME_MAX + 1];
  422. /*
  423. * out, constructed path from the directory with which the ioctl is
  424. * called to dirid
  425. */
  426. char path[BTRFS_INO_LOOKUP_USER_PATH_MAX];
  427. };
  428. /* Search criteria for the btrfs SEARCH ioctl family. */
  429. struct btrfs_ioctl_search_key {
  430. /*
  431. * The tree we're searching in. 1 is the tree of tree roots, 2 is the
  432. * extent tree, etc...
  433. *
  434. * A special tree_id value of 0 will cause a search in the subvolume
  435. * tree that the inode which is passed to the ioctl is part of.
  436. */
  437. __u64 tree_id; /* in */
  438. /*
  439. * When doing a tree search, we're actually taking a slice from a
  440. * linear search space of 136-bit keys.
  441. *
  442. * A full 136-bit tree key is composed as:
  443. * (objectid << 72) + (type << 64) + offset
  444. *
  445. * The individual min and max values for objectid, type and offset
  446. * define the min_key and max_key values for the search range. All
  447. * metadata items with a key in the interval [min_key, max_key] will be
  448. * returned.
  449. *
  450. * Additionally, we can filter the items returned on transaction id of
  451. * the metadata block they're stored in by specifying a transid range.
  452. * Be aware that this transaction id only denotes when the metadata
  453. * page that currently contains the item got written the last time as
  454. * result of a COW operation. The number does not have any meaning
  455. * related to the transaction in which an individual item that is being
  456. * returned was created or changed.
  457. */
  458. __u64 min_objectid; /* in */
  459. __u64 max_objectid; /* in */
  460. __u64 min_offset; /* in */
  461. __u64 max_offset; /* in */
  462. __u64 min_transid; /* in */
  463. __u64 max_transid; /* in */
  464. __u32 min_type; /* in */
  465. __u32 max_type; /* in */
  466. /*
  467. * input: The maximum amount of results desired.
  468. * output: The actual amount of items returned, restricted by any of:
  469. * - reaching the upper bound of the search range
  470. * - reaching the input nr_items amount of items
  471. * - completely filling the supplied memory buffer
  472. */
  473. __u32 nr_items; /* in/out */
  474. /* align to 64 bits */
  475. __u32 unused;
  476. /* some extra for later */
  477. __u64 unused1;
  478. __u64 unused2;
  479. __u64 unused3;
  480. __u64 unused4;
  481. };
  482. struct btrfs_ioctl_search_header {
  483. __u64 transid;
  484. __u64 objectid;
  485. __u64 offset;
  486. __u32 type;
  487. __u32 len;
  488. };
  489. #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
  490. /*
  491. * the buf is an array of search headers where
  492. * each header is followed by the actual item
  493. * the type field is expanded to 32 bits for alignment
  494. */
  495. struct btrfs_ioctl_search_args {
  496. struct btrfs_ioctl_search_key key;
  497. char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
  498. };
  499. struct btrfs_ioctl_search_args_v2 {
  500. struct btrfs_ioctl_search_key key; /* in/out - search parameters */
  501. __u64 buf_size; /* in - size of buffer
  502. * out - on EOVERFLOW: needed size
  503. * to store item */
  504. __u64 buf[]; /* out - found items */
  505. };
  506. struct btrfs_ioctl_clone_range_args {
  507. __s64 src_fd;
  508. __u64 src_offset, src_length;
  509. __u64 dest_offset;
  510. };
  511. /*
  512. * flags definition for the defrag range ioctl
  513. *
  514. * Used by:
  515. * struct btrfs_ioctl_defrag_range_args.flags
  516. */
  517. #define BTRFS_DEFRAG_RANGE_COMPRESS 1
  518. #define BTRFS_DEFRAG_RANGE_START_IO 2
  519. struct btrfs_ioctl_defrag_range_args {
  520. /* start of the defrag operation */
  521. __u64 start;
  522. /* number of bytes to defrag, use (u64)-1 to say all */
  523. __u64 len;
  524. /*
  525. * flags for the operation, which can include turning
  526. * on compression for this one defrag
  527. */
  528. __u64 flags;
  529. /*
  530. * any extent bigger than this will be considered
  531. * already defragged. Use 0 to take the kernel default
  532. * Use 1 to say every single extent must be rewritten
  533. */
  534. __u32 extent_thresh;
  535. /*
  536. * which compression method to use if turning on compression
  537. * for this defrag operation. If unspecified, zlib will
  538. * be used
  539. */
  540. __u32 compress_type;
  541. /* spare for later */
  542. __u32 unused[4];
  543. };
  544. #define BTRFS_SAME_DATA_DIFFERS 1
  545. /* For extent-same ioctl */
  546. struct btrfs_ioctl_same_extent_info {
  547. __s64 fd; /* in - destination file */
  548. __u64 logical_offset; /* in - start of extent in destination */
  549. __u64 bytes_deduped; /* out - total # of bytes we were able
  550. * to dedupe from this file */
  551. /* status of this dedupe operation:
  552. * 0 if dedup succeeds
  553. * < 0 for error
  554. * == BTRFS_SAME_DATA_DIFFERS if data differs
  555. */
  556. __s32 status; /* out - see above description */
  557. __u32 reserved;
  558. };
  559. struct btrfs_ioctl_same_args {
  560. __u64 logical_offset; /* in - start of extent in source */
  561. __u64 length; /* in - length of extent */
  562. __u16 dest_count; /* in - total elements in info array */
  563. __u16 reserved1;
  564. __u32 reserved2;
  565. struct btrfs_ioctl_same_extent_info info[];
  566. };
  567. struct btrfs_ioctl_space_info {
  568. __u64 flags;
  569. __u64 total_bytes;
  570. __u64 used_bytes;
  571. };
  572. struct btrfs_ioctl_space_args {
  573. __u64 space_slots;
  574. __u64 total_spaces;
  575. struct btrfs_ioctl_space_info spaces[];
  576. };
  577. struct btrfs_data_container {
  578. __u32 bytes_left; /* out -- bytes not needed to deliver output */
  579. __u32 bytes_missing; /* out -- additional bytes needed for result */
  580. __u32 elem_cnt; /* out */
  581. __u32 elem_missed; /* out */
  582. __u64 val[]; /* out */
  583. };
  584. struct btrfs_ioctl_ino_path_args {
  585. __u64 inum; /* in */
  586. __u64 size; /* in */
  587. __u64 reserved[4];
  588. /* struct btrfs_data_container *fspath; out */
  589. __u64 fspath; /* out */
  590. };
  591. struct btrfs_ioctl_logical_ino_args {
  592. __u64 logical; /* in */
  593. __u64 size; /* in */
  594. __u64 reserved[3]; /* must be 0 for now */
  595. __u64 flags; /* in, v2 only */
  596. /* struct btrfs_data_container *inodes; out */
  597. __u64 inodes;
  598. };
  599. /* Return every ref to the extent, not just those containing logical block.
  600. * Requires logical == extent bytenr. */
  601. #define BTRFS_LOGICAL_INO_ARGS_IGNORE_OFFSET (1ULL << 0)
  602. enum btrfs_dev_stat_values {
  603. /* disk I/O failure stats */
  604. BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
  605. BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
  606. BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
  607. /* stats for indirect indications for I/O failures */
  608. BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
  609. * contents is illegal: this is an
  610. * indication that the block was damaged
  611. * during read or write, or written to
  612. * wrong location or read from wrong
  613. * location */
  614. BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
  615. * been written */
  616. BTRFS_DEV_STAT_VALUES_MAX
  617. };
  618. /* Reset statistics after reading; needs SYS_ADMIN capability */
  619. #define BTRFS_DEV_STATS_RESET (1ULL << 0)
  620. struct btrfs_ioctl_get_dev_stats {
  621. __u64 devid; /* in */
  622. __u64 nr_items; /* in/out */
  623. __u64 flags; /* in/out */
  624. /* out values: */
  625. __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
  626. /*
  627. * This pads the struct to 1032 bytes. It was originally meant to pad to
  628. * 1024 bytes, but when adding the flags field, the padding calculation
  629. * was not adjusted.
  630. */
  631. __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX];
  632. };
  633. #define BTRFS_QUOTA_CTL_ENABLE 1
  634. #define BTRFS_QUOTA_CTL_DISABLE 2
  635. #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
  636. struct btrfs_ioctl_quota_ctl_args {
  637. __u64 cmd;
  638. __u64 status;
  639. };
  640. struct btrfs_ioctl_quota_rescan_args {
  641. __u64 flags;
  642. __u64 progress;
  643. __u64 reserved[6];
  644. };
  645. struct btrfs_ioctl_qgroup_assign_args {
  646. __u64 assign;
  647. __u64 src;
  648. __u64 dst;
  649. };
  650. struct btrfs_ioctl_qgroup_create_args {
  651. __u64 create;
  652. __u64 qgroupid;
  653. };
  654. struct btrfs_ioctl_timespec {
  655. __u64 sec;
  656. __u32 nsec;
  657. };
  658. struct btrfs_ioctl_received_subvol_args {
  659. char uuid[BTRFS_UUID_SIZE]; /* in */
  660. __u64 stransid; /* in */
  661. __u64 rtransid; /* out */
  662. struct btrfs_ioctl_timespec stime; /* in */
  663. struct btrfs_ioctl_timespec rtime; /* out */
  664. __u64 flags; /* in */
  665. __u64 reserved[16]; /* in */
  666. };
  667. /*
  668. * Caller doesn't want file data in the send stream, even if the
  669. * search of clone sources doesn't find an extent. UPDATE_EXTENT
  670. * commands will be sent instead of WRITE commands.
  671. */
  672. #define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
  673. /*
  674. * Do not add the leading stream header. Used when multiple snapshots
  675. * are sent back to back.
  676. */
  677. #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
  678. /*
  679. * Omit the command at the end of the stream that indicated the end
  680. * of the stream. This option is used when multiple snapshots are
  681. * sent back to back.
  682. */
  683. #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
  684. /*
  685. * Read the protocol version in the structure
  686. */
  687. #define BTRFS_SEND_FLAG_VERSION 0x8
  688. /*
  689. * Send compressed data using the ENCODED_WRITE command instead of decompressing
  690. * the data and sending it with the WRITE command. This requires protocol
  691. * version >= 2.
  692. */
  693. #define BTRFS_SEND_FLAG_COMPRESSED 0x10
  694. #define BTRFS_SEND_FLAG_MASK \
  695. (BTRFS_SEND_FLAG_NO_FILE_DATA | \
  696. BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
  697. BTRFS_SEND_FLAG_OMIT_END_CMD | \
  698. BTRFS_SEND_FLAG_VERSION | \
  699. BTRFS_SEND_FLAG_COMPRESSED)
  700. struct btrfs_ioctl_send_args {
  701. __s64 send_fd; /* in */
  702. __u64 clone_sources_count; /* in */
  703. __u64 __user *clone_sources; /* in */
  704. __u64 parent_root; /* in */
  705. __u64 flags; /* in */
  706. __u32 version; /* in */
  707. __u8 reserved[28]; /* in */
  708. };
  709. /*
  710. * Information about a fs tree root.
  711. *
  712. * All items are filled by the ioctl
  713. */
  714. struct btrfs_ioctl_get_subvol_info_args {
  715. /* Id of this subvolume */
  716. __u64 treeid;
  717. /* Name of this subvolume, used to get the real name at mount point */
  718. char name[BTRFS_VOL_NAME_MAX + 1];
  719. /*
  720. * Id of the subvolume which contains this subvolume.
  721. * Zero for top-level subvolume or a deleted subvolume.
  722. */
  723. __u64 parent_id;
  724. /*
  725. * Inode number of the directory which contains this subvolume.
  726. * Zero for top-level subvolume or a deleted subvolume
  727. */
  728. __u64 dirid;
  729. /* Latest transaction id of this subvolume */
  730. __u64 generation;
  731. /* Flags of this subvolume */
  732. __u64 flags;
  733. /* UUID of this subvolume */
  734. __u8 uuid[BTRFS_UUID_SIZE];
  735. /*
  736. * UUID of the subvolume of which this subvolume is a snapshot.
  737. * All zero for a non-snapshot subvolume.
  738. */
  739. __u8 parent_uuid[BTRFS_UUID_SIZE];
  740. /*
  741. * UUID of the subvolume from which this subvolume was received.
  742. * All zero for non-received subvolume.
  743. */
  744. __u8 received_uuid[BTRFS_UUID_SIZE];
  745. /* Transaction id indicating when change/create/send/receive happened */
  746. __u64 ctransid;
  747. __u64 otransid;
  748. __u64 stransid;
  749. __u64 rtransid;
  750. /* Time corresponding to c/o/s/rtransid */
  751. struct btrfs_ioctl_timespec ctime;
  752. struct btrfs_ioctl_timespec otime;
  753. struct btrfs_ioctl_timespec stime;
  754. struct btrfs_ioctl_timespec rtime;
  755. /* Must be zero */
  756. __u64 reserved[8];
  757. };
  758. #define BTRFS_MAX_ROOTREF_BUFFER_NUM 255
  759. struct btrfs_ioctl_get_subvol_rootref_args {
  760. /* in/out, minimum id of rootref's treeid to be searched */
  761. __u64 min_treeid;
  762. /* out */
  763. struct {
  764. __u64 treeid;
  765. __u64 dirid;
  766. } rootref[BTRFS_MAX_ROOTREF_BUFFER_NUM];
  767. /* out, number of found items */
  768. __u8 num_items;
  769. __u8 align[7];
  770. };
  771. /*
  772. * Data and metadata for an encoded read or write.
  773. *
  774. * Encoded I/O bypasses any encoding automatically done by the filesystem (e.g.,
  775. * compression). This can be used to read the compressed contents of a file or
  776. * write pre-compressed data directly to a file.
  777. *
  778. * BTRFS_IOC_ENCODED_READ and BTRFS_IOC_ENCODED_WRITE are essentially
  779. * preadv/pwritev with additional metadata about how the data is encoded and the
  780. * size of the unencoded data.
  781. *
  782. * BTRFS_IOC_ENCODED_READ fills the given iovecs with the encoded data, fills
  783. * the metadata fields, and returns the size of the encoded data. It reads one
  784. * extent per call. It can also read data which is not encoded.
  785. *
  786. * BTRFS_IOC_ENCODED_WRITE uses the metadata fields, writes the encoded data
  787. * from the iovecs, and returns the size of the encoded data. Note that the
  788. * encoded data is not validated when it is written; if it is not valid (e.g.,
  789. * it cannot be decompressed), then a subsequent read may return an error.
  790. *
  791. * Since the filesystem page cache contains decoded data, encoded I/O bypasses
  792. * the page cache. Encoded I/O requires CAP_SYS_ADMIN.
  793. */
  794. struct btrfs_ioctl_encoded_io_args {
  795. /* Input parameters for both reads and writes. */
  796. /*
  797. * iovecs containing encoded data.
  798. *
  799. * For reads, if the size of the encoded data is larger than the sum of
  800. * iov[n].iov_len for 0 <= n < iovcnt, then the ioctl fails with
  801. * ENOBUFS.
  802. *
  803. * For writes, the size of the encoded data is the sum of iov[n].iov_len
  804. * for 0 <= n < iovcnt. This must be less than 128 KiB (this limit may
  805. * increase in the future). This must also be less than or equal to
  806. * unencoded_len.
  807. */
  808. const struct iovec __user *iov;
  809. /* Number of iovecs. */
  810. unsigned long iovcnt;
  811. /*
  812. * Offset in file.
  813. *
  814. * For writes, must be aligned to the sector size of the filesystem.
  815. */
  816. __s64 offset;
  817. /* Currently must be zero. */
  818. __u64 flags;
  819. /*
  820. * For reads, the following members are output parameters that will
  821. * contain the returned metadata for the encoded data.
  822. * For writes, the following members must be set to the metadata for the
  823. * encoded data.
  824. */
  825. /*
  826. * Length of the data in the file.
  827. *
  828. * Must be less than or equal to unencoded_len - unencoded_offset. For
  829. * writes, must be aligned to the sector size of the filesystem unless
  830. * the data ends at or beyond the current end of the file.
  831. */
  832. __u64 len;
  833. /*
  834. * Length of the unencoded (i.e., decrypted and decompressed) data.
  835. *
  836. * For writes, must be no more than 128 KiB (this limit may increase in
  837. * the future). If the unencoded data is actually longer than
  838. * unencoded_len, then it is truncated; if it is shorter, then it is
  839. * extended with zeroes.
  840. */
  841. __u64 unencoded_len;
  842. /*
  843. * Offset from the first byte of the unencoded data to the first byte of
  844. * logical data in the file.
  845. *
  846. * Must be less than unencoded_len.
  847. */
  848. __u64 unencoded_offset;
  849. /*
  850. * BTRFS_ENCODED_IO_COMPRESSION_* type.
  851. *
  852. * For writes, must not be BTRFS_ENCODED_IO_COMPRESSION_NONE.
  853. */
  854. __u32 compression;
  855. /* Currently always BTRFS_ENCODED_IO_ENCRYPTION_NONE. */
  856. __u32 encryption;
  857. /*
  858. * Reserved for future expansion.
  859. *
  860. * For reads, always returned as zero. Users should check for non-zero
  861. * bytes. If there are any, then the kernel has a newer version of this
  862. * structure with additional information that the user definition is
  863. * missing.
  864. *
  865. * For writes, must be zeroed.
  866. */
  867. __u8 reserved[64];
  868. };
  869. /* Data is not compressed. */
  870. #define BTRFS_ENCODED_IO_COMPRESSION_NONE 0
  871. /* Data is compressed as a single zlib stream. */
  872. #define BTRFS_ENCODED_IO_COMPRESSION_ZLIB 1
  873. /*
  874. * Data is compressed as a single zstd frame with the windowLog compression
  875. * parameter set to no more than 17.
  876. */
  877. #define BTRFS_ENCODED_IO_COMPRESSION_ZSTD 2
  878. /*
  879. * Data is compressed sector by sector (using the sector size indicated by the
  880. * name of the constant) with LZO1X and wrapped in the format documented in
  881. * fs/btrfs/lzo.c. For writes, the compression sector size must match the
  882. * filesystem sector size.
  883. */
  884. #define BTRFS_ENCODED_IO_COMPRESSION_LZO_4K 3
  885. #define BTRFS_ENCODED_IO_COMPRESSION_LZO_8K 4
  886. #define BTRFS_ENCODED_IO_COMPRESSION_LZO_16K 5
  887. #define BTRFS_ENCODED_IO_COMPRESSION_LZO_32K 6
  888. #define BTRFS_ENCODED_IO_COMPRESSION_LZO_64K 7
  889. #define BTRFS_ENCODED_IO_COMPRESSION_TYPES 8
  890. /* Data is not encrypted. */
  891. #define BTRFS_ENCODED_IO_ENCRYPTION_NONE 0
  892. #define BTRFS_ENCODED_IO_ENCRYPTION_TYPES 1
  893. /* Error codes as returned by the kernel */
  894. enum btrfs_err_code {
  895. BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
  896. BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
  897. BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
  898. BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
  899. BTRFS_ERROR_DEV_TGT_REPLACE,
  900. BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
  901. BTRFS_ERROR_DEV_ONLY_WRITABLE,
  902. BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS,
  903. BTRFS_ERROR_DEV_RAID1C3_MIN_NOT_MET,
  904. BTRFS_ERROR_DEV_RAID1C4_MIN_NOT_MET,
  905. };
  906. #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
  907. struct btrfs_ioctl_vol_args)
  908. #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
  909. struct btrfs_ioctl_vol_args)
  910. #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
  911. struct btrfs_ioctl_vol_args)
  912. #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
  913. struct btrfs_ioctl_vol_args)
  914. #define BTRFS_IOC_FORGET_DEV _IOW(BTRFS_IOCTL_MAGIC, 5, \
  915. struct btrfs_ioctl_vol_args)
  916. /* trans start and trans end are dangerous, and only for
  917. * use by applications that know how to avoid the
  918. * resulting deadlocks
  919. */
  920. #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
  921. #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
  922. #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
  923. #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
  924. #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
  925. struct btrfs_ioctl_vol_args)
  926. #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
  927. struct btrfs_ioctl_vol_args)
  928. #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
  929. struct btrfs_ioctl_vol_args)
  930. #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
  931. struct btrfs_ioctl_clone_range_args)
  932. #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
  933. struct btrfs_ioctl_vol_args)
  934. #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
  935. struct btrfs_ioctl_vol_args)
  936. #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
  937. struct btrfs_ioctl_defrag_range_args)
  938. #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  939. struct btrfs_ioctl_search_args)
  940. #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  941. struct btrfs_ioctl_search_args_v2)
  942. #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
  943. struct btrfs_ioctl_ino_lookup_args)
  944. #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
  945. #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
  946. struct btrfs_ioctl_space_args)
  947. #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
  948. #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
  949. #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
  950. struct btrfs_ioctl_vol_args_v2)
  951. #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
  952. struct btrfs_ioctl_vol_args_v2)
  953. #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
  954. #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
  955. #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
  956. struct btrfs_ioctl_scrub_args)
  957. #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
  958. #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
  959. struct btrfs_ioctl_scrub_args)
  960. #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
  961. struct btrfs_ioctl_dev_info_args)
  962. #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
  963. struct btrfs_ioctl_fs_info_args)
  964. #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
  965. struct btrfs_ioctl_balance_args)
  966. #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
  967. #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
  968. struct btrfs_ioctl_balance_args)
  969. #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
  970. struct btrfs_ioctl_ino_path_args)
  971. #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
  972. struct btrfs_ioctl_logical_ino_args)
  973. #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
  974. struct btrfs_ioctl_received_subvol_args)
  975. #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
  976. #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
  977. struct btrfs_ioctl_vol_args)
  978. #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
  979. struct btrfs_ioctl_quota_ctl_args)
  980. #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
  981. struct btrfs_ioctl_qgroup_assign_args)
  982. #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
  983. struct btrfs_ioctl_qgroup_create_args)
  984. #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
  985. struct btrfs_ioctl_qgroup_limit_args)
  986. #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
  987. struct btrfs_ioctl_quota_rescan_args)
  988. #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
  989. struct btrfs_ioctl_quota_rescan_args)
  990. #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
  991. #define BTRFS_IOC_GET_FSLABEL FS_IOC_GETFSLABEL
  992. #define BTRFS_IOC_SET_FSLABEL FS_IOC_SETFSLABEL
  993. #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
  994. struct btrfs_ioctl_get_dev_stats)
  995. #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
  996. struct btrfs_ioctl_dev_replace_args)
  997. #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
  998. struct btrfs_ioctl_same_args)
  999. #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
  1000. struct btrfs_ioctl_feature_flags)
  1001. #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
  1002. struct btrfs_ioctl_feature_flags[2])
  1003. #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
  1004. struct btrfs_ioctl_feature_flags[3])
  1005. #define BTRFS_IOC_RM_DEV_V2 _IOW(BTRFS_IOCTL_MAGIC, 58, \
  1006. struct btrfs_ioctl_vol_args_v2)
  1007. #define BTRFS_IOC_LOGICAL_INO_V2 _IOWR(BTRFS_IOCTL_MAGIC, 59, \
  1008. struct btrfs_ioctl_logical_ino_args)
  1009. #define BTRFS_IOC_GET_SUBVOL_INFO _IOR(BTRFS_IOCTL_MAGIC, 60, \
  1010. struct btrfs_ioctl_get_subvol_info_args)
  1011. #define BTRFS_IOC_GET_SUBVOL_ROOTREF _IOWR(BTRFS_IOCTL_MAGIC, 61, \
  1012. struct btrfs_ioctl_get_subvol_rootref_args)
  1013. #define BTRFS_IOC_INO_LOOKUP_USER _IOWR(BTRFS_IOCTL_MAGIC, 62, \
  1014. struct btrfs_ioctl_ino_lookup_user_args)
  1015. #define BTRFS_IOC_SNAP_DESTROY_V2 _IOW(BTRFS_IOCTL_MAGIC, 63, \
  1016. struct btrfs_ioctl_vol_args_v2)
  1017. #define BTRFS_IOC_ENCODED_READ _IOR(BTRFS_IOCTL_MAGIC, 64, \
  1018. struct btrfs_ioctl_encoded_io_args)
  1019. #define BTRFS_IOC_ENCODED_WRITE _IOW(BTRFS_IOCTL_MAGIC, 64, \
  1020. struct btrfs_ioctl_encoded_io_args)
  1021. #endif /* _UAPI_LINUX_BTRFS_H */