The header file "include/linux/nilfs2_fs.h" is composed of parts for ioctl and disk format, and both are intended to be shared with user space programs. This moves them to the uapi directory "include/uapi/linux" splitting the file to "nilfs2_api.h" and "nilfs2_ondisk.h". The following minor changes are accompanied by this migration: - nilfs_direct_node struct in nilfs2/direct.h is converged to nilfs2_ondisk.h because it's an on-disk structure. - inline functions nilfs_rec_len_from_disk() and nilfs_rec_len_to_disk() are moved to nilfs2/dir.c.
Showing the changes to include/uapi/linux (2 of 18 files). Show all
Unified · Split
| @@ -0,0 +1,292 @@ | ||
| 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 */ | |
| @@ -0,0 +1,650 @@ | ||
| 1 | +/* | |
| 2 | + * nilfs2_ondisk.h - NILFS2 on-disk structures | |
| 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 | + * linux/include/linux/ext2_fs.h | |
| 13 | + * | |
| 14 | + * Copyright (C) 1992, 1993, 1994, 1995 | |
| 15 | + * Remy Card (card@masi.ibp.fr) | |
| 16 | + * Laboratoire MASI - Institut Blaise Pascal | |
| 17 | + * Universite Pierre et Marie Curie (Paris VI) | |
| 18 | + * | |
| 19 | + * from | |
| 20 | + * | |
| 21 | + * linux/include/linux/minix_fs.h | |
| 22 | + * | |
| 23 | + * Copyright (C) 1991, 1992 Linus Torvalds | |
| 24 | + */ | |
| 25 | + | |
| 26 | +#ifndef _LINUX_NILFS2_ONDISK_H | |
| 27 | +#define _LINUX_NILFS2_ONDISK_H | |
| 28 | + | |
| 29 | +#include <linux/types.h> | |
| 30 | +#include <linux/magic.h> | |
| 31 | + | |
| 32 | + | |
| 33 | +#define NILFS_INODE_BMAP_SIZE 7 | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * struct nilfs_inode - structure of an inode on disk | |
| 37 | + * @i_blocks: blocks count | |
| 38 | + * @i_size: size in bytes | |
| 39 | + * @i_ctime: creation time (seconds) | |
| 40 | + * @i_mtime: modification time (seconds) | |
| 41 | + * @i_ctime_nsec: creation time (nano seconds) | |
| 42 | + * @i_mtime_nsec: modification time (nano seconds) | |
| 43 | + * @i_uid: user id | |
| 44 | + * @i_gid: group id | |
| 45 | + * @i_mode: file mode | |
| 46 | + * @i_links_count: links count | |
| 47 | + * @i_flags: file flags | |
| 48 | + * @i_bmap: block mapping | |
| 49 | + * @i_xattr: extended attributes | |
| 50 | + * @i_generation: file generation (for NFS) | |
| 51 | + * @i_pad: padding | |
| 52 | + */ | |
| 53 | +struct nilfs_inode { | |
| 54 | + __le64 i_blocks; | |
| 55 | + __le64 i_size; | |
| 56 | + __le64 i_ctime; | |
| 57 | + __le64 i_mtime; | |
| 58 | + __le32 i_ctime_nsec; | |
| 59 | + __le32 i_mtime_nsec; | |
| 60 | + __le32 i_uid; | |
| 61 | + __le32 i_gid; | |
| 62 | + __le16 i_mode; | |
| 63 | + __le16 i_links_count; | |
| 64 | + __le32 i_flags; | |
| 65 | + __le64 i_bmap[NILFS_INODE_BMAP_SIZE]; | |
| 66 | +#define i_device_code i_bmap[0] | |
| 67 | + __le64 i_xattr; | |
| 68 | + __le32 i_generation; | |
| 69 | + __le32 i_pad; | |
| 70 | +}; | |
| 71 | + | |
| 72 | +#define NILFS_MIN_INODE_SIZE 128 | |
| 73 | + | |
| 74 | +/** | |
| 75 | + * struct nilfs_super_root - structure of super root | |
| 76 | + * @sr_sum: check sum | |
| 77 | + * @sr_bytes: byte count of the structure | |
| 78 | + * @sr_flags: flags (reserved) | |
| 79 | + * @sr_nongc_ctime: write time of the last segment not for cleaner operation | |
| 80 | + * @sr_dat: DAT file inode | |
| 81 | + * @sr_cpfile: checkpoint file inode | |
| 82 | + * @sr_sufile: segment usage file inode | |
| 83 | + */ | |
| 84 | +struct nilfs_super_root { | |
| 85 | + __le32 sr_sum; | |
| 86 | + __le16 sr_bytes; | |
| 87 | + __le16 sr_flags; | |
| 88 | + __le64 sr_nongc_ctime; | |
| 89 | + struct nilfs_inode sr_dat; | |
| 90 | + struct nilfs_inode sr_cpfile; | |
| 91 | + struct nilfs_inode sr_sufile; | |
| 92 | +}; | |
| 93 | + | |
| 94 | +#define NILFS_SR_MDT_OFFSET(inode_size, i) \ | |
| 95 | + ((unsigned long)&((struct nilfs_super_root *)0)->sr_dat + \ | |
| 96 | + (inode_size) * (i)) | |
| 97 | +#define NILFS_SR_DAT_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 0) | |
| 98 | +#define NILFS_SR_CPFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 1) | |
| 99 | +#define NILFS_SR_SUFILE_OFFSET(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 2) | |
| 100 | +#define NILFS_SR_BYTES(inode_size) NILFS_SR_MDT_OFFSET(inode_size, 3) | |
| 101 | + | |
| 102 | +/* | |
| 103 | + * Maximal mount counts | |
| 104 | + */ | |
| 105 | +#define NILFS_DFL_MAX_MNT_COUNT 50 /* 50 mounts */ | |
| 106 | + | |
| 107 | +/* | |
| 108 | + * File system states (sbp->s_state, nilfs->ns_mount_state) | |
| 109 | + */ | |
| 110 | +#define NILFS_VALID_FS 0x0001 /* Unmounted cleanly */ | |
| 111 | +#define NILFS_ERROR_FS 0x0002 /* Errors detected */ | |
| 112 | +#define NILFS_RESIZE_FS 0x0004 /* Resize required */ | |
| 113 | + | |
| 114 | +/* | |
| 115 | + * Mount flags (sbi->s_mount_opt) | |
| 116 | + */ | |
| 117 | +#define NILFS_MOUNT_ERROR_MODE 0x0070 /* Error mode mask */ | |
| 118 | +#define NILFS_MOUNT_ERRORS_CONT 0x0010 /* Continue on errors */ | |
| 119 | +#define NILFS_MOUNT_ERRORS_RO 0x0020 /* Remount fs ro on errors */ | |
| 120 | +#define NILFS_MOUNT_ERRORS_PANIC 0x0040 /* Panic on errors */ | |
| 121 | +#define NILFS_MOUNT_BARRIER 0x1000 /* Use block barriers */ | |
| 122 | +#define NILFS_MOUNT_STRICT_ORDER 0x2000 /* | |
| 123 | + * Apply strict in-order | |
| 124 | + * semantics also for data | |
| 125 | + */ | |
| 126 | +#define NILFS_MOUNT_NORECOVERY 0x4000 /* | |
| 127 | + * Disable write access during | |
| 128 | + * mount-time recovery | |
| 129 | + */ | |
| 130 | +#define NILFS_MOUNT_DISCARD 0x8000 /* Issue DISCARD requests */ | |
| 131 | + | |
| 132 | + | |
| 133 | +/** | |
| 134 | + * struct nilfs_super_block - structure of super block on disk | |
| 135 | + */ | |
| 136 | +struct nilfs_super_block { | |
| 137 | +/*00*/ __le32 s_rev_level; /* Revision level */ | |
| 138 | + __le16 s_minor_rev_level; /* minor revision level */ | |
| 139 | + __le16 s_magic; /* Magic signature */ | |
| 140 | + | |
| 141 | + __le16 s_bytes; /* | |
| 142 | + * Bytes count of CRC calculation | |
| 143 | + * for this structure. s_reserved | |
| 144 | + * is excluded. | |
| 145 | + */ | |
| 146 | + __le16 s_flags; /* flags */ | |
| 147 | + __le32 s_crc_seed; /* Seed value of CRC calculation */ | |
| 148 | +/*10*/ __le32 s_sum; /* Check sum of super block */ | |
| 149 | + | |
| 150 | + __le32 s_log_block_size; /* | |
| 151 | + * Block size represented as follows | |
| 152 | + * blocksize = | |
| 153 | + * 1 << (s_log_block_size + 10) | |
| 154 | + */ | |
| 155 | + __le64 s_nsegments; /* Number of segments in filesystem */ | |
| 156 | +/*20*/ __le64 s_dev_size; /* block device size in bytes */ | |
| 157 | + __le64 s_first_data_block; /* 1st seg disk block number */ | |
| 158 | +/*30*/ __le32 s_blocks_per_segment; /* number of blocks per full segment */ | |
| 159 | + __le32 s_r_segments_percentage; /* Reserved segments percentage */ | |
| 160 | + | |
| 161 | + __le64 s_last_cno; /* Last checkpoint number */ | |
| 162 | +/*40*/ __le64 s_last_pseg; /* disk block addr pseg written last */ | |
| 163 | + __le64 s_last_seq; /* seq. number of seg written last */ | |
| 164 | +/*50*/ __le64 s_free_blocks_count; /* Free blocks count */ | |
| 165 | + | |
| 166 | + __le64 s_ctime; /* | |
| 167 | + * Creation time (execution time of | |
| 168 | + * newfs) | |
| 169 | + */ | |
| 170 | +/*60*/ __le64 s_mtime; /* Mount time */ | |
| 171 | + __le64 s_wtime; /* Write time */ | |
| 172 | +/*70*/ __le16 s_mnt_count; /* Mount count */ | |
| 173 | + __le16 s_max_mnt_count; /* Maximal mount count */ | |
| 174 | + __le16 s_state; /* File system state */ | |
| 175 | + __le16 s_errors; /* Behaviour when detecting errors */ | |
| 176 | + __le64 s_lastcheck; /* time of last check */ | |
| 177 | + | |
| 178 | +/*80*/ __le32 s_checkinterval; /* max. time between checks */ | |
| 179 | + __le32 s_creator_os; /* OS */ | |
| 180 | + __le16 s_def_resuid; /* Default uid for reserved blocks */ | |
| 181 | + __le16 s_def_resgid; /* Default gid for reserved blocks */ | |
| 182 | + __le32 s_first_ino; /* First non-reserved inode */ | |
| 183 | + | |
| 184 | +/*90*/ __le16 s_inode_size; /* Size of an inode */ | |
| 185 | + __le16 s_dat_entry_size; /* Size of a dat entry */ | |
| 186 | + __le16 s_checkpoint_size; /* Size of a checkpoint */ | |
| 187 | + __le16 s_segment_usage_size; /* Size of a segment usage */ | |
| 188 | + | |
| 189 | +/*98*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */ | |
| 190 | +/*A8*/ char s_volume_name[80]; /* volume name */ | |
| 191 | + | |
| 192 | +/*F8*/ __le32 s_c_interval; /* Commit interval of segment */ | |
| 193 | + __le32 s_c_block_max; /* | |
| 194 | + * Threshold of data amount for | |
| 195 | + * the segment construction | |
| 196 | + */ | |
| 197 | +/*100*/ __le64 s_feature_compat; /* Compatible feature set */ | |
| 198 | + __le64 s_feature_compat_ro; /* Read-only compatible feature set */ | |
| 199 | + __le64 s_feature_incompat; /* Incompatible feature set */ | |
| 200 | + __u32 s_reserved[186]; /* padding to the end of the block */ | |
| 201 | +}; | |
| 202 | + | |
| 203 | +/* | |
| 204 | + * Codes for operating systems | |
| 205 | + */ | |
| 206 | +#define NILFS_OS_LINUX 0 | |
| 207 | +/* Codes from 1 to 4 are reserved to keep compatibility with ext2 creator-OS */ | |
| 208 | + | |
| 209 | +/* | |
| 210 | + * Revision levels | |
| 211 | + */ | |
| 212 | +#define NILFS_CURRENT_REV 2 /* current major revision */ | |
| 213 | +#define NILFS_MINOR_REV 0 /* minor revision */ | |
| 214 | +#define NILFS_MIN_SUPP_REV 2 /* minimum supported revision */ | |
| 215 | + | |
| 216 | +/* | |
| 217 | + * Feature set definitions | |
| 218 | + * | |
| 219 | + * If there is a bit set in the incompatible feature set that the kernel | |
| 220 | + * doesn't know about, it should refuse to mount the filesystem. | |
| 221 | + */ | |
| 222 | +#define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT 0x00000001ULL | |
| 223 | + | |
| 224 | +#define NILFS_FEATURE_COMPAT_SUPP 0ULL | |
| 225 | +#define NILFS_FEATURE_COMPAT_RO_SUPP NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT | |
| 226 | +#define NILFS_FEATURE_INCOMPAT_SUPP 0ULL | |
| 227 | + | |
| 228 | +/* | |
| 229 | + * Bytes count of super_block for CRC-calculation | |
| 230 | + */ | |
| 231 | +#define NILFS_SB_BYTES \ | |
| 232 | + ((long)&((struct nilfs_super_block *)0)->s_reserved) | |
| 233 | + | |
| 234 | +/* | |
| 235 | + * Special inode number | |
| 236 | + */ | |
| 237 | +#define NILFS_ROOT_INO 2 /* Root file inode */ | |
| 238 | +#define NILFS_DAT_INO 3 /* DAT file */ | |
| 239 | +#define NILFS_CPFILE_INO 4 /* checkpoint file */ | |
| 240 | +#define NILFS_SUFILE_INO 5 /* segment usage file */ | |
| 241 | +#define NILFS_IFILE_INO 6 /* ifile */ | |
| 242 | +#define NILFS_ATIME_INO 7 /* Atime file (reserved) */ | |
| 243 | +#define NILFS_XATTR_INO 8 /* Xattribute file (reserved) */ | |
| 244 | +#define NILFS_SKETCH_INO 10 /* Sketch file */ | |
| 245 | +#define NILFS_USER_INO 11 /* Fisrt user's file inode number */ | |
| 246 | + | |
| 247 | +#define NILFS_SB_OFFSET_BYTES 1024 /* byte offset of nilfs superblock */ | |
| 248 | + | |
| 249 | +#define NILFS_SEG_MIN_BLOCKS 16 /* | |
| 250 | + * Minimum number of blocks in | |
| 251 | + * a full segment | |
| 252 | + */ | |
| 253 | +#define NILFS_PSEG_MIN_BLOCKS 2 /* | |
| 254 | + * Minimum number of blocks in | |
| 255 | + * a partial segment | |
| 256 | + */ | |
| 257 | +#define NILFS_MIN_NRSVSEGS 8 /* | |
| 258 | + * Minimum number of reserved | |
| 259 | + * segments | |
| 260 | + */ | |
| 261 | + | |
| 262 | +/* | |
| 263 | + * We call DAT, cpfile, and sufile root metadata files. Inodes of | |
| 264 | + * these files are written in super root block instead of ifile, and | |
| 265 | + * garbage collector doesn't keep any past versions of these files. | |
| 266 | + */ | |
| 267 | +#define NILFS_ROOT_METADATA_FILE(ino) \ | |
| 268 | + ((ino) >= NILFS_DAT_INO && (ino) <= NILFS_SUFILE_INO) | |
| 269 | + | |
| 270 | +/* | |
| 271 | + * bytes offset of secondary super block | |
| 272 | + */ | |
| 273 | +#define NILFS_SB2_OFFSET_BYTES(devsize) ((((devsize) >> 12) - 1) << 12) | |
| 274 | + | |
| 275 | +/* | |
| 276 | + * Maximal count of links to a file | |
| 277 | + */ | |
| 278 | +#define NILFS_LINK_MAX 32000 | |
| 279 | + | |
| 280 | +/* | |
| 281 | + * Structure of a directory entry | |
| 282 | + * (Same as ext2) | |
| 283 | + */ | |
| 284 | + | |
| 285 | +#define NILFS_NAME_LEN 255 | |
| 286 | + | |
| 287 | +/* | |
| 288 | + * Block size limitations | |
| 289 | + */ | |
| 290 | +#define NILFS_MIN_BLOCK_SIZE 1024 | |
| 291 | +#define NILFS_MAX_BLOCK_SIZE 65536 | |
| 292 | + | |
| 293 | +/* | |
| 294 | + * The new version of the directory entry. Since V0 structures are | |
| 295 | + * stored in intel byte order, and the name_len field could never be | |
| 296 | + * bigger than 255 chars, it's safe to reclaim the extra byte for the | |
| 297 | + * file_type field. | |
| 298 | + */ | |
| 299 | +struct nilfs_dir_entry { | |
| 300 | + __le64 inode; /* Inode number */ | |
| 301 | + __le16 rec_len; /* Directory entry length */ | |
| 302 | + __u8 name_len; /* Name length */ | |
| 303 | + __u8 file_type; /* Dir entry type (file, dir, etc) */ | |
| 304 | + char name[NILFS_NAME_LEN]; /* File name */ | |
| 305 | + char pad; | |
| 306 | +}; | |
| 307 | + | |
| 308 | +/* | |
| 309 | + * NILFS directory file types. Only the low 3 bits are used. The | |
| 310 | + * other bits are reserved for now. | |
| 311 | + */ | |
| 312 | +enum { | |
| 313 | + NILFS_FT_UNKNOWN, | |
| 314 | + NILFS_FT_REG_FILE, | |
| 315 | + NILFS_FT_DIR, | |
| 316 | + NILFS_FT_CHRDEV, | |
| 317 | + NILFS_FT_BLKDEV, | |
| 318 | + NILFS_FT_FIFO, | |
| 319 | + NILFS_FT_SOCK, | |
| 320 | + NILFS_FT_SYMLINK, | |
| 321 | + NILFS_FT_MAX | |
| 322 | +}; | |
| 323 | + | |
| 324 | +/* | |
| 325 | + * NILFS_DIR_PAD defines the directory entries boundaries | |
| 326 | + * | |
| 327 | + * NOTE: It must be a multiple of 8 | |
| 328 | + */ | |
| 329 | +#define NILFS_DIR_PAD 8 | |
| 330 | +#define NILFS_DIR_ROUND (NILFS_DIR_PAD - 1) | |
| 331 | +#define NILFS_DIR_REC_LEN(name_len) (((name_len) + 12 + NILFS_DIR_ROUND) & \ | |
| 332 | + ~NILFS_DIR_ROUND) | |
| 333 | +#define NILFS_MAX_REC_LEN ((1 << 16) - 1) | |
| 334 | + | |
| 335 | +/** | |
| 336 | + * struct nilfs_finfo - file information | |
| 337 | + * @fi_ino: inode number | |
| 338 | + * @fi_cno: checkpoint number | |
| 339 | + * @fi_nblocks: number of blocks (including intermediate blocks) | |
| 340 | + * @fi_ndatablk: number of file data blocks | |
| 341 | + */ | |
| 342 | +struct nilfs_finfo { | |
| 343 | + __le64 fi_ino; | |
| 344 | + __le64 fi_cno; | |
| 345 | + __le32 fi_nblocks; | |
| 346 | + __le32 fi_ndatablk; | |
| 347 | +}; | |
| 348 | + | |
| 349 | +/** | |
| 350 | + * struct nilfs_binfo_v - information on a data block (except DAT) | |
| 351 | + * @bi_vblocknr: virtual block number | |
| 352 | + * @bi_blkoff: block offset | |
| 353 | + */ | |
| 354 | +struct nilfs_binfo_v { | |
| 355 | + __le64 bi_vblocknr; | |
| 356 | + __le64 bi_blkoff; | |
| 357 | +}; | |
| 358 | + | |
| 359 | +/** | |
| 360 | + * struct nilfs_binfo_dat - information on a DAT node block | |
| 361 | + * @bi_blkoff: block offset | |
| 362 | + * @bi_level: level | |
| 363 | + * @bi_pad: padding | |
| 364 | + */ | |
| 365 | +struct nilfs_binfo_dat { | |
| 366 | + __le64 bi_blkoff; | |
| 367 | + __u8 bi_level; | |
| 368 | + __u8 bi_pad[7]; | |
| 369 | +}; | |
| 370 | + | |
| 371 | +/** | |
| 372 | + * union nilfs_binfo: block information | |
| 373 | + * @bi_v: nilfs_binfo_v structure | |
| 374 | + * @bi_dat: nilfs_binfo_dat structure | |
| 375 | + */ | |
| 376 | +union nilfs_binfo { | |
| 377 | + struct nilfs_binfo_v bi_v; | |
| 378 | + struct nilfs_binfo_dat bi_dat; | |
| 379 | +}; | |
| 380 | + | |
| 381 | +/** | |
| 382 | + * struct nilfs_segment_summary - segment summary header | |
| 383 | + * @ss_datasum: checksum of data | |
| 384 | + * @ss_sumsum: checksum of segment summary | |
| 385 | + * @ss_magic: magic number | |
| 386 | + * @ss_bytes: size of this structure in bytes | |
| 387 | + * @ss_flags: flags | |
| 388 | + * @ss_seq: sequence number | |
| 389 | + * @ss_create: creation timestamp | |
| 390 | + * @ss_next: next segment | |
| 391 | + * @ss_nblocks: number of blocks | |
| 392 | + * @ss_nfinfo: number of finfo structures | |
| 393 | + * @ss_sumbytes: total size of segment summary in bytes | |
| 394 | + * @ss_pad: padding | |
| 395 | + * @ss_cno: checkpoint number | |
| 396 | + */ | |
| 397 | +struct nilfs_segment_summary { | |
| 398 | + __le32 ss_datasum; | |
| 399 | + __le32 ss_sumsum; | |
| 400 | + __le32 ss_magic; | |
| 401 | + __le16 ss_bytes; | |
| 402 | + __le16 ss_flags; | |
| 403 | + __le64 ss_seq; | |
| 404 | + __le64 ss_create; | |
| 405 | + __le64 ss_next; | |
| 406 | + __le32 ss_nblocks; | |
| 407 | + __le32 ss_nfinfo; | |
| 408 | + __le32 ss_sumbytes; | |
| 409 | + __le32 ss_pad; | |
| 410 | + __le64 ss_cno; | |
| 411 | + /* array of finfo structures */ | |
| 412 | +}; | |
| 413 | + | |
| 414 | +#define NILFS_SEGSUM_MAGIC 0x1eaffa11 /* segment summary magic number */ | |
| 415 | + | |
| 416 | +/* | |
| 417 | + * Segment summary flags | |
| 418 | + */ | |
| 419 | +#define NILFS_SS_LOGBGN 0x0001 /* begins a logical segment */ | |
| 420 | +#define NILFS_SS_LOGEND 0x0002 /* ends a logical segment */ | |
| 421 | +#define NILFS_SS_SR 0x0004 /* has super root */ | |
| 422 | +#define NILFS_SS_SYNDT 0x0008 /* includes data only updates */ | |
| 423 | +#define NILFS_SS_GC 0x0010 /* segment written for cleaner operation */ | |
| 424 | + | |
| 425 | +/** | |
| 426 | + * struct nilfs_btree_node - header of B-tree node block | |
| 427 | + * @bn_flags: flags | |
| 428 | + * @bn_level: level | |
| 429 | + * @bn_nchildren: number of children | |
| 430 | + * @bn_pad: padding | |
| 431 | + */ | |
| 432 | +struct nilfs_btree_node { | |
| 433 | + __u8 bn_flags; | |
| 434 | + __u8 bn_level; | |
| 435 | + __le16 bn_nchildren; | |
| 436 | + __le32 bn_pad; | |
| 437 | +}; | |
| 438 | + | |
| 439 | +/* flags */ | |
| 440 | +#define NILFS_BTREE_NODE_ROOT 0x01 | |
| 441 | + | |
| 442 | +/* level */ | |
| 443 | +#define NILFS_BTREE_LEVEL_DATA 0 | |
| 444 | +#define NILFS_BTREE_LEVEL_NODE_MIN (NILFS_BTREE_LEVEL_DATA + 1) | |
| 445 | +#define NILFS_BTREE_LEVEL_MAX 14 /* Max level (exclusive) */ | |
| 446 | + | |
| 447 | +/** | |
| 448 | + * struct nilfs_direct_node - header of built-in bmap array | |
| 449 | + * @dn_flags: flags | |
| 450 | + * @dn_pad: padding | |
| 451 | + */ | |
| 452 | +struct nilfs_direct_node { | |
| 453 | + __u8 dn_flags; | |
| 454 | + __u8 pad[7]; | |
| 455 | +}; | |
| 456 | + | |
| 457 | +/** | |
| 458 | + * struct nilfs_palloc_group_desc - block group descriptor | |
| 459 | + * @pg_nfrees: number of free entries in block group | |
| 460 | + */ | |
| 461 | +struct nilfs_palloc_group_desc { | |
| 462 | + __le32 pg_nfrees; | |
| 463 | +}; | |
| 464 | + | |
| 465 | +/** | |
| 466 | + * struct nilfs_dat_entry - disk address translation entry | |
| 467 | + * @de_blocknr: block number | |
| 468 | + * @de_start: start checkpoint number | |
| 469 | + * @de_end: end checkpoint number | |
| 470 | + * @de_rsv: reserved for future use | |
| 471 | + */ | |
| 472 | +struct nilfs_dat_entry { | |
| 473 | + __le64 de_blocknr; | |
| 474 | + __le64 de_start; | |
| 475 | + __le64 de_end; | |
| 476 | + __le64 de_rsv; | |
| 477 | +}; | |
| 478 | + | |
| 479 | +#define NILFS_MIN_DAT_ENTRY_SIZE 32 | |
| 480 | + | |
| 481 | +/** | |
| 482 | + * struct nilfs_snapshot_list - snapshot list | |
| 483 | + * @ssl_next: next checkpoint number on snapshot list | |
| 484 | + * @ssl_prev: previous checkpoint number on snapshot list | |
| 485 | + */ | |
| 486 | +struct nilfs_snapshot_list { | |
| 487 | + __le64 ssl_next; | |
| 488 | + __le64 ssl_prev; | |
| 489 | +}; | |
| 490 | + | |
| 491 | +/** | |
| 492 | + * struct nilfs_checkpoint - checkpoint structure | |
| 493 | + * @cp_flags: flags | |
| 494 | + * @cp_checkpoints_count: checkpoints count in a block | |
| 495 | + * @cp_snapshot_list: snapshot list | |
| 496 | + * @cp_cno: checkpoint number | |
| 497 | + * @cp_create: creation timestamp | |
| 498 | + * @cp_nblk_inc: number of blocks incremented by this checkpoint | |
| 499 | + * @cp_inodes_count: inodes count | |
| 500 | + * @cp_blocks_count: blocks count | |
| 501 | + * @cp_ifile_inode: inode of ifile | |
| 502 | + */ | |
| 503 | +struct nilfs_checkpoint { | |
| 504 | + __le32 cp_flags; | |
| 505 | + __le32 cp_checkpoints_count; | |
| 506 | + struct nilfs_snapshot_list cp_snapshot_list; | |
| 507 | + __le64 cp_cno; | |
| 508 | + __le64 cp_create; | |
| 509 | + __le64 cp_nblk_inc; | |
| 510 | + __le64 cp_inodes_count; | |
| 511 | + __le64 cp_blocks_count; | |
| 512 | + | |
| 513 | + /* | |
| 514 | + * Do not change the byte offset of ifile inode. | |
| 515 | + * To keep the compatibility of the disk format, | |
| 516 | + * additional fields should be added behind cp_ifile_inode. | |
| 517 | + */ | |
| 518 | + struct nilfs_inode cp_ifile_inode; | |
| 519 | +}; | |
| 520 | + | |
| 521 | +#define NILFS_MIN_CHECKPOINT_SIZE (64 + NILFS_MIN_INODE_SIZE) | |
| 522 | + | |
| 523 | +/* checkpoint flags */ | |
| 524 | +enum { | |
| 525 | + NILFS_CHECKPOINT_SNAPSHOT, | |
| 526 | + NILFS_CHECKPOINT_INVALID, | |
| 527 | + NILFS_CHECKPOINT_SKETCH, | |
| 528 | + NILFS_CHECKPOINT_MINOR, | |
| 529 | +}; | |
| 530 | + | |
| 531 | +#define NILFS_CHECKPOINT_FNS(flag, name) \ | |
| 532 | +static inline void \ | |
| 533 | +nilfs_checkpoint_set_##name(struct nilfs_checkpoint *cp) \ | |
| 534 | +{ \ | |
| 535 | + cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) | \ | |
| 536 | + (1UL << NILFS_CHECKPOINT_##flag)); \ | |
| 537 | +} \ | |
| 538 | +static inline void \ | |
| 539 | +nilfs_checkpoint_clear_##name(struct nilfs_checkpoint *cp) \ | |
| 540 | +{ \ | |
| 541 | + cp->cp_flags = cpu_to_le32(le32_to_cpu(cp->cp_flags) & \ | |
| 542 | + ~(1UL << NILFS_CHECKPOINT_##flag)); \ | |
| 543 | +} \ | |
| 544 | +static inline int \ | |
| 545 | +nilfs_checkpoint_##name(const struct nilfs_checkpoint *cp) \ | |
| 546 | +{ \ | |
| 547 | + return !!(le32_to_cpu(cp->cp_flags) & \ | |
| 548 | + (1UL << NILFS_CHECKPOINT_##flag)); \ | |
| 549 | +} | |
| 550 | + | |
| 551 | +NILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot) | |
| 552 | +NILFS_CHECKPOINT_FNS(INVALID, invalid) | |
| 553 | +NILFS_CHECKPOINT_FNS(MINOR, minor) | |
| 554 | + | |
| 555 | +/** | |
| 556 | + * struct nilfs_cpfile_header - checkpoint file header | |
| 557 | + * @ch_ncheckpoints: number of checkpoints | |
| 558 | + * @ch_nsnapshots: number of snapshots | |
| 559 | + * @ch_snapshot_list: snapshot list | |
| 560 | + */ | |
| 561 | +struct nilfs_cpfile_header { | |
| 562 | + __le64 ch_ncheckpoints; | |
| 563 | + __le64 ch_nsnapshots; | |
| 564 | + struct nilfs_snapshot_list ch_snapshot_list; | |
| 565 | +}; | |
| 566 | + | |
| 567 | +#define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET \ | |
| 568 | + ((sizeof(struct nilfs_cpfile_header) + \ | |
| 569 | + sizeof(struct nilfs_checkpoint) - 1) / \ | |
| 570 | + sizeof(struct nilfs_checkpoint)) | |
| 571 | + | |
| 572 | +/** | |
| 573 | + * struct nilfs_segment_usage - segment usage | |
| 574 | + * @su_lastmod: last modified timestamp | |
| 575 | + * @su_nblocks: number of blocks in segment | |
| 576 | + * @su_flags: flags | |
| 577 | + */ | |
| 578 | +struct nilfs_segment_usage { | |
| 579 | + __le64 su_lastmod; | |
| 580 | + __le32 su_nblocks; | |
| 581 | + __le32 su_flags; | |
| 582 | +}; | |
| 583 | + | |
| 584 | +#define NILFS_MIN_SEGMENT_USAGE_SIZE 16 | |
| 585 | + | |
| 586 | +/* segment usage flag */ | |
| 587 | +enum { | |
| 588 | + NILFS_SEGMENT_USAGE_ACTIVE, | |
| 589 | + NILFS_SEGMENT_USAGE_DIRTY, | |
| 590 | + NILFS_SEGMENT_USAGE_ERROR, | |
| 591 | +}; | |
| 592 | + | |
| 593 | +#define NILFS_SEGMENT_USAGE_FNS(flag, name) \ | |
| 594 | +static inline void \ | |
| 595 | +nilfs_segment_usage_set_##name(struct nilfs_segment_usage *su) \ | |
| 596 | +{ \ | |
| 597 | + su->su_flags = cpu_to_le32(le32_to_cpu(su->su_flags) | \ | |
| 598 | + (1UL << NILFS_SEGMENT_USAGE_##flag));\ | |
| 599 | +} \ | |
| 600 | +static inline void \ | |
| 601 | +nilfs_segment_usage_clear_##name(struct nilfs_segment_usage *su) \ | |
| 602 | +{ \ | |
| 603 | + su->su_flags = \ | |
| 604 | + cpu_to_le32(le32_to_cpu(su->su_flags) & \ | |
| 605 | + ~(1UL << NILFS_SEGMENT_USAGE_##flag)); \ | |
| 606 | +} \ | |
| 607 | +static inline int \ | |
| 608 | +nilfs_segment_usage_##name(const struct nilfs_segment_usage *su) \ | |
| 609 | +{ \ | |
| 610 | + return !!(le32_to_cpu(su->su_flags) & \ | |
| 611 | + (1UL << NILFS_SEGMENT_USAGE_##flag)); \ | |
| 612 | +} | |
| 613 | + | |
| 614 | +NILFS_SEGMENT_USAGE_FNS(ACTIVE, active) | |
| 615 | +NILFS_SEGMENT_USAGE_FNS(DIRTY, dirty) | |
| 616 | +NILFS_SEGMENT_USAGE_FNS(ERROR, error) | |
| 617 | + | |
| 618 | +static inline void | |
| 619 | +nilfs_segment_usage_set_clean(struct nilfs_segment_usage *su) | |
| 620 | +{ | |
| 621 | + su->su_lastmod = cpu_to_le64(0); | |
| 622 | + su->su_nblocks = cpu_to_le32(0); | |
| 623 | + su->su_flags = cpu_to_le32(0); | |
| 624 | +} | |
| 625 | + | |
| 626 | +static inline int | |
| 627 | +nilfs_segment_usage_clean(const struct nilfs_segment_usage *su) | |
| 628 | +{ | |
| 629 | + return !le32_to_cpu(su->su_flags); | |
| 630 | +} | |
| 631 | + | |
| 632 | +/** | |
| 633 | + * struct nilfs_sufile_header - segment usage file header | |
| 634 | + * @sh_ncleansegs: number of clean segments | |
| 635 | + * @sh_ndirtysegs: number of dirty segments | |
| 636 | + * @sh_last_alloc: last allocated segment number | |
| 637 | + */ | |
| 638 | +struct nilfs_sufile_header { | |
| 639 | + __le64 sh_ncleansegs; | |
| 640 | + __le64 sh_ndirtysegs; | |
| 641 | + __le64 sh_last_alloc; | |
| 642 | + /* ... */ | |
| 643 | +}; | |
| 644 | + | |
| 645 | +#define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET \ | |
| 646 | + ((sizeof(struct nilfs_sufile_header) + \ | |
| 647 | + sizeof(struct nilfs_segment_usage) - 1) / \ | |
| 648 | + sizeof(struct nilfs_segment_usage)) | |
| 649 | + | |
| 650 | +#endif /* _LINUX_NILFS2_ONDISK_H */ | |