btrfs.h 22 KB

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