2 * nilfs2_api.h - NILFS2 user space API
4 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
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.
12 #ifndef _LINUX_NILFS2_API_H
13 #define _LINUX_NILFS2_API_H
15 #include <linux/types.h>
16 #include <linux/ioctl.h>
19 * struct nilfs_cpinfo - checkpoint information
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
35 __u64 ci_inodes_count
;
36 __u64 ci_blocks_count
;
40 /* checkpoint flags */
42 NILFS_CPINFO_SNAPSHOT
,
48 #define NILFS_CPINFO_FNS(flag, name) \
50 nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \
52 return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag)); \
55 NILFS_CPINFO_FNS(SNAPSHOT
, snapshot
)
56 NILFS_CPINFO_FNS(INVALID
, invalid
)
57 NILFS_CPINFO_FNS(MINOR
, minor
)
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
71 /* segment usage flags */
78 #define NILFS_SUINFO_FNS(flag, name) \
80 nilfs_suinfo_##name(const struct nilfs_suinfo *si) \
82 return si->sui_flags & (1UL << NILFS_SUINFO_##flag); \
85 NILFS_SUINFO_FNS(ACTIVE
, active
)
86 NILFS_SUINFO_FNS(DIRTY
, dirty
)
87 NILFS_SUINFO_FNS(ERROR
, error
)
89 static inline int nilfs_suinfo_clean(const struct nilfs_suinfo
*si
)
91 return !si
->sui_flags
;
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
101 struct nilfs_suinfo_update
{
105 struct nilfs_suinfo sup_sui
;
109 NILFS_SUINFO_UPDATE_LASTMOD
,
110 NILFS_SUINFO_UPDATE_NBLOCKS
,
111 NILFS_SUINFO_UPDATE_FLAGS
,
112 __NR_NILFS_SUINFO_UPDATE_FIELDS
,
115 #define NILFS_SUINFO_UPDATE_FNS(flag, name) \
117 nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \
119 sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \
122 nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \
124 sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \
127 nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \
129 return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\
132 NILFS_SUINFO_UPDATE_FNS(LASTMOD
, lastmod
)
133 NILFS_SUINFO_UPDATE_FNS(NBLOCKS
, nblocks
)
134 NILFS_SUINFO_UPDATE_FNS(FLAGS
, flags
)
142 * struct nilfs_cpmode - change checkpoint mode structure
143 * @cm_cno: checkpoint number
144 * @cm_mode: mode of checkpoint
147 struct nilfs_cpmode
{
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
159 * @v_index: start number of target data items
163 __u32 v_nmembs
; /* number of members */
164 __u16 v_size
; /* size of members */
170 * struct nilfs_period - period of checkpoint numbers
171 * @p_start: start checkpoint number (inclusive)
172 * @p_end: end checkpoint number (exclusive)
174 struct nilfs_period
{
180 * struct nilfs_cpstat - checkpoint statistics
181 * @cs_cno: checkpoint number
182 * @cs_ncps: number of checkpoints
183 * @cs_nsss: number of snapshots
185 struct nilfs_cpstat
{
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
200 struct nilfs_sustat
{
205 __u64 ss_nongc_ctime
;
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
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)
238 struct nilfs_period vd_period
;
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
263 #define NILFS_IOCTL_IDENT 'n'
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)
292 #endif /* _LINUX_NILFS2_API_H */