📄 ocfs2_fs.h
字号:
sizeof(ocfs2_extent_rec) *//*10*/ struct ocfs2_extent_rec l_recs[0]; /* Extent records */};/* * On disk allocation chain list for OCFS2. Note that this is * contained inside ocfs2_dinode, so the offsets are relative to * ocfs2_dinode.id2.i_chain. */struct ocfs2_chain_list {/*00*/ __le16 cl_cpg; /* Clusters per Block Group */ __le16 cl_bpc; /* Bits per cluster */ __le16 cl_count; /* Total chains in this list */ __le16 cl_next_free_rec; /* Next unused chain slot */ __le64 cl_reserved1;/*10*/ struct ocfs2_chain_rec cl_recs[0]; /* Chain records */};/* * On disk deallocation log for OCFS2. Note that this is * contained inside ocfs2_dinode, so the offsets are relative to * ocfs2_dinode.id2.i_dealloc. */struct ocfs2_truncate_log {/*00*/ __le16 tl_count; /* Total records in this log */ __le16 tl_used; /* Number of records in use */ __le32 tl_reserved1;/*08*/ struct ocfs2_truncate_rec tl_recs[0]; /* Truncate records */};/* * On disk extent block (indirect block) for OCFS2 */struct ocfs2_extent_block{/*00*/ __u8 h_signature[8]; /* Signature for verification */ __le64 h_reserved1;/*10*/ __le16 h_suballoc_slot; /* Slot suballocator this extent_header belongs to */ __le16 h_suballoc_bit; /* Bit offset in suballocator block group */ __le32 h_fs_generation; /* Must match super block */ __le64 h_blkno; /* Offset on disk, in blocks *//*20*/ __le64 h_reserved3; __le64 h_next_leaf_blk; /* Offset on disk, in blocks, of next leaf header pointing to data *//*30*/ struct ocfs2_extent_list h_list; /* Extent record list *//* Actual on-disk size is one block */};/* * On disk superblock for OCFS2 * Note that it is contained inside an ocfs2_dinode, so all offsets * are relative to the start of ocfs2_dinode.id2. */struct ocfs2_super_block {/*00*/ __le16 s_major_rev_level; __le16 s_minor_rev_level; __le16 s_mnt_count; __le16 s_max_mnt_count; __le16 s_state; /* File system state */ __le16 s_errors; /* Behaviour when detecting errors */ __le32 s_checkinterval; /* Max time between checks *//*10*/ __le64 s_lastcheck; /* Time of last check */ __le32 s_creator_os; /* OS */ __le32 s_feature_compat; /* Compatible feature set *//*20*/ __le32 s_feature_incompat; /* Incompatible feature set */ __le32 s_feature_ro_compat; /* Readonly-compatible feature set */ __le64 s_root_blkno; /* Offset, in blocks, of root directory dinode *//*30*/ __le64 s_system_dir_blkno; /* Offset, in blocks, of system directory dinode */ __le32 s_blocksize_bits; /* Blocksize for this fs */ __le32 s_clustersize_bits; /* Clustersize for this fs *//*40*/ __le16 s_max_slots; /* Max number of simultaneous mounts before tunefs required */ __le16 s_tunefs_flag; __le32 s_reserved1; __le64 s_first_cluster_group; /* Block offset of 1st cluster * group header *//*50*/ __u8 s_label[OCFS2_MAX_VOL_LABEL_LEN]; /* Label for mounting, etc. *//*90*/ __u8 s_uuid[OCFS2_VOL_UUID_LEN]; /* 128-bit uuid *//*A0*/};/* * Local allocation bitmap for OCFS2 slots * Note that it exists inside an ocfs2_dinode, so all offsets are * relative to the start of ocfs2_dinode.id2. */struct ocfs2_local_alloc{/*00*/ __le32 la_bm_off; /* Starting bit offset in main bitmap */ __le16 la_size; /* Size of included bitmap, in bytes */ __le16 la_reserved1; __le64 la_reserved2;/*10*/ __u8 la_bitmap[0];};/* * Data-in-inode header. This is only used if i_dyn_features has * OCFS2_INLINE_DATA_FL set. */struct ocfs2_inline_data{/*00*/ __le16 id_count; /* Number of bytes that can be used * for data, starting at id_data */ __le16 id_reserved0; __le32 id_reserved1; __u8 id_data[0]; /* Start of user data */};/* * On disk inode for OCFS2 */struct ocfs2_dinode {/*00*/ __u8 i_signature[8]; /* Signature for validation */ __le32 i_generation; /* Generation number */ __le16 i_suballoc_slot; /* Slot suballocator this inode belongs to */ __le16 i_suballoc_bit; /* Bit offset in suballocator block group *//*10*/ __le32 i_reserved0; __le32 i_clusters; /* Cluster count */ __le32 i_uid; /* Owner UID */ __le32 i_gid; /* Owning GID *//*20*/ __le64 i_size; /* Size in bytes */ __le16 i_mode; /* File mode */ __le16 i_links_count; /* Links count */ __le32 i_flags; /* File flags *//*30*/ __le64 i_atime; /* Access time */ __le64 i_ctime; /* Creation time *//*40*/ __le64 i_mtime; /* Modification time */ __le64 i_dtime; /* Deletion time *//*50*/ __le64 i_blkno; /* Offset on disk, in blocks */ __le64 i_last_eb_blk; /* Pointer to last extent block *//*60*/ __le32 i_fs_generation; /* Generation per fs-instance */ __le32 i_atime_nsec; __le32 i_ctime_nsec; __le32 i_mtime_nsec; __le32 i_attr; __le16 i_orphaned_slot; /* Only valid when OCFS2_ORPHANED_FL was set in i_flags */ __le16 i_dyn_features;/*70*/ __le64 i_reserved2[8];/*B8*/ union { __le64 i_pad1; /* Generic way to refer to this 64bit union */ struct { __le64 i_rdev; /* Device number */ } dev1; struct { /* Info for bitmap system inodes */ __le32 i_used; /* Bits (ie, clusters) used */ __le32 i_total; /* Total bits (clusters) available */ } bitmap1; struct { /* Info for journal system inodes */ __le32 ij_flags; /* Mounted, version, etc. */ __le32 ij_recovery_generation; /* Incremented when the journal is recovered after an unclean shutdown */ } journal1; } id1; /* Inode type dependant 1 *//*C0*/ union { struct ocfs2_super_block i_super; struct ocfs2_local_alloc i_lab; struct ocfs2_chain_list i_chain; struct ocfs2_extent_list i_list; struct ocfs2_truncate_log i_dealloc; struct ocfs2_inline_data i_data; __u8 i_symlink[0]; } id2;/* Actual on-disk size is one block */};/* * On-disk directory entry structure for OCFS2 * * Packed as this structure could be accessed unaligned on 64-bit platforms */struct ocfs2_dir_entry {/*00*/ __le64 inode; /* Inode number */ __le16 rec_len; /* Directory entry length */ __u8 name_len; /* Name length */ __u8 file_type;/*0C*/ char name[OCFS2_MAX_FILENAME_LEN]; /* File name *//* Actual on-disk length specified by rec_len */} __attribute__ ((packed));/* * On disk allocator group structure for OCFS2 */struct ocfs2_group_desc{/*00*/ __u8 bg_signature[8]; /* Signature for validation */ __le16 bg_size; /* Size of included bitmap in bytes. */ __le16 bg_bits; /* Bits represented by this group. */ __le16 bg_free_bits_count; /* Free bits count */ __le16 bg_chain; /* What chain I am in. *//*10*/ __le32 bg_generation; __le32 bg_reserved1; __le64 bg_next_group; /* Next group in my list, in blocks *//*20*/ __le64 bg_parent_dinode; /* dinode which owns me, in blocks */ __le64 bg_blkno; /* Offset on disk, in blocks *//*30*/ __le64 bg_reserved2[2];/*40*/ __u8 bg_bitmap[0];};#ifdef __KERNEL__static inline int ocfs2_fast_symlink_chars(struct super_block *sb){ return sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);}static inline int ocfs2_max_inline_data(struct super_block *sb){ return sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);}static inline int ocfs2_extent_recs_per_inode(struct super_block *sb){ int size; size = sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_list.l_recs); return size / sizeof(struct ocfs2_extent_rec);}static inline int ocfs2_chain_recs_per_inode(struct super_block *sb){ int size; size = sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); return size / sizeof(struct ocfs2_chain_rec);}static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb){ int size; size = sb->s_blocksize - offsetof(struct ocfs2_extent_block, h_list.l_recs); return size / sizeof(struct ocfs2_extent_rec);}static inline u16 ocfs2_local_alloc_size(struct super_block *sb){ u16 size; size = sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); return size;}static inline int ocfs2_group_bitmap_size(struct super_block *sb){ int size; size = sb->s_blocksize - offsetof(struct ocfs2_group_desc, bg_bitmap); return size;}static inline int ocfs2_truncate_recs_per_inode(struct super_block *sb){ int size; size = sb->s_blocksize - offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); return size / sizeof(struct ocfs2_truncate_rec);}static inline u64 ocfs2_backup_super_blkno(struct super_block *sb, int index){ u64 offset = OCFS2_BACKUP_SB_START; if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { offset <<= (2 * index); offset >>= sb->s_blocksize_bits; return offset; } return 0;}#elsestatic inline int ocfs2_fast_symlink_chars(int blocksize){ return blocksize - offsetof(struct ocfs2_dinode, id2.i_symlink);}static inline int ocfs2_max_inline_data(int blocksize){ return blocksize - offsetof(struct ocfs2_dinode, id2.i_data.id_data);}static inline int ocfs2_extent_recs_per_inode(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_dinode, id2.i_list.l_recs); return size / sizeof(struct ocfs2_extent_rec);}static inline int ocfs2_chain_recs_per_inode(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_dinode, id2.i_chain.cl_recs); return size / sizeof(struct ocfs2_chain_rec);}static inline int ocfs2_extent_recs_per_eb(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_extent_block, h_list.l_recs); return size / sizeof(struct ocfs2_extent_rec);}static inline int ocfs2_local_alloc_size(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_dinode, id2.i_lab.la_bitmap); return size;}static inline int ocfs2_group_bitmap_size(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_group_desc, bg_bitmap); return size;}static inline int ocfs2_truncate_recs_per_inode(int blocksize){ int size; size = blocksize - offsetof(struct ocfs2_dinode, id2.i_dealloc.tl_recs); return size / sizeof(struct ocfs2_truncate_rec);}static inline uint64_t ocfs2_backup_super_blkno(int blocksize, int index){ uint64_t offset = OCFS2_BACKUP_SB_START; if (index >= 0 && index < OCFS2_MAX_BACKUP_SUPERBLOCKS) { offset <<= (2 * index); offset /= blocksize; return offset; } return 0;}#endif /* __KERNEL__ */static inline int ocfs2_system_inode_is_global(int type){ return ((type >= 0) && (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE));}static inline int ocfs2_sprintf_system_inode_name(char *buf, int len, int type, int slot){ int chars; /* * Global system inodes can only have one copy. Everything * after OCFS2_LAST_GLOBAL_SYSTEM_INODE in the system inode * list has a copy per slot. */ if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE) chars = snprintf(buf, len, "%s", ocfs2_system_inodes[type].si_name); else chars = snprintf(buf, len, ocfs2_system_inodes[type].si_name, slot); return chars;}static inline void ocfs2_set_de_type(struct ocfs2_dir_entry *de, umode_t mode){ de->file_type = ocfs2_type_by_mode[(mode & S_IFMT)>>S_SHIFT];}#endif /* _OCFS2_FS_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -