nilfs2_api.h 7.3 KB

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