nilfs2_api.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
  2. /*
  3. * nilfs2_api.h - NILFS2 user space API
  4. *
  5. * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU Lesser General Public License as published
  9. * by the Free Software Foundation; either version 2.1 of the License, or
  10. * (at your option) any later version.
  11. */
  12. #ifndef _LINUX_NILFS2_API_H
  13. #define _LINUX_NILFS2_API_H
  14. #include <linux/types.h>
  15. #include <linux/ioctl.h>
  16. /**
  17. * struct nilfs_cpinfo - checkpoint information
  18. * @ci_flags: flags
  19. * @ci_pad: padding
  20. * @ci_cno: checkpoint number
  21. * @ci_create: creation timestamp
  22. * @ci_nblk_inc: number of blocks incremented by this checkpoint
  23. * @ci_inodes_count: inodes count
  24. * @ci_blocks_count: blocks count
  25. * @ci_next: next checkpoint number in snapshot list
  26. */
  27. struct nilfs_cpinfo {
  28. __u32 ci_flags;
  29. __u32 ci_pad;
  30. __u64 ci_cno;
  31. __u64 ci_create;
  32. __u64 ci_nblk_inc;
  33. __u64 ci_inodes_count;
  34. __u64 ci_blocks_count;
  35. __u64 ci_next;
  36. };
  37. /* checkpoint flags */
  38. enum {
  39. NILFS_CPINFO_SNAPSHOT,
  40. NILFS_CPINFO_INVALID,
  41. NILFS_CPINFO_SKETCH,
  42. NILFS_CPINFO_MINOR,
  43. };
  44. #define NILFS_CPINFO_FNS(flag, name) \
  45. static inline int \
  46. nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \
  47. { \
  48. return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag)); \
  49. }
  50. NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
  51. NILFS_CPINFO_FNS(INVALID, invalid)
  52. NILFS_CPINFO_FNS(MINOR, minor)
  53. /**
  54. * nilfs_suinfo - segment usage information
  55. * @sui_lastmod: timestamp of last modification
  56. * @sui_nblocks: number of written blocks in segment
  57. * @sui_flags: segment usage flags
  58. */
  59. struct nilfs_suinfo {
  60. __u64 sui_lastmod;
  61. __u32 sui_nblocks;
  62. __u32 sui_flags;
  63. };
  64. /* segment usage flags */
  65. enum {
  66. NILFS_SUINFO_ACTIVE,
  67. NILFS_SUINFO_DIRTY,
  68. NILFS_SUINFO_ERROR,
  69. };
  70. #define NILFS_SUINFO_FNS(flag, name) \
  71. static inline int \
  72. nilfs_suinfo_##name(const struct nilfs_suinfo *si) \
  73. { \
  74. return si->sui_flags & (1UL << NILFS_SUINFO_##flag); \
  75. }
  76. NILFS_SUINFO_FNS(ACTIVE, active)
  77. NILFS_SUINFO_FNS(DIRTY, dirty)
  78. NILFS_SUINFO_FNS(ERROR, error)
  79. static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si)
  80. {
  81. return !si->sui_flags;
  82. }
  83. /**
  84. * nilfs_suinfo_update - segment usage information update
  85. * @sup_segnum: segment number
  86. * @sup_flags: flags for which fields are active in sup_sui
  87. * @sup_reserved: reserved necessary for alignment
  88. * @sup_sui: segment usage information
  89. */
  90. struct nilfs_suinfo_update {
  91. __u64 sup_segnum;
  92. __u32 sup_flags;
  93. __u32 sup_reserved;
  94. struct nilfs_suinfo sup_sui;
  95. };
  96. enum {
  97. NILFS_SUINFO_UPDATE_LASTMOD,
  98. NILFS_SUINFO_UPDATE_NBLOCKS,
  99. NILFS_SUINFO_UPDATE_FLAGS,
  100. __NR_NILFS_SUINFO_UPDATE_FIELDS,
  101. };
  102. #define NILFS_SUINFO_UPDATE_FNS(flag, name) \
  103. static inline void \
  104. nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \
  105. { \
  106. sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \
  107. } \
  108. static inline void \
  109. nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \
  110. { \
  111. sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \
  112. } \
  113. static inline int \
  114. nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \
  115. { \
  116. return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\
  117. }
  118. NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod)
  119. NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks)
  120. NILFS_SUINFO_UPDATE_FNS(FLAGS, flags)
  121. enum {
  122. NILFS_CHECKPOINT,
  123. NILFS_SNAPSHOT,
  124. };
  125. /**
  126. * struct nilfs_cpmode - change checkpoint mode structure
  127. * @cm_cno: checkpoint number
  128. * @cm_mode: mode of checkpoint
  129. * @cm_pad: padding
  130. */
  131. struct nilfs_cpmode {
  132. __u64 cm_cno;
  133. __u32 cm_mode;
  134. __u32 cm_pad;
  135. };
  136. /**
  137. * struct nilfs_argv - argument vector
  138. * @v_base: pointer on data array from userspace
  139. * @v_nmembs: number of members in data array
  140. * @v_size: size of data array in bytes
  141. * @v_flags: flags
  142. * @v_index: start number of target data items
  143. */
  144. struct nilfs_argv {
  145. __u64 v_base;
  146. __u32 v_nmembs; /* number of members */
  147. __u16 v_size; /* size of members */
  148. __u16 v_flags;
  149. __u64 v_index;
  150. };
  151. /**
  152. * struct nilfs_period - period of checkpoint numbers
  153. * @p_start: start checkpoint number (inclusive)
  154. * @p_end: end checkpoint number (exclusive)
  155. */
  156. struct nilfs_period {
  157. __u64 p_start;
  158. __u64 p_end;
  159. };
  160. /**
  161. * struct nilfs_cpstat - checkpoint statistics
  162. * @cs_cno: checkpoint number
  163. * @cs_ncps: number of checkpoints
  164. * @cs_nsss: number of snapshots
  165. */
  166. struct nilfs_cpstat {
  167. __u64 cs_cno;
  168. __u64 cs_ncps;
  169. __u64 cs_nsss;
  170. };
  171. /**
  172. * struct nilfs_sustat - segment usage statistics
  173. * @ss_nsegs: number of segments
  174. * @ss_ncleansegs: number of clean segments
  175. * @ss_ndirtysegs: number of dirty segments
  176. * @ss_ctime: creation time of the last segment
  177. * @ss_nongc_ctime: creation time of the last segment not for GC
  178. * @ss_prot_seq: least sequence number of segments which must not be reclaimed
  179. */
  180. struct nilfs_sustat {
  181. __u64 ss_nsegs;
  182. __u64 ss_ncleansegs;
  183. __u64 ss_ndirtysegs;
  184. __u64 ss_ctime;
  185. __u64 ss_nongc_ctime;
  186. __u64 ss_prot_seq;
  187. };
  188. /**
  189. * struct nilfs_vinfo - virtual block number information
  190. * @vi_vblocknr: virtual block number
  191. * @vi_start: start checkpoint number (inclusive)
  192. * @vi_end: end checkpoint number (exclusive)
  193. * @vi_blocknr: disk block number
  194. */
  195. struct nilfs_vinfo {
  196. __u64 vi_vblocknr;
  197. __u64 vi_start;
  198. __u64 vi_end;
  199. __u64 vi_blocknr;
  200. };
  201. /**
  202. * struct nilfs_vdesc - descriptor of virtual block number
  203. * @vd_ino: inode number
  204. * @vd_cno: checkpoint number
  205. * @vd_vblocknr: virtual block number
  206. * @vd_period: period of checkpoint numbers
  207. * @vd_blocknr: disk block number
  208. * @vd_offset: logical block offset inside a file
  209. * @vd_flags: flags (data or node block)
  210. * @vd_pad: padding
  211. */
  212. struct nilfs_vdesc {
  213. __u64 vd_ino;
  214. __u64 vd_cno;
  215. __u64 vd_vblocknr;
  216. struct nilfs_period vd_period;
  217. __u64 vd_blocknr;
  218. __u64 vd_offset;
  219. __u32 vd_flags;
  220. __u32 vd_pad;
  221. };
  222. /**
  223. * struct nilfs_bdesc - descriptor of disk block number
  224. * @bd_ino: inode number
  225. * @bd_oblocknr: disk block address (for skipping dead blocks)
  226. * @bd_blocknr: disk block address
  227. * @bd_offset: logical block offset inside a file
  228. * @bd_level: level in the b-tree organization
  229. * @bd_pad: padding
  230. */
  231. struct nilfs_bdesc {
  232. __u64 bd_ino;
  233. __u64 bd_oblocknr;
  234. __u64 bd_blocknr;
  235. __u64 bd_offset;
  236. __u32 bd_level;
  237. __u32 bd_pad;
  238. };
  239. #define NILFS_IOCTL_IDENT 'n'
  240. #define NILFS_IOCTL_CHANGE_CPMODE \
  241. _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode)
  242. #define NILFS_IOCTL_DELETE_CHECKPOINT \
  243. _IOW(NILFS_IOCTL_IDENT, 0x81, __u64)
  244. #define NILFS_IOCTL_GET_CPINFO \
  245. _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv)
  246. #define NILFS_IOCTL_GET_CPSTAT \
  247. _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat)
  248. #define NILFS_IOCTL_GET_SUINFO \
  249. _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv)
  250. #define NILFS_IOCTL_GET_SUSTAT \
  251. _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat)
  252. #define NILFS_IOCTL_GET_VINFO \
  253. _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv)
  254. #define NILFS_IOCTL_GET_BDESCS \
  255. _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv)
  256. #define NILFS_IOCTL_CLEAN_SEGMENTS \
  257. _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5])
  258. #define NILFS_IOCTL_SYNC \
  259. _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
  260. #define NILFS_IOCTL_RESIZE \
  261. _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
  262. #define NILFS_IOCTL_SET_ALLOC_RANGE \
  263. _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2])
  264. #define NILFS_IOCTL_SET_SUINFO \
  265. _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv)
  266. #endif /* _LINUX_NILFS2_API_H */