1 /* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */
3 * nilfs2_api.h - NILFS2 user space API
5 * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation.
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.
13 #ifndef _LINUX_NILFS2_API_H
14 #define _LINUX_NILFS2_API_H
16 #include <linux/types.h>
17 #include <linux/ioctl.h>
20 * struct nilfs_cpinfo - checkpoint information
23 * @ci_cno: checkpoint number
24 * @ci_create: creation timestamp
25 * @ci_nblk_inc: number of blocks incremented by this checkpoint
26 * @ci_inodes_count: inodes count
27 * @ci_blocks_count: blocks count
28 * @ci_next: next checkpoint number in snapshot list
36 __u64 ci_inodes_count;
37 __u64 ci_blocks_count;
41 /* checkpoint flags */
43 NILFS_CPINFO_SNAPSHOT,
49 #define NILFS_CPINFO_FNS(flag, name) \
51 nilfs_cpinfo_##name(const struct nilfs_cpinfo *cpinfo) \
53 return !!(cpinfo->ci_flags & (1UL << NILFS_CPINFO_##flag)); \
56 NILFS_CPINFO_FNS(SNAPSHOT, snapshot)
57 NILFS_CPINFO_FNS(INVALID, invalid)
58 NILFS_CPINFO_FNS(MINOR, minor)
61 * nilfs_suinfo - segment usage information
62 * @sui_lastmod: timestamp of last modification
63 * @sui_nblocks: number of written blocks in segment
64 * @sui_flags: segment usage flags
72 /* segment usage flags */
79 #define NILFS_SUINFO_FNS(flag, name) \
81 nilfs_suinfo_##name(const struct nilfs_suinfo *si) \
83 return si->sui_flags & (1UL << NILFS_SUINFO_##flag); \
86 NILFS_SUINFO_FNS(ACTIVE, active)
87 NILFS_SUINFO_FNS(DIRTY, dirty)
88 NILFS_SUINFO_FNS(ERROR, error)
90 static inline int nilfs_suinfo_clean(const struct nilfs_suinfo *si)
92 return !si->sui_flags;
96 * nilfs_suinfo_update - segment usage information update
97 * @sup_segnum: segment number
98 * @sup_flags: flags for which fields are active in sup_sui
99 * @sup_reserved: reserved necessary for alignment
100 * @sup_sui: segment usage information
102 struct nilfs_suinfo_update {
106 struct nilfs_suinfo sup_sui;
110 NILFS_SUINFO_UPDATE_LASTMOD,
111 NILFS_SUINFO_UPDATE_NBLOCKS,
112 NILFS_SUINFO_UPDATE_FLAGS,
113 __NR_NILFS_SUINFO_UPDATE_FIELDS,
116 #define NILFS_SUINFO_UPDATE_FNS(flag, name) \
118 nilfs_suinfo_update_set_##name(struct nilfs_suinfo_update *sup) \
120 sup->sup_flags |= 1UL << NILFS_SUINFO_UPDATE_##flag; \
123 nilfs_suinfo_update_clear_##name(struct nilfs_suinfo_update *sup) \
125 sup->sup_flags &= ~(1UL << NILFS_SUINFO_UPDATE_##flag); \
128 nilfs_suinfo_update_##name(const struct nilfs_suinfo_update *sup) \
130 return !!(sup->sup_flags & (1UL << NILFS_SUINFO_UPDATE_##flag));\
133 NILFS_SUINFO_UPDATE_FNS(LASTMOD, lastmod)
134 NILFS_SUINFO_UPDATE_FNS(NBLOCKS, nblocks)
135 NILFS_SUINFO_UPDATE_FNS(FLAGS, flags)
143 * struct nilfs_cpmode - change checkpoint mode structure
144 * @cm_cno: checkpoint number
145 * @cm_mode: mode of checkpoint
148 struct nilfs_cpmode {
155 * struct nilfs_argv - argument vector
156 * @v_base: pointer on data array from userspace
157 * @v_nmembs: number of members in data array
158 * @v_size: size of data array in bytes
160 * @v_index: start number of target data items
164 __u32 v_nmembs; /* number of members */
165 __u16 v_size; /* size of members */
171 * struct nilfs_period - period of checkpoint numbers
172 * @p_start: start checkpoint number (inclusive)
173 * @p_end: end checkpoint number (exclusive)
175 struct nilfs_period {
181 * struct nilfs_cpstat - checkpoint statistics
182 * @cs_cno: checkpoint number
183 * @cs_ncps: number of checkpoints
184 * @cs_nsss: number of snapshots
186 struct nilfs_cpstat {
193 * struct nilfs_sustat - segment usage statistics
194 * @ss_nsegs: number of segments
195 * @ss_ncleansegs: number of clean segments
196 * @ss_ndirtysegs: number of dirty segments
197 * @ss_ctime: creation time of the last segment
198 * @ss_nongc_ctime: creation time of the last segment not for GC
199 * @ss_prot_seq: least sequence number of segments which must not be reclaimed
201 struct nilfs_sustat {
206 __u64 ss_nongc_ctime;
211 * struct nilfs_vinfo - virtual block number information
212 * @vi_vblocknr: virtual block number
213 * @vi_start: start checkpoint number (inclusive)
214 * @vi_end: end checkpoint number (exclusive)
215 * @vi_blocknr: disk block number
225 * struct nilfs_vdesc - descriptor of virtual block number
226 * @vd_ino: inode number
227 * @vd_cno: checkpoint number
228 * @vd_vblocknr: virtual block number
229 * @vd_period: period of checkpoint numbers
230 * @vd_blocknr: disk block number
231 * @vd_offset: logical block offset inside a file
232 * @vd_flags: flags (data or node block)
239 struct nilfs_period vd_period;
247 * struct nilfs_bdesc - descriptor of disk block number
248 * @bd_ino: inode number
249 * @bd_oblocknr: disk block address (for skipping dead blocks)
250 * @bd_blocknr: disk block address
251 * @bd_offset: logical block offset inside a file
252 * @bd_level: level in the b-tree organization
264 #define NILFS_IOCTL_IDENT 'n'
266 #define NILFS_IOCTL_CHANGE_CPMODE \
267 _IOW(NILFS_IOCTL_IDENT, 0x80, struct nilfs_cpmode)
268 #define NILFS_IOCTL_DELETE_CHECKPOINT \
269 _IOW(NILFS_IOCTL_IDENT, 0x81, __u64)
270 #define NILFS_IOCTL_GET_CPINFO \
271 _IOR(NILFS_IOCTL_IDENT, 0x82, struct nilfs_argv)
272 #define NILFS_IOCTL_GET_CPSTAT \
273 _IOR(NILFS_IOCTL_IDENT, 0x83, struct nilfs_cpstat)
274 #define NILFS_IOCTL_GET_SUINFO \
275 _IOR(NILFS_IOCTL_IDENT, 0x84, struct nilfs_argv)
276 #define NILFS_IOCTL_GET_SUSTAT \
277 _IOR(NILFS_IOCTL_IDENT, 0x85, struct nilfs_sustat)
278 #define NILFS_IOCTL_GET_VINFO \
279 _IOWR(NILFS_IOCTL_IDENT, 0x86, struct nilfs_argv)
280 #define NILFS_IOCTL_GET_BDESCS \
281 _IOWR(NILFS_IOCTL_IDENT, 0x87, struct nilfs_argv)
282 #define NILFS_IOCTL_CLEAN_SEGMENTS \
283 _IOW(NILFS_IOCTL_IDENT, 0x88, struct nilfs_argv[5])
284 #define NILFS_IOCTL_SYNC \
285 _IOR(NILFS_IOCTL_IDENT, 0x8A, __u64)
286 #define NILFS_IOCTL_RESIZE \
287 _IOW(NILFS_IOCTL_IDENT, 0x8B, __u64)
288 #define NILFS_IOCTL_SET_ALLOC_RANGE \
289 _IOW(NILFS_IOCTL_IDENT, 0x8C, __u64[2])
290 #define NILFS_IOCTL_SET_SUINFO \
291 _IOW(NILFS_IOCTL_IDENT, 0x8D, struct nilfs_argv)
293 #endif /* _LINUX_NILFS2_API_H */