/* SPDX-License-Identifier: LGPL-2.1+ WITH Linux-syscall-note */ /* * nilfs2_ondisk.h - NILFS2 on-disk structures * * Copyright (C) 2005-2008 Nippon Telegraph and Telephone Corporation. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. */ /* * linux/include/linux/ext2_fs.h * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card ([email protected]) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * * from * * linux/include/linux/minix_fs.h * * Copyright (C) 1991, 1992 Linus Torvalds */ #ifndef _LINUX_NILFS2_ONDISK_H #define _LINUX_NILFS2_ONDISK_H #include <linux/types.h> #include <linux/magic.h> #include <asm/byteorder.h> #define NILFS_INODE_BMAP_SIZE … /** * struct nilfs_inode - structure of an inode on disk * @i_blocks: blocks count * @i_size: size in bytes * @i_ctime: creation time (seconds) * @i_mtime: modification time (seconds) * @i_ctime_nsec: creation time (nano seconds) * @i_mtime_nsec: modification time (nano seconds) * @i_uid: user id * @i_gid: group id * @i_mode: file mode * @i_links_count: links count * @i_flags: file flags * @i_bmap: block mapping * @i_xattr: extended attributes * @i_generation: file generation (for NFS) * @i_pad: padding */ struct nilfs_inode { … }; #define NILFS_MIN_INODE_SIZE … /** * struct nilfs_super_root - structure of super root * @sr_sum: check sum * @sr_bytes: byte count of the structure * @sr_flags: flags (reserved) * @sr_nongc_ctime: write time of the last segment not for cleaner operation * @sr_dat: DAT file inode * @sr_cpfile: checkpoint file inode * @sr_sufile: segment usage file inode */ struct nilfs_super_root { … }; #define NILFS_SR_MDT_OFFSET(inode_size, i) … #define NILFS_SR_DAT_OFFSET(inode_size) … #define NILFS_SR_CPFILE_OFFSET(inode_size) … #define NILFS_SR_SUFILE_OFFSET(inode_size) … #define NILFS_SR_BYTES(inode_size) … /* * Maximal mount counts */ #define NILFS_DFL_MAX_MNT_COUNT … /* * File system states (sbp->s_state, nilfs->ns_mount_state) */ #define NILFS_VALID_FS … #define NILFS_ERROR_FS … #define NILFS_RESIZE_FS … /* * Mount flags (sbi->s_mount_opt) */ #define NILFS_MOUNT_ERROR_MODE … #define NILFS_MOUNT_ERRORS_CONT … #define NILFS_MOUNT_ERRORS_RO … #define NILFS_MOUNT_ERRORS_PANIC … #define NILFS_MOUNT_BARRIER … #define NILFS_MOUNT_STRICT_ORDER … #define NILFS_MOUNT_NORECOVERY … #define NILFS_MOUNT_DISCARD … /** * struct nilfs_super_block - structure of super block on disk */ struct nilfs_super_block { … }; /* * Codes for operating systems */ #define NILFS_OS_LINUX … /* Codes from 1 to 4 are reserved to keep compatibility with ext2 creator-OS */ /* * Revision levels */ #define NILFS_CURRENT_REV … #define NILFS_MINOR_REV … #define NILFS_MIN_SUPP_REV … /* * Feature set definitions * * If there is a bit set in the incompatible feature set that the kernel * doesn't know about, it should refuse to mount the filesystem. */ #define NILFS_FEATURE_COMPAT_RO_BLOCK_COUNT … #define NILFS_FEATURE_COMPAT_SUPP … #define NILFS_FEATURE_COMPAT_RO_SUPP … #define NILFS_FEATURE_INCOMPAT_SUPP … /* * Bytes count of super_block for CRC-calculation */ #define NILFS_SB_BYTES … /* * Special inode number */ #define NILFS_ROOT_INO … #define NILFS_DAT_INO … #define NILFS_CPFILE_INO … #define NILFS_SUFILE_INO … #define NILFS_IFILE_INO … #define NILFS_ATIME_INO … #define NILFS_XATTR_INO … #define NILFS_SKETCH_INO … #define NILFS_USER_INO … #define NILFS_SB_OFFSET_BYTES … #define NILFS_SEG_MIN_BLOCKS … #define NILFS_PSEG_MIN_BLOCKS … #define NILFS_MIN_NRSVSEGS … /* * We call DAT, cpfile, and sufile root metadata files. Inodes of * these files are written in super root block instead of ifile, and * garbage collector doesn't keep any past versions of these files. */ #define NILFS_ROOT_METADATA_FILE(ino) … /* * bytes offset of secondary super block */ #define NILFS_SB2_OFFSET_BYTES(devsize) … /* * Maximal count of links to a file */ #define NILFS_LINK_MAX … /* * Structure of a directory entry * (Same as ext2) */ #define NILFS_NAME_LEN … /* * Block size limitations */ #define NILFS_MIN_BLOCK_SIZE … #define NILFS_MAX_BLOCK_SIZE … /* * The new version of the directory entry. Since V0 structures are * stored in intel byte order, and the name_len field could never be * bigger than 255 chars, it's safe to reclaim the extra byte for the * file_type field. */ struct nilfs_dir_entry { … }; /* * NILFS directory file types. Only the low 3 bits are used. The * other bits are reserved for now. */ enum { … }; /* * NILFS_DIR_PAD defines the directory entries boundaries * * NOTE: It must be a multiple of 8 */ #define NILFS_DIR_PAD … #define NILFS_DIR_ROUND … #define NILFS_DIR_REC_LEN(name_len) … #define NILFS_MAX_REC_LEN … /** * struct nilfs_finfo - file information * @fi_ino: inode number * @fi_cno: checkpoint number * @fi_nblocks: number of blocks (including intermediate blocks) * @fi_ndatablk: number of file data blocks */ struct nilfs_finfo { … }; /** * struct nilfs_binfo_v - information on a data block (except DAT) * @bi_vblocknr: virtual block number * @bi_blkoff: block offset */ struct nilfs_binfo_v { … }; /** * struct nilfs_binfo_dat - information on a DAT node block * @bi_blkoff: block offset * @bi_level: level * @bi_pad: padding */ struct nilfs_binfo_dat { … }; /** * union nilfs_binfo: block information * @bi_v: nilfs_binfo_v structure * @bi_dat: nilfs_binfo_dat structure */ nilfs_binfo; /** * struct nilfs_segment_summary - segment summary header * @ss_datasum: checksum of data * @ss_sumsum: checksum of segment summary * @ss_magic: magic number * @ss_bytes: size of this structure in bytes * @ss_flags: flags * @ss_seq: sequence number * @ss_create: creation timestamp * @ss_next: next segment * @ss_nblocks: number of blocks * @ss_nfinfo: number of finfo structures * @ss_sumbytes: total size of segment summary in bytes * @ss_pad: padding * @ss_cno: checkpoint number */ struct nilfs_segment_summary { … }; #define NILFS_SEGSUM_MAGIC … /* * Segment summary flags */ #define NILFS_SS_LOGBGN … #define NILFS_SS_LOGEND … #define NILFS_SS_SR … #define NILFS_SS_SYNDT … #define NILFS_SS_GC … /** * struct nilfs_btree_node - header of B-tree node block * @bn_flags: flags * @bn_level: level * @bn_nchildren: number of children * @bn_pad: padding */ struct nilfs_btree_node { … }; /* flags */ #define NILFS_BTREE_NODE_ROOT … /* level */ #define NILFS_BTREE_LEVEL_DATA … #define NILFS_BTREE_LEVEL_NODE_MIN … #define NILFS_BTREE_LEVEL_MAX … /** * struct nilfs_direct_node - header of built-in bmap array * @dn_flags: flags * @dn_pad: padding */ struct nilfs_direct_node { … }; /** * struct nilfs_palloc_group_desc - block group descriptor * @pg_nfrees: number of free entries in block group */ struct nilfs_palloc_group_desc { … }; /** * struct nilfs_dat_entry - disk address translation entry * @de_blocknr: block number * @de_start: start checkpoint number * @de_end: end checkpoint number * @de_rsv: reserved for future use */ struct nilfs_dat_entry { … }; #define NILFS_MIN_DAT_ENTRY_SIZE … /** * struct nilfs_snapshot_list - snapshot list * @ssl_next: next checkpoint number on snapshot list * @ssl_prev: previous checkpoint number on snapshot list */ struct nilfs_snapshot_list { … }; /** * struct nilfs_checkpoint - checkpoint structure * @cp_flags: flags * @cp_checkpoints_count: checkpoints count in a block * @cp_snapshot_list: snapshot list * @cp_cno: checkpoint number * @cp_create: creation timestamp * @cp_nblk_inc: number of blocks incremented by this checkpoint * @cp_inodes_count: inodes count * @cp_blocks_count: blocks count * @cp_ifile_inode: inode of ifile */ struct nilfs_checkpoint { … }; #define NILFS_MIN_CHECKPOINT_SIZE … /* checkpoint flags */ enum { … }; #define NILFS_CHECKPOINT_FNS(flag, name) … NILFS_CHECKPOINT_FNS(SNAPSHOT, snapshot) NILFS_CHECKPOINT_FNS(INVALID, invalid) NILFS_CHECKPOINT_FNS(MINOR, minor) /** * struct nilfs_cpfile_header - checkpoint file header * @ch_ncheckpoints: number of checkpoints * @ch_nsnapshots: number of snapshots * @ch_snapshot_list: snapshot list */ struct nilfs_cpfile_header { … }; #define NILFS_CPFILE_FIRST_CHECKPOINT_OFFSET … /** * struct nilfs_segment_usage - segment usage * @su_lastmod: last modified timestamp * @su_nblocks: number of blocks in segment * @su_flags: flags */ struct nilfs_segment_usage { … }; #define NILFS_MIN_SEGMENT_USAGE_SIZE … /* segment usage flag */ enum { … }; #define NILFS_SEGMENT_USAGE_FNS(flag, name) … NILFS_SEGMENT_USAGE_FNS(ACTIVE, active) NILFS_SEGMENT_USAGE_FNS(DIRTY, dirty) NILFS_SEGMENT_USAGE_FNS(ERROR, error) static inline void nilfs_segment_usage_set_clean(struct nilfs_segment_usage *su) { … } static inline int nilfs_segment_usage_clean(const struct nilfs_segment_usage *su) { … } /** * struct nilfs_sufile_header - segment usage file header * @sh_ncleansegs: number of clean segments * @sh_ndirtysegs: number of dirty segments * @sh_last_alloc: last allocated segment number */ struct nilfs_sufile_header { … }; #define NILFS_SUFILE_FIRST_SEGMENT_USAGE_OFFSET … #endif /* _LINUX_NILFS2_ONDISK_H */