ocfs2_ioctl.h 6.3 KB

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