📄 ocfs2.h
字号:
*/ struct list_head blocked_lock_list; unsigned long blocked_lock_count; wait_queue_head_t osb_mount_event; /* Truncate log info */ struct inode *osb_tl_inode; struct buffer_head *osb_tl_bh; struct delayed_work osb_truncate_log_wq; struct ocfs2_node_map osb_recovering_orphan_dirs; unsigned int *osb_orphan_wipes; wait_queue_head_t osb_wipe_event;};#define OCFS2_SB(sb) ((struct ocfs2_super *)(sb)->s_fs_info)static inline int ocfs2_should_order_data(struct inode *inode){ if (!S_ISREG(inode->i_mode)) return 0; if (OCFS2_SB(inode->i_sb)->s_mount_opt & OCFS2_MOUNT_DATA_WRITEBACK) return 0; return 1;}static inline int ocfs2_sparse_alloc(struct ocfs2_super *osb){ if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_SPARSE_ALLOC) return 1; return 0;}static inline int ocfs2_writes_unwritten_extents(struct ocfs2_super *osb){ /* * Support for sparse files is a pre-requisite */ if (!ocfs2_sparse_alloc(osb)) return 0; if (osb->s_feature_ro_compat & OCFS2_FEATURE_RO_COMPAT_UNWRITTEN) return 1; return 0;}static inline int ocfs2_supports_inline_data(struct ocfs2_super *osb){ if (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_INLINE_DATA) return 1; return 0;}/* set / clear functions because cluster events can make these happen * in parallel so we want the transitions to be atomic. this also * means that any future flags osb_flags must be protected by spinlock * too! */static inline void ocfs2_set_osb_flag(struct ocfs2_super *osb, unsigned long flag){ spin_lock(&osb->osb_lock); osb->osb_flags |= flag; spin_unlock(&osb->osb_lock);}static inline void ocfs2_set_ro_flag(struct ocfs2_super *osb, int hard){ spin_lock(&osb->osb_lock); osb->osb_flags &= ~(OCFS2_OSB_SOFT_RO|OCFS2_OSB_HARD_RO); if (hard) osb->osb_flags |= OCFS2_OSB_HARD_RO; else osb->osb_flags |= OCFS2_OSB_SOFT_RO; spin_unlock(&osb->osb_lock);}static inline int ocfs2_is_hard_readonly(struct ocfs2_super *osb){ int ret; spin_lock(&osb->osb_lock); ret = osb->osb_flags & OCFS2_OSB_HARD_RO; spin_unlock(&osb->osb_lock); return ret;}static inline int ocfs2_is_soft_readonly(struct ocfs2_super *osb){ int ret; spin_lock(&osb->osb_lock); ret = osb->osb_flags & OCFS2_OSB_SOFT_RO; spin_unlock(&osb->osb_lock); return ret;}static inline int ocfs2_mount_local(struct ocfs2_super *osb){ return (osb->s_feature_incompat & OCFS2_FEATURE_INCOMPAT_LOCAL_MOUNT);}#define OCFS2_IS_VALID_DINODE(ptr) \ (!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))#define OCFS2_RO_ON_INVALID_DINODE(__sb, __di) do { \ typeof(__di) ____di = (__di); \ ocfs2_error((__sb), \ "Dinode # %llu has bad signature %.*s", \ (unsigned long long)le64_to_cpu((____di)->i_blkno), 7, \ (____di)->i_signature); \} while (0)#define OCFS2_IS_VALID_EXTENT_BLOCK(ptr) \ (!strcmp((ptr)->h_signature, OCFS2_EXTENT_BLOCK_SIGNATURE))#define OCFS2_RO_ON_INVALID_EXTENT_BLOCK(__sb, __eb) do { \ typeof(__eb) ____eb = (__eb); \ ocfs2_error((__sb), \ "Extent Block # %llu has bad signature %.*s", \ (unsigned long long)le64_to_cpu((____eb)->h_blkno), 7, \ (____eb)->h_signature); \} while (0)#define OCFS2_IS_VALID_GROUP_DESC(ptr) \ (!strcmp((ptr)->bg_signature, OCFS2_GROUP_DESC_SIGNATURE))#define OCFS2_RO_ON_INVALID_GROUP_DESC(__sb, __gd) do { \ typeof(__gd) ____gd = (__gd); \ ocfs2_error((__sb), \ "Group Descriptor # %llu has bad signature %.*s", \ (unsigned long long)le64_to_cpu((____gd)->bg_blkno), 7, \ (____gd)->bg_signature); \} while (0)static inline unsigned long ino_from_blkno(struct super_block *sb, u64 blkno){ return (unsigned long)(blkno & (u64)ULONG_MAX);}static inline u64 ocfs2_clusters_to_blocks(struct super_block *sb, u32 clusters){ int c_to_b_bits = OCFS2_SB(sb)->s_clustersize_bits - sb->s_blocksize_bits; return (u64)clusters << c_to_b_bits;}static inline u32 ocfs2_blocks_to_clusters(struct super_block *sb, u64 blocks){ int b_to_c_bits = OCFS2_SB(sb)->s_clustersize_bits - sb->s_blocksize_bits; return (u32)(blocks >> b_to_c_bits);}static inline unsigned int ocfs2_clusters_for_bytes(struct super_block *sb, u64 bytes){ int cl_bits = OCFS2_SB(sb)->s_clustersize_bits; unsigned int clusters; bytes += OCFS2_SB(sb)->s_clustersize - 1; /* OCFS2 just cannot have enough clusters to overflow this */ clusters = (unsigned int)(bytes >> cl_bits); return clusters;}static inline u64 ocfs2_blocks_for_bytes(struct super_block *sb, u64 bytes){ bytes += sb->s_blocksize - 1; return bytes >> sb->s_blocksize_bits;}static inline u64 ocfs2_clusters_to_bytes(struct super_block *sb, u32 clusters){ return (u64)clusters << OCFS2_SB(sb)->s_clustersize_bits;}static inline u64 ocfs2_align_bytes_to_clusters(struct super_block *sb, u64 bytes){ int cl_bits = OCFS2_SB(sb)->s_clustersize_bits; unsigned int clusters; clusters = ocfs2_clusters_for_bytes(sb, bytes); return (u64)clusters << cl_bits;}static inline u64 ocfs2_align_bytes_to_blocks(struct super_block *sb, u64 bytes){ u64 blocks; blocks = ocfs2_blocks_for_bytes(sb, bytes); return blocks << sb->s_blocksize_bits;}static inline unsigned long ocfs2_align_bytes_to_sectors(u64 bytes){ return (unsigned long)((bytes + 511) >> 9);}static inline unsigned int ocfs2_page_index_to_clusters(struct super_block *sb, unsigned long pg_index){ u32 clusters = pg_index; unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits; if (unlikely(PAGE_CACHE_SHIFT > cbits)) clusters = pg_index << (PAGE_CACHE_SHIFT - cbits); else if (PAGE_CACHE_SHIFT < cbits) clusters = pg_index >> (cbits - PAGE_CACHE_SHIFT); return clusters;}/* * Find the 1st page index which covers the given clusters. */static inline pgoff_t ocfs2_align_clusters_to_page_index(struct super_block *sb, u32 clusters){ unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits; pgoff_t index = clusters; if (PAGE_CACHE_SHIFT > cbits) { index = (pgoff_t)clusters >> (PAGE_CACHE_SHIFT - cbits); } else if (PAGE_CACHE_SHIFT < cbits) { index = (pgoff_t)clusters << (cbits - PAGE_CACHE_SHIFT); } return index;}static inline unsigned int ocfs2_pages_per_cluster(struct super_block *sb){ unsigned int cbits = OCFS2_SB(sb)->s_clustersize_bits; unsigned int pages_per_cluster = 1; if (PAGE_CACHE_SHIFT < cbits) pages_per_cluster = 1 << (cbits - PAGE_CACHE_SHIFT); return pages_per_cluster;}static inline void ocfs2_init_inode_steal_slot(struct ocfs2_super *osb){ spin_lock(&osb->osb_lock); osb->s_inode_steal_slot = OCFS2_INVALID_SLOT; spin_unlock(&osb->osb_lock); atomic_set(&osb->s_num_inodes_stolen, 0);}static inline void ocfs2_set_inode_steal_slot(struct ocfs2_super *osb, s16 slot){ spin_lock(&osb->osb_lock); osb->s_inode_steal_slot = slot; spin_unlock(&osb->osb_lock);}static inline s16 ocfs2_get_inode_steal_slot(struct ocfs2_super *osb){ s16 slot; spin_lock(&osb->osb_lock); slot = osb->s_inode_steal_slot; spin_unlock(&osb->osb_lock); return slot;}#define ocfs2_set_bit ext2_set_bit#define ocfs2_clear_bit ext2_clear_bit#define ocfs2_test_bit ext2_test_bit#define ocfs2_find_next_zero_bit ext2_find_next_zero_bit#endif /* OCFS2_H */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -