ocfs2_ioctl.h 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /* -*- mode: c; c-basic-offset: 8; -*-
  3. * vim: noexpandtab sw=8 ts=8 sts=0:
  4. *
  5. * ocfs2_ioctl.h
  6. *
  7. * Defines OCFS2 ioctls.
  8. *
  9. * Copyright (C) 2010 Oracle. All rights reserved.
  10. */
  11. #ifndef OCFS2_IOCTL_H
  12. #define OCFS2_IOCTL_H
  13. /*
  14. * ioctl commands
  15. */
  16. #define OCFS2_IOC_GETFLAGS FS_IOC_GETFLAGS
  17. #define OCFS2_IOC_SETFLAGS FS_IOC_SETFLAGS
  18. #define OCFS2_IOC32_GETFLAGS FS_IOC32_GETFLAGS
  19. #define OCFS2_IOC32_SETFLAGS FS_IOC32_SETFLAGS
  20. /*
  21. * Space reservation / allocation / free ioctls and argument structure
  22. * are designed to be compatible with XFS.
  23. *
  24. * ALLOCSP* and FREESP* are not and will never be supported, but are
  25. * included here for completeness.
  26. */
  27. struct ocfs2_space_resv {
  28. __s16 l_type;
  29. __s16 l_whence;
  30. __s64 l_start;
  31. __s64 l_len; /* len == 0 means until end of file */
  32. __s32 l_sysid;
  33. __u32 l_pid;
  34. __s32 l_pad[4]; /* reserve area */
  35. };
  36. #define OCFS2_IOC_ALLOCSP _IOW ('X', 10, struct ocfs2_space_resv)
  37. #define OCFS2_IOC_FREESP _IOW ('X', 11, struct ocfs2_space_resv)
  38. #define OCFS2_IOC_RESVSP _IOW ('X', 40, struct ocfs2_space_resv)
  39. #define OCFS2_IOC_UNRESVSP _IOW ('X', 41, struct ocfs2_space_resv)
  40. #define OCFS2_IOC_ALLOCSP64 _IOW ('X', 36, struct ocfs2_space_resv)
  41. #define OCFS2_IOC_FREESP64 _IOW ('X', 37, struct ocfs2_space_resv)
  42. #define OCFS2_IOC_RESVSP64 _IOW ('X', 42, struct ocfs2_space_resv)
  43. #define OCFS2_IOC_UNRESVSP64 _IOW ('X', 43, struct ocfs2_space_resv)
  44. /* Used to pass group descriptor data when online resize is done */
  45. struct ocfs2_new_group_input {
  46. __u64 group; /* Group descriptor's blkno. */
  47. __u32 clusters; /* Total number of clusters in this group */
  48. __u32 frees; /* Total free clusters in this group */
  49. __u16 chain; /* Chain for this group */
  50. __u16 reserved1;
  51. __u32 reserved2;
  52. };
  53. #define OCFS2_IOC_GROUP_EXTEND _IOW('o', 1, int)
  54. #define OCFS2_IOC_GROUP_ADD _IOW('o', 2,struct ocfs2_new_group_input)
  55. #define OCFS2_IOC_GROUP_ADD64 _IOW('o', 3,struct ocfs2_new_group_input)
  56. /* Used to pass 2 file names to reflink. */
  57. struct reflink_arguments {
  58. __u64 old_path;
  59. __u64 new_path;
  60. __u64 preserve;
  61. };
  62. #define OCFS2_IOC_REFLINK _IOW('o', 4, struct reflink_arguments)
  63. /* Following definitions dedicated for ocfs2_info_request ioctls. */
  64. #define OCFS2_INFO_MAX_REQUEST (50)
  65. #define OCFS2_TEXT_UUID_LEN (OCFS2_VOL_UUID_LEN * 2)
  66. /* Magic number of all requests */
  67. #define OCFS2_INFO_MAGIC (0x4F32494E)
  68. /*
  69. * Always try to separate info request into small pieces to
  70. * guarantee the backward&forward compatibility.
  71. */
  72. struct ocfs2_info {
  73. __u64 oi_requests; /* Array of __u64 pointers to requests */
  74. __u32 oi_count; /* Number of requests in info_requests */
  75. __u32 oi_pad;
  76. };
  77. struct ocfs2_info_request {
  78. /*00*/ __u32 ir_magic; /* Magic number */
  79. __u32 ir_code; /* Info request code */
  80. __u32 ir_size; /* Size of request */
  81. __u32 ir_flags; /* Request flags */
  82. /*10*/ /* Request specific fields */
  83. };
  84. struct ocfs2_info_clustersize {
  85. struct ocfs2_info_request ic_req;
  86. __u32 ic_clustersize;
  87. __u32 ic_pad;
  88. };
  89. struct ocfs2_info_blocksize {
  90. struct ocfs2_info_request ib_req;
  91. __u32 ib_blocksize;
  92. __u32 ib_pad;
  93. };
  94. struct ocfs2_info_maxslots {
  95. struct ocfs2_info_request im_req;
  96. __u32 im_max_slots;
  97. __u32 im_pad;
  98. };
  99. struct ocfs2_info_label {
  100. struct ocfs2_info_request il_req;
  101. __u8 il_label[OCFS2_MAX_VOL_LABEL_LEN];
  102. } __attribute__ ((packed));
  103. struct ocfs2_info_uuid {
  104. struct ocfs2_info_request iu_req;
  105. __u8 iu_uuid_str[OCFS2_TEXT_UUID_LEN + 1];
  106. } __attribute__ ((packed));
  107. struct ocfs2_info_fs_features {
  108. struct ocfs2_info_request if_req;
  109. __u32 if_compat_features;
  110. __u32 if_incompat_features;
  111. __u32 if_ro_compat_features;
  112. __u32 if_pad;
  113. };
  114. struct ocfs2_info_journal_size {
  115. struct ocfs2_info_request ij_req;
  116. __u64 ij_journal_size;
  117. };
  118. struct ocfs2_info_freeinode {
  119. struct ocfs2_info_request ifi_req;
  120. struct ocfs2_info_local_freeinode {
  121. __u64 lfi_total;
  122. __u64 lfi_free;
  123. } ifi_stat[OCFS2_MAX_SLOTS];
  124. __u32 ifi_slotnum; /* out */
  125. __u32 ifi_pad;
  126. };
  127. #define OCFS2_INFO_MAX_HIST (32)
  128. struct ocfs2_info_freefrag {
  129. struct ocfs2_info_request iff_req;
  130. struct ocfs2_info_freefrag_stats { /* (out) */
  131. struct ocfs2_info_free_chunk_list {
  132. __u32 fc_chunks[OCFS2_INFO_MAX_HIST];
  133. __u32 fc_clusters[OCFS2_INFO_MAX_HIST];
  134. } ffs_fc_hist;
  135. __u32 ffs_clusters;
  136. __u32 ffs_free_clusters;
  137. __u32 ffs_free_chunks;
  138. __u32 ffs_free_chunks_real;
  139. __u32 ffs_min; /* Minimum free chunksize in clusters */
  140. __u32 ffs_max;
  141. __u32 ffs_avg;
  142. __u32 ffs_pad;
  143. } iff_ffs;
  144. __u32 iff_chunksize; /* chunksize in clusters(in) */
  145. __u32 iff_pad;
  146. };
  147. /* Codes for ocfs2_info_request */
  148. enum ocfs2_info_type {
  149. OCFS2_INFO_CLUSTERSIZE = 1,
  150. OCFS2_INFO_BLOCKSIZE,
  151. OCFS2_INFO_MAXSLOTS,
  152. OCFS2_INFO_LABEL,
  153. OCFS2_INFO_UUID,
  154. OCFS2_INFO_FS_FEATURES,
  155. OCFS2_INFO_JOURNAL_SIZE,
  156. OCFS2_INFO_FREEINODE,
  157. OCFS2_INFO_FREEFRAG,
  158. OCFS2_INFO_NUM_TYPES
  159. };
  160. /* Flags for struct ocfs2_info_request */
  161. /* Filled by the caller */
  162. #define OCFS2_INFO_FL_NON_COHERENT (0x00000001) /* Cluster coherency not
  163. required. This is a hint.
  164. It is up to ocfs2 whether
  165. the request can be fulfilled
  166. without locking. */
  167. /* Filled by ocfs2 */
  168. #define OCFS2_INFO_FL_FILLED (0x40000000) /* Filesystem understood
  169. this request and
  170. filled in the answer */
  171. #define OCFS2_INFO_FL_ERROR (0x80000000) /* Error happened during
  172. request handling. */
  173. #define OCFS2_IOC_INFO _IOR('o', 5, struct ocfs2_info)
  174. struct ocfs2_move_extents {
  175. /* All values are in bytes */
  176. /* in */
  177. __u64 me_start; /* Virtual start in the file to move */
  178. __u64 me_len; /* Length of the extents to be moved */
  179. __u64 me_goal; /* Physical offset of the goal,
  180. it's in block unit */
  181. __u64 me_threshold; /* Maximum distance from goal or threshold
  182. for auto defragmentation */
  183. __u64 me_flags; /* Flags for the operation:
  184. * - auto defragmentation.
  185. * - refcount,xattr cases.
  186. */
  187. /* out */
  188. __u64 me_moved_len; /* Moved/defraged length */
  189. __u64 me_new_offset; /* Resulting physical location */
  190. __u32 me_reserved[2]; /* Reserved for futhure */
  191. };
  192. #define OCFS2_MOVE_EXT_FL_AUTO_DEFRAG (0x00000001) /* Kernel manages to
  193. claim new clusters
  194. as the goal place
  195. for extents moving */
  196. #define OCFS2_MOVE_EXT_FL_PART_DEFRAG (0x00000002) /* Allow partial extent
  197. moving, is to make
  198. movement less likely
  199. to fail, may make fs
  200. even more fragmented */
  201. #define OCFS2_MOVE_EXT_FL_COMPLETE (0x00000004) /* Move or defragmenation
  202. completely gets done.
  203. */
  204. #define OCFS2_IOC_MOVE_EXT _IOW('o', 6, struct ocfs2_move_extents)
  205. #endif /* OCFS2_IOCTL_H */