btrfs.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  1. /*
  2. * Copyright (C) 2007 Oracle. All rights reserved.
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public
  6. * License v2 as published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. * General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public
  14. * License along with this program; if not, write to the
  15. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  16. * Boston, MA 021110-1307, USA.
  17. */
  18. #ifndef _UAPI_LINUX_BTRFS_H
  19. #define _UAPI_LINUX_BTRFS_H
  20. #include <linux/types.h>
  21. #include <linux/ioctl.h>
  22. #define BTRFS_IOCTL_MAGIC 0x94
  23. #define BTRFS_VOL_NAME_MAX 255
  24. /* this should be 4k */
  25. #define BTRFS_PATH_NAME_MAX 4087
  26. struct btrfs_ioctl_vol_args {
  27. __s64 fd;
  28. char name[BTRFS_PATH_NAME_MAX + 1];
  29. };
  30. #define BTRFS_DEVICE_PATH_NAME_MAX 1024
  31. #define BTRFS_SUBVOL_CREATE_ASYNC (1ULL << 0)
  32. #define BTRFS_SUBVOL_RDONLY (1ULL << 1)
  33. #define BTRFS_SUBVOL_QGROUP_INHERIT (1ULL << 2)
  34. #define BTRFS_FSID_SIZE 16
  35. #define BTRFS_UUID_SIZE 16
  36. #define BTRFS_UUID_UNPARSED_SIZE 37
  37. #define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
  38. struct btrfs_qgroup_limit {
  39. __u64 flags;
  40. __u64 max_rfer;
  41. __u64 max_excl;
  42. __u64 rsv_rfer;
  43. __u64 rsv_excl;
  44. };
  45. struct btrfs_qgroup_inherit {
  46. __u64 flags;
  47. __u64 num_qgroups;
  48. __u64 num_ref_copies;
  49. __u64 num_excl_copies;
  50. struct btrfs_qgroup_limit lim;
  51. __u64 qgroups[0];
  52. };
  53. struct btrfs_ioctl_qgroup_limit_args {
  54. __u64 qgroupid;
  55. struct btrfs_qgroup_limit lim;
  56. };
  57. #define BTRFS_SUBVOL_NAME_MAX 4039
  58. struct btrfs_ioctl_vol_args_v2 {
  59. __s64 fd;
  60. __u64 transid;
  61. __u64 flags;
  62. union {
  63. struct {
  64. __u64 size;
  65. struct btrfs_qgroup_inherit __user *qgroup_inherit;
  66. };
  67. __u64 unused[4];
  68. };
  69. char name[BTRFS_SUBVOL_NAME_MAX + 1];
  70. };
  71. /*
  72. * structure to report errors and progress to userspace, either as a
  73. * result of a finished scrub, a canceled scrub or a progress inquiry
  74. */
  75. struct btrfs_scrub_progress {
  76. __u64 data_extents_scrubbed; /* # of data extents scrubbed */
  77. __u64 tree_extents_scrubbed; /* # of tree extents scrubbed */
  78. __u64 data_bytes_scrubbed; /* # of data bytes scrubbed */
  79. __u64 tree_bytes_scrubbed; /* # of tree bytes scrubbed */
  80. __u64 read_errors; /* # of read errors encountered (EIO) */
  81. __u64 csum_errors; /* # of failed csum checks */
  82. __u64 verify_errors; /* # of occurences, where the metadata
  83. * of a tree block did not match the
  84. * expected values, like generation or
  85. * logical */
  86. __u64 no_csum; /* # of 4k data block for which no csum
  87. * is present, probably the result of
  88. * data written with nodatasum */
  89. __u64 csum_discards; /* # of csum for which no data was found
  90. * in the extent tree. */
  91. __u64 super_errors; /* # of bad super blocks encountered */
  92. __u64 malloc_errors; /* # of internal kmalloc errors. These
  93. * will likely cause an incomplete
  94. * scrub */
  95. __u64 uncorrectable_errors; /* # of errors where either no intact
  96. * copy was found or the writeback
  97. * failed */
  98. __u64 corrected_errors; /* # of errors corrected */
  99. __u64 last_physical; /* last physical address scrubbed. In
  100. * case a scrub was aborted, this can
  101. * be used to restart the scrub */
  102. __u64 unverified_errors; /* # of occurences where a read for a
  103. * full (64k) bio failed, but the re-
  104. * check succeeded for each 4k piece.
  105. * Intermittent error. */
  106. };
  107. #define BTRFS_SCRUB_READONLY 1
  108. struct btrfs_ioctl_scrub_args {
  109. __u64 devid; /* in */
  110. __u64 start; /* in */
  111. __u64 end; /* in */
  112. __u64 flags; /* in */
  113. struct btrfs_scrub_progress progress; /* out */
  114. /* pad to 1k */
  115. __u64 unused[(1024-32-sizeof(struct btrfs_scrub_progress))/8];
  116. };
  117. #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_ALWAYS 0
  118. #define BTRFS_IOCTL_DEV_REPLACE_CONT_READING_FROM_SRCDEV_MODE_AVOID 1
  119. struct btrfs_ioctl_dev_replace_start_params {
  120. __u64 srcdevid; /* in, if 0, use srcdev_name instead */
  121. __u64 cont_reading_from_srcdev_mode; /* in, see #define
  122. * above */
  123. __u8 srcdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
  124. __u8 tgtdev_name[BTRFS_DEVICE_PATH_NAME_MAX + 1]; /* in */
  125. };
  126. #define BTRFS_IOCTL_DEV_REPLACE_STATE_NEVER_STARTED 0
  127. #define BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED 1
  128. #define BTRFS_IOCTL_DEV_REPLACE_STATE_FINISHED 2
  129. #define BTRFS_IOCTL_DEV_REPLACE_STATE_CANCELED 3
  130. #define BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED 4
  131. struct btrfs_ioctl_dev_replace_status_params {
  132. __u64 replace_state; /* out, see #define above */
  133. __u64 progress_1000; /* out, 0 <= x <= 1000 */
  134. __u64 time_started; /* out, seconds since 1-Jan-1970 */
  135. __u64 time_stopped; /* out, seconds since 1-Jan-1970 */
  136. __u64 num_write_errors; /* out */
  137. __u64 num_uncorrectable_read_errors; /* out */
  138. };
  139. #define BTRFS_IOCTL_DEV_REPLACE_CMD_START 0
  140. #define BTRFS_IOCTL_DEV_REPLACE_CMD_STATUS 1
  141. #define BTRFS_IOCTL_DEV_REPLACE_CMD_CANCEL 2
  142. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NO_ERROR 0
  143. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_NOT_STARTED 1
  144. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_ALREADY_STARTED 2
  145. #define BTRFS_IOCTL_DEV_REPLACE_RESULT_SCRUB_INPROGRESS 3
  146. struct btrfs_ioctl_dev_replace_args {
  147. __u64 cmd; /* in */
  148. __u64 result; /* out */
  149. union {
  150. struct btrfs_ioctl_dev_replace_start_params start;
  151. struct btrfs_ioctl_dev_replace_status_params status;
  152. }; /* in/out */
  153. __u64 spare[64];
  154. };
  155. struct btrfs_ioctl_dev_info_args {
  156. __u64 devid; /* in/out */
  157. __u8 uuid[BTRFS_UUID_SIZE]; /* in/out */
  158. __u64 bytes_used; /* out */
  159. __u64 total_bytes; /* out */
  160. __u64 unused[379]; /* pad to 4k */
  161. __u8 path[BTRFS_DEVICE_PATH_NAME_MAX]; /* out */
  162. };
  163. struct btrfs_ioctl_fs_info_args {
  164. __u64 max_id; /* out */
  165. __u64 num_devices; /* out */
  166. __u8 fsid[BTRFS_FSID_SIZE]; /* out */
  167. __u32 nodesize; /* out */
  168. __u32 sectorsize; /* out */
  169. __u32 clone_alignment; /* out */
  170. __u32 reserved32;
  171. __u64 reserved[122]; /* pad to 1k */
  172. };
  173. struct btrfs_ioctl_feature_flags {
  174. __u64 compat_flags;
  175. __u64 compat_ro_flags;
  176. __u64 incompat_flags;
  177. };
  178. /* balance control ioctl modes */
  179. #define BTRFS_BALANCE_CTL_PAUSE 1
  180. #define BTRFS_BALANCE_CTL_CANCEL 2
  181. /*
  182. * this is packed, because it should be exactly the same as its disk
  183. * byte order counterpart (struct btrfs_disk_balance_args)
  184. */
  185. struct btrfs_balance_args {
  186. __u64 profiles;
  187. union {
  188. __le64 usage;
  189. struct {
  190. __le32 usage_min;
  191. __le32 usage_max;
  192. };
  193. };
  194. __u64 devid;
  195. __u64 pstart;
  196. __u64 pend;
  197. __u64 vstart;
  198. __u64 vend;
  199. __u64 target;
  200. __u64 flags;
  201. /*
  202. * BTRFS_BALANCE_ARGS_LIMIT with value 'limit'
  203. * BTRFS_BALANCE_ARGS_LIMIT_RANGE - the extend version can use minimum
  204. * and maximum
  205. */
  206. union {
  207. __u64 limit; /* limit number of processed chunks */
  208. struct {
  209. __u32 limit_min;
  210. __u32 limit_max;
  211. };
  212. };
  213. /*
  214. * Process chunks that cross stripes_min..stripes_max devices,
  215. * BTRFS_BALANCE_ARGS_STRIPES_RANGE
  216. */
  217. __le32 stripes_min;
  218. __le32 stripes_max;
  219. __u64 unused[6];
  220. } __attribute__ ((__packed__));
  221. /* report balance progress to userspace */
  222. struct btrfs_balance_progress {
  223. __u64 expected; /* estimated # of chunks that will be
  224. * relocated to fulfill the request */
  225. __u64 considered; /* # of chunks we have considered so far */
  226. __u64 completed; /* # of chunks relocated so far */
  227. };
  228. #define BTRFS_BALANCE_STATE_RUNNING (1ULL << 0)
  229. #define BTRFS_BALANCE_STATE_PAUSE_REQ (1ULL << 1)
  230. #define BTRFS_BALANCE_STATE_CANCEL_REQ (1ULL << 2)
  231. struct btrfs_ioctl_balance_args {
  232. __u64 flags; /* in/out */
  233. __u64 state; /* out */
  234. struct btrfs_balance_args data; /* in/out */
  235. struct btrfs_balance_args meta; /* in/out */
  236. struct btrfs_balance_args sys; /* in/out */
  237. struct btrfs_balance_progress stat; /* out */
  238. __u64 unused[72]; /* pad to 1k */
  239. };
  240. #define BTRFS_INO_LOOKUP_PATH_MAX 4080
  241. struct btrfs_ioctl_ino_lookup_args {
  242. __u64 treeid;
  243. __u64 objectid;
  244. char name[BTRFS_INO_LOOKUP_PATH_MAX];
  245. };
  246. struct btrfs_ioctl_search_key {
  247. /* which root are we searching. 0 is the tree of tree roots */
  248. __u64 tree_id;
  249. /* keys returned will be >= min and <= max */
  250. __u64 min_objectid;
  251. __u64 max_objectid;
  252. /* keys returned will be >= min and <= max */
  253. __u64 min_offset;
  254. __u64 max_offset;
  255. /* max and min transids to search for */
  256. __u64 min_transid;
  257. __u64 max_transid;
  258. /* keys returned will be >= min and <= max */
  259. __u32 min_type;
  260. __u32 max_type;
  261. /*
  262. * how many items did userland ask for, and how many are we
  263. * returning
  264. */
  265. __u32 nr_items;
  266. /* align to 64 bits */
  267. __u32 unused;
  268. /* some extra for later */
  269. __u64 unused1;
  270. __u64 unused2;
  271. __u64 unused3;
  272. __u64 unused4;
  273. };
  274. struct btrfs_ioctl_search_header {
  275. __u64 transid;
  276. __u64 objectid;
  277. __u64 offset;
  278. __u32 type;
  279. __u32 len;
  280. };
  281. #define BTRFS_SEARCH_ARGS_BUFSIZE (4096 - sizeof(struct btrfs_ioctl_search_key))
  282. /*
  283. * the buf is an array of search headers where
  284. * each header is followed by the actual item
  285. * the type field is expanded to 32 bits for alignment
  286. */
  287. struct btrfs_ioctl_search_args {
  288. struct btrfs_ioctl_search_key key;
  289. char buf[BTRFS_SEARCH_ARGS_BUFSIZE];
  290. };
  291. struct btrfs_ioctl_search_args_v2 {
  292. struct btrfs_ioctl_search_key key; /* in/out - search parameters */
  293. __u64 buf_size; /* in - size of buffer
  294. * out - on EOVERFLOW: needed size
  295. * to store item */
  296. __u64 buf[0]; /* out - found items */
  297. };
  298. struct btrfs_ioctl_clone_range_args {
  299. __s64 src_fd;
  300. __u64 src_offset, src_length;
  301. __u64 dest_offset;
  302. };
  303. /* flags for the defrag range ioctl */
  304. #define BTRFS_DEFRAG_RANGE_COMPRESS 1
  305. #define BTRFS_DEFRAG_RANGE_START_IO 2
  306. #define BTRFS_SAME_DATA_DIFFERS 1
  307. /* For extent-same ioctl */
  308. struct btrfs_ioctl_same_extent_info {
  309. __s64 fd; /* in - destination file */
  310. __u64 logical_offset; /* in - start of extent in destination */
  311. __u64 bytes_deduped; /* out - total # of bytes we were able
  312. * to dedupe from this file */
  313. /* status of this dedupe operation:
  314. * 0 if dedup succeeds
  315. * < 0 for error
  316. * == BTRFS_SAME_DATA_DIFFERS if data differs
  317. */
  318. __s32 status; /* out - see above description */
  319. __u32 reserved;
  320. };
  321. struct btrfs_ioctl_same_args {
  322. __u64 logical_offset; /* in - start of extent in source */
  323. __u64 length; /* in - length of extent */
  324. __u16 dest_count; /* in - total elements in info array */
  325. __u16 reserved1;
  326. __u32 reserved2;
  327. struct btrfs_ioctl_same_extent_info info[0];
  328. };
  329. struct btrfs_ioctl_space_info {
  330. __u64 flags;
  331. __u64 total_bytes;
  332. __u64 used_bytes;
  333. };
  334. struct btrfs_ioctl_space_args {
  335. __u64 space_slots;
  336. __u64 total_spaces;
  337. struct btrfs_ioctl_space_info spaces[0];
  338. };
  339. struct btrfs_data_container {
  340. __u32 bytes_left; /* out -- bytes not needed to deliver output */
  341. __u32 bytes_missing; /* out -- additional bytes needed for result */
  342. __u32 elem_cnt; /* out */
  343. __u32 elem_missed; /* out */
  344. __u64 val[0]; /* out */
  345. };
  346. struct btrfs_ioctl_ino_path_args {
  347. __u64 inum; /* in */
  348. __u64 size; /* in */
  349. __u64 reserved[4];
  350. /* struct btrfs_data_container *fspath; out */
  351. __u64 fspath; /* out */
  352. };
  353. struct btrfs_ioctl_logical_ino_args {
  354. __u64 logical; /* in */
  355. __u64 size; /* in */
  356. __u64 reserved[4];
  357. /* struct btrfs_data_container *inodes; out */
  358. __u64 inodes;
  359. };
  360. enum btrfs_dev_stat_values {
  361. /* disk I/O failure stats */
  362. BTRFS_DEV_STAT_WRITE_ERRS, /* EIO or EREMOTEIO from lower layers */
  363. BTRFS_DEV_STAT_READ_ERRS, /* EIO or EREMOTEIO from lower layers */
  364. BTRFS_DEV_STAT_FLUSH_ERRS, /* EIO or EREMOTEIO from lower layers */
  365. /* stats for indirect indications for I/O failures */
  366. BTRFS_DEV_STAT_CORRUPTION_ERRS, /* checksum error, bytenr error or
  367. * contents is illegal: this is an
  368. * indication that the block was damaged
  369. * during read or write, or written to
  370. * wrong location or read from wrong
  371. * location */
  372. BTRFS_DEV_STAT_GENERATION_ERRS, /* an indication that blocks have not
  373. * been written */
  374. BTRFS_DEV_STAT_VALUES_MAX
  375. };
  376. /* Reset statistics after reading; needs SYS_ADMIN capability */
  377. #define BTRFS_DEV_STATS_RESET (1ULL << 0)
  378. struct btrfs_ioctl_get_dev_stats {
  379. __u64 devid; /* in */
  380. __u64 nr_items; /* in/out */
  381. __u64 flags; /* in/out */
  382. /* out values: */
  383. __u64 values[BTRFS_DEV_STAT_VALUES_MAX];
  384. __u64 unused[128 - 2 - BTRFS_DEV_STAT_VALUES_MAX]; /* pad to 1k */
  385. };
  386. #define BTRFS_QUOTA_CTL_ENABLE 1
  387. #define BTRFS_QUOTA_CTL_DISABLE 2
  388. #define BTRFS_QUOTA_CTL_RESCAN__NOTUSED 3
  389. struct btrfs_ioctl_quota_ctl_args {
  390. __u64 cmd;
  391. __u64 status;
  392. };
  393. struct btrfs_ioctl_quota_rescan_args {
  394. __u64 flags;
  395. __u64 progress;
  396. __u64 reserved[6];
  397. };
  398. struct btrfs_ioctl_qgroup_assign_args {
  399. __u64 assign;
  400. __u64 src;
  401. __u64 dst;
  402. };
  403. struct btrfs_ioctl_qgroup_create_args {
  404. __u64 create;
  405. __u64 qgroupid;
  406. };
  407. struct btrfs_ioctl_timespec {
  408. __u64 sec;
  409. __u32 nsec;
  410. };
  411. struct btrfs_ioctl_received_subvol_args {
  412. char uuid[BTRFS_UUID_SIZE]; /* in */
  413. __u64 stransid; /* in */
  414. __u64 rtransid; /* out */
  415. struct btrfs_ioctl_timespec stime; /* in */
  416. struct btrfs_ioctl_timespec rtime; /* out */
  417. __u64 flags; /* in */
  418. __u64 reserved[16]; /* in */
  419. };
  420. /*
  421. * Caller doesn't want file data in the send stream, even if the
  422. * search of clone sources doesn't find an extent. UPDATE_EXTENT
  423. * commands will be sent instead of WRITE commands.
  424. */
  425. #define BTRFS_SEND_FLAG_NO_FILE_DATA 0x1
  426. /*
  427. * Do not add the leading stream header. Used when multiple snapshots
  428. * are sent back to back.
  429. */
  430. #define BTRFS_SEND_FLAG_OMIT_STREAM_HEADER 0x2
  431. /*
  432. * Omit the command at the end of the stream that indicated the end
  433. * of the stream. This option is used when multiple snapshots are
  434. * sent back to back.
  435. */
  436. #define BTRFS_SEND_FLAG_OMIT_END_CMD 0x4
  437. #define BTRFS_SEND_FLAG_MASK \
  438. (BTRFS_SEND_FLAG_NO_FILE_DATA | \
  439. BTRFS_SEND_FLAG_OMIT_STREAM_HEADER | \
  440. BTRFS_SEND_FLAG_OMIT_END_CMD)
  441. struct btrfs_ioctl_send_args {
  442. __s64 send_fd; /* in */
  443. __u64 clone_sources_count; /* in */
  444. __u64 __user *clone_sources; /* in */
  445. __u64 parent_root; /* in */
  446. __u64 flags; /* in */
  447. __u64 reserved[4]; /* in */
  448. };
  449. /* Error codes as returned by the kernel */
  450. enum btrfs_err_code {
  451. BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET = 1,
  452. BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET,
  453. BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET,
  454. BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET,
  455. BTRFS_ERROR_DEV_TGT_REPLACE,
  456. BTRFS_ERROR_DEV_MISSING_NOT_FOUND,
  457. BTRFS_ERROR_DEV_ONLY_WRITABLE,
  458. BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS
  459. };
  460. /* An error code to error string mapping for the kernel
  461. * error codes
  462. */
  463. static inline char *btrfs_err_str(enum btrfs_err_code err_code)
  464. {
  465. switch (err_code) {
  466. case BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET:
  467. return "unable to go below two devices on raid1";
  468. case BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET:
  469. return "unable to go below four devices on raid10";
  470. case BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET:
  471. return "unable to go below two devices on raid5";
  472. case BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET:
  473. return "unable to go below three devices on raid6";
  474. case BTRFS_ERROR_DEV_TGT_REPLACE:
  475. return "unable to remove the dev_replace target dev";
  476. case BTRFS_ERROR_DEV_MISSING_NOT_FOUND:
  477. return "no missing devices found to remove";
  478. case BTRFS_ERROR_DEV_ONLY_WRITABLE:
  479. return "unable to remove the only writeable device";
  480. case BTRFS_ERROR_DEV_EXCL_RUN_IN_PROGRESS:
  481. return "add/delete/balance/replace/resize operation "\
  482. "in progress";
  483. default:
  484. return NULL;
  485. }
  486. }
  487. #define BTRFS_IOC_SNAP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 1, \
  488. struct btrfs_ioctl_vol_args)
  489. #define BTRFS_IOC_DEFRAG _IOW(BTRFS_IOCTL_MAGIC, 2, \
  490. struct btrfs_ioctl_vol_args)
  491. #define BTRFS_IOC_RESIZE _IOW(BTRFS_IOCTL_MAGIC, 3, \
  492. struct btrfs_ioctl_vol_args)
  493. #define BTRFS_IOC_SCAN_DEV _IOW(BTRFS_IOCTL_MAGIC, 4, \
  494. struct btrfs_ioctl_vol_args)
  495. /* trans start and trans end are dangerous, and only for
  496. * use by applications that know how to avoid the
  497. * resulting deadlocks
  498. */
  499. #define BTRFS_IOC_TRANS_START _IO(BTRFS_IOCTL_MAGIC, 6)
  500. #define BTRFS_IOC_TRANS_END _IO(BTRFS_IOCTL_MAGIC, 7)
  501. #define BTRFS_IOC_SYNC _IO(BTRFS_IOCTL_MAGIC, 8)
  502. #define BTRFS_IOC_CLONE _IOW(BTRFS_IOCTL_MAGIC, 9, int)
  503. #define BTRFS_IOC_ADD_DEV _IOW(BTRFS_IOCTL_MAGIC, 10, \
  504. struct btrfs_ioctl_vol_args)
  505. #define BTRFS_IOC_RM_DEV _IOW(BTRFS_IOCTL_MAGIC, 11, \
  506. struct btrfs_ioctl_vol_args)
  507. #define BTRFS_IOC_BALANCE _IOW(BTRFS_IOCTL_MAGIC, 12, \
  508. struct btrfs_ioctl_vol_args)
  509. #define BTRFS_IOC_CLONE_RANGE _IOW(BTRFS_IOCTL_MAGIC, 13, \
  510. struct btrfs_ioctl_clone_range_args)
  511. #define BTRFS_IOC_SUBVOL_CREATE _IOW(BTRFS_IOCTL_MAGIC, 14, \
  512. struct btrfs_ioctl_vol_args)
  513. #define BTRFS_IOC_SNAP_DESTROY _IOW(BTRFS_IOCTL_MAGIC, 15, \
  514. struct btrfs_ioctl_vol_args)
  515. #define BTRFS_IOC_DEFRAG_RANGE _IOW(BTRFS_IOCTL_MAGIC, 16, \
  516. struct btrfs_ioctl_defrag_range_args)
  517. #define BTRFS_IOC_TREE_SEARCH _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  518. struct btrfs_ioctl_search_args)
  519. #define BTRFS_IOC_TREE_SEARCH_V2 _IOWR(BTRFS_IOCTL_MAGIC, 17, \
  520. struct btrfs_ioctl_search_args_v2)
  521. #define BTRFS_IOC_INO_LOOKUP _IOWR(BTRFS_IOCTL_MAGIC, 18, \
  522. struct btrfs_ioctl_ino_lookup_args)
  523. #define BTRFS_IOC_DEFAULT_SUBVOL _IOW(BTRFS_IOCTL_MAGIC, 19, __u64)
  524. #define BTRFS_IOC_SPACE_INFO _IOWR(BTRFS_IOCTL_MAGIC, 20, \
  525. struct btrfs_ioctl_space_args)
  526. #define BTRFS_IOC_START_SYNC _IOR(BTRFS_IOCTL_MAGIC, 24, __u64)
  527. #define BTRFS_IOC_WAIT_SYNC _IOW(BTRFS_IOCTL_MAGIC, 22, __u64)
  528. #define BTRFS_IOC_SNAP_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 23, \
  529. struct btrfs_ioctl_vol_args_v2)
  530. #define BTRFS_IOC_SUBVOL_CREATE_V2 _IOW(BTRFS_IOCTL_MAGIC, 24, \
  531. struct btrfs_ioctl_vol_args_v2)
  532. #define BTRFS_IOC_SUBVOL_GETFLAGS _IOR(BTRFS_IOCTL_MAGIC, 25, __u64)
  533. #define BTRFS_IOC_SUBVOL_SETFLAGS _IOW(BTRFS_IOCTL_MAGIC, 26, __u64)
  534. #define BTRFS_IOC_SCRUB _IOWR(BTRFS_IOCTL_MAGIC, 27, \
  535. struct btrfs_ioctl_scrub_args)
  536. #define BTRFS_IOC_SCRUB_CANCEL _IO(BTRFS_IOCTL_MAGIC, 28)
  537. #define BTRFS_IOC_SCRUB_PROGRESS _IOWR(BTRFS_IOCTL_MAGIC, 29, \
  538. struct btrfs_ioctl_scrub_args)
  539. #define BTRFS_IOC_DEV_INFO _IOWR(BTRFS_IOCTL_MAGIC, 30, \
  540. struct btrfs_ioctl_dev_info_args)
  541. #define BTRFS_IOC_FS_INFO _IOR(BTRFS_IOCTL_MAGIC, 31, \
  542. struct btrfs_ioctl_fs_info_args)
  543. #define BTRFS_IOC_BALANCE_V2 _IOWR(BTRFS_IOCTL_MAGIC, 32, \
  544. struct btrfs_ioctl_balance_args)
  545. #define BTRFS_IOC_BALANCE_CTL _IOW(BTRFS_IOCTL_MAGIC, 33, int)
  546. #define BTRFS_IOC_BALANCE_PROGRESS _IOR(BTRFS_IOCTL_MAGIC, 34, \
  547. struct btrfs_ioctl_balance_args)
  548. #define BTRFS_IOC_INO_PATHS _IOWR(BTRFS_IOCTL_MAGIC, 35, \
  549. struct btrfs_ioctl_ino_path_args)
  550. #define BTRFS_IOC_LOGICAL_INO _IOWR(BTRFS_IOCTL_MAGIC, 36, \
  551. struct btrfs_ioctl_ino_path_args)
  552. #define BTRFS_IOC_SET_RECEIVED_SUBVOL _IOWR(BTRFS_IOCTL_MAGIC, 37, \
  553. struct btrfs_ioctl_received_subvol_args)
  554. #define BTRFS_IOC_SEND _IOW(BTRFS_IOCTL_MAGIC, 38, struct btrfs_ioctl_send_args)
  555. #define BTRFS_IOC_DEVICES_READY _IOR(BTRFS_IOCTL_MAGIC, 39, \
  556. struct btrfs_ioctl_vol_args)
  557. #define BTRFS_IOC_QUOTA_CTL _IOWR(BTRFS_IOCTL_MAGIC, 40, \
  558. struct btrfs_ioctl_quota_ctl_args)
  559. #define BTRFS_IOC_QGROUP_ASSIGN _IOW(BTRFS_IOCTL_MAGIC, 41, \
  560. struct btrfs_ioctl_qgroup_assign_args)
  561. #define BTRFS_IOC_QGROUP_CREATE _IOW(BTRFS_IOCTL_MAGIC, 42, \
  562. struct btrfs_ioctl_qgroup_create_args)
  563. #define BTRFS_IOC_QGROUP_LIMIT _IOR(BTRFS_IOCTL_MAGIC, 43, \
  564. struct btrfs_ioctl_qgroup_limit_args)
  565. #define BTRFS_IOC_QUOTA_RESCAN _IOW(BTRFS_IOCTL_MAGIC, 44, \
  566. struct btrfs_ioctl_quota_rescan_args)
  567. #define BTRFS_IOC_QUOTA_RESCAN_STATUS _IOR(BTRFS_IOCTL_MAGIC, 45, \
  568. struct btrfs_ioctl_quota_rescan_args)
  569. #define BTRFS_IOC_QUOTA_RESCAN_WAIT _IO(BTRFS_IOCTL_MAGIC, 46)
  570. #define BTRFS_IOC_GET_FSLABEL _IOR(BTRFS_IOCTL_MAGIC, 49, \
  571. char[BTRFS_LABEL_SIZE])
  572. #define BTRFS_IOC_SET_FSLABEL _IOW(BTRFS_IOCTL_MAGIC, 50, \
  573. char[BTRFS_LABEL_SIZE])
  574. #define BTRFS_IOC_GET_DEV_STATS _IOWR(BTRFS_IOCTL_MAGIC, 52, \
  575. struct btrfs_ioctl_get_dev_stats)
  576. #define BTRFS_IOC_DEV_REPLACE _IOWR(BTRFS_IOCTL_MAGIC, 53, \
  577. struct btrfs_ioctl_dev_replace_args)
  578. #define BTRFS_IOC_FILE_EXTENT_SAME _IOWR(BTRFS_IOCTL_MAGIC, 54, \
  579. struct btrfs_ioctl_same_args)
  580. #define BTRFS_IOC_GET_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
  581. struct btrfs_ioctl_feature_flags)
  582. #define BTRFS_IOC_SET_FEATURES _IOW(BTRFS_IOCTL_MAGIC, 57, \
  583. struct btrfs_ioctl_feature_flags[2])
  584. #define BTRFS_IOC_GET_SUPPORTED_FEATURES _IOR(BTRFS_IOCTL_MAGIC, 57, \
  585. struct btrfs_ioctl_feature_flags[3])
  586. #endif /* _UAPI_LINUX_BTRFS_H */