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