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