diff options
Diffstat (limited to 'fs/ocfs2/ocfs2_fs.h')
-rw-r--r-- | fs/ocfs2/ocfs2_fs.h | 136 |
1 files changed, 131 insertions, 5 deletions
diff --git a/fs/ocfs2/ocfs2_fs.h b/fs/ocfs2/ocfs2_fs.h index 2332ef740f4f..7ab6e9e5e77c 100644 --- a/fs/ocfs2/ocfs2_fs.h +++ b/fs/ocfs2/ocfs2_fs.h | |||
@@ -66,6 +66,8 @@ | |||
66 | #define OCFS2_GROUP_DESC_SIGNATURE "GROUP01" | 66 | #define OCFS2_GROUP_DESC_SIGNATURE "GROUP01" |
67 | #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01" | 67 | #define OCFS2_XATTR_BLOCK_SIGNATURE "XATTR01" |
68 | #define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1" | 68 | #define OCFS2_DIR_TRAILER_SIGNATURE "DIRTRL1" |
69 | #define OCFS2_DX_ROOT_SIGNATURE "DXDIR01" | ||
70 | #define OCFS2_DX_LEAF_SIGNATURE "DXLEAF1" | ||
69 | 71 | ||
70 | /* Compatibility flags */ | 72 | /* Compatibility flags */ |
71 | #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ | 73 | #define OCFS2_HAS_COMPAT_FEATURE(sb,mask) \ |
@@ -95,7 +97,8 @@ | |||
95 | | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ | 97 | | OCFS2_FEATURE_INCOMPAT_EXTENDED_SLOT_MAP \ |
96 | | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \ | 98 | | OCFS2_FEATURE_INCOMPAT_USERSPACE_STACK \ |
97 | | OCFS2_FEATURE_INCOMPAT_XATTR \ | 99 | | OCFS2_FEATURE_INCOMPAT_XATTR \ |
98 | | OCFS2_FEATURE_INCOMPAT_META_ECC) | 100 | | OCFS2_FEATURE_INCOMPAT_META_ECC \ |
101 | | OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS) | ||
99 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ | 102 | #define OCFS2_FEATURE_RO_COMPAT_SUPP (OCFS2_FEATURE_RO_COMPAT_UNWRITTEN \ |
100 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ | 103 | | OCFS2_FEATURE_RO_COMPAT_USRQUOTA \ |
101 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) | 104 | | OCFS2_FEATURE_RO_COMPAT_GRPQUOTA) |
@@ -151,6 +154,9 @@ | |||
151 | /* Support for extended attributes */ | 154 | /* Support for extended attributes */ |
152 | #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200 | 155 | #define OCFS2_FEATURE_INCOMPAT_XATTR 0x0200 |
153 | 156 | ||
157 | /* Support for indexed directores */ | ||
158 | #define OCFS2_FEATURE_INCOMPAT_INDEXED_DIRS 0x0400 | ||
159 | |||
154 | /* Metadata checksum and error correction */ | 160 | /* Metadata checksum and error correction */ |
155 | #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800 | 161 | #define OCFS2_FEATURE_INCOMPAT_META_ECC 0x0800 |
156 | 162 | ||
@@ -411,8 +417,12 @@ static struct ocfs2_system_inode_info ocfs2_system_inodes[NUM_SYSTEM_INODES] = { | |||
411 | #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \ | 417 | #define OCFS2_DIR_REC_LEN(name_len) (((name_len) + OCFS2_DIR_MEMBER_LEN + \ |
412 | OCFS2_DIR_ROUND) & \ | 418 | OCFS2_DIR_ROUND) & \ |
413 | ~OCFS2_DIR_ROUND) | 419 | ~OCFS2_DIR_ROUND) |
420 | #define OCFS2_DIR_MIN_REC_LEN OCFS2_DIR_REC_LEN(1) | ||
414 | 421 | ||
415 | #define OCFS2_LINK_MAX 32000 | 422 | #define OCFS2_LINK_MAX 32000 |
423 | #define OCFS2_DX_LINK_MAX ((1U << 31) - 1U) | ||
424 | #define OCFS2_LINKS_HI_SHIFT 16 | ||
425 | #define OCFS2_DX_ENTRIES_MAX (0xffffffffU) | ||
416 | 426 | ||
417 | #define S_SHIFT 12 | 427 | #define S_SHIFT 12 |
418 | static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { | 428 | static unsigned char ocfs2_type_by_mode[S_IFMT >> S_SHIFT] = { |
@@ -628,8 +638,9 @@ struct ocfs2_super_block { | |||
628 | /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size | 638 | /*B8*/ __le16 s_xattr_inline_size; /* extended attribute inline size |
629 | for this fs*/ | 639 | for this fs*/ |
630 | __le16 s_reserved0; | 640 | __le16 s_reserved0; |
631 | __le32 s_reserved1; | 641 | __le32 s_dx_seed[3]; /* seed[0-2] for dx dir hash. |
632 | /*C0*/ __le64 s_reserved2[16]; /* Fill out superblock */ | 642 | * s_uuid_hash serves as seed[3]. */ |
643 | /*C0*/ __le64 s_reserved2[15]; /* Fill out superblock */ | ||
633 | /*140*/ | 644 | /*140*/ |
634 | 645 | ||
635 | /* | 646 | /* |
@@ -679,7 +690,7 @@ struct ocfs2_dinode { | |||
679 | belongs to */ | 690 | belongs to */ |
680 | __le16 i_suballoc_bit; /* Bit offset in suballocator | 691 | __le16 i_suballoc_bit; /* Bit offset in suballocator |
681 | block group */ | 692 | block group */ |
682 | /*10*/ __le16 i_reserved0; | 693 | /*10*/ __le16 i_links_count_hi; /* High 16 bits of links count */ |
683 | __le16 i_xattr_inline_size; | 694 | __le16 i_xattr_inline_size; |
684 | __le32 i_clusters; /* Cluster count */ | 695 | __le32 i_clusters; /* Cluster count */ |
685 | __le32 i_uid; /* Owner UID */ | 696 | __le32 i_uid; /* Owner UID */ |
@@ -705,7 +716,8 @@ struct ocfs2_dinode { | |||
705 | __le16 i_dyn_features; | 716 | __le16 i_dyn_features; |
706 | __le64 i_xattr_loc; | 717 | __le64 i_xattr_loc; |
707 | /*80*/ struct ocfs2_block_check i_check; /* Error checking */ | 718 | /*80*/ struct ocfs2_block_check i_check; /* Error checking */ |
708 | /*88*/ __le64 i_reserved2[6]; | 719 | /*88*/ __le64 i_dx_root; /* Pointer to dir index root block */ |
720 | __le64 i_reserved2[5]; | ||
709 | /*B8*/ union { | 721 | /*B8*/ union { |
710 | __le64 i_pad1; /* Generic way to refer to this | 722 | __le64 i_pad1; /* Generic way to refer to this |
711 | 64bit union */ | 723 | 64bit union */ |
@@ -781,6 +793,90 @@ struct ocfs2_dir_block_trailer { | |||
781 | /*40*/ | 793 | /*40*/ |
782 | }; | 794 | }; |
783 | 795 | ||
796 | /* | ||
797 | * A directory entry in the indexed tree. We don't store the full name here, | ||
798 | * but instead provide a pointer to the full dirent in the unindexed tree. | ||
799 | * | ||
800 | * We also store name_len here so as to reduce the number of leaf blocks we | ||
801 | * need to search in case of collisions. | ||
802 | */ | ||
803 | struct ocfs2_dx_entry { | ||
804 | __le32 dx_major_hash; /* Used to find logical | ||
805 | * cluster in index */ | ||
806 | __le32 dx_minor_hash; /* Lower bits used to find | ||
807 | * block in cluster */ | ||
808 | __le64 dx_dirent_blk; /* Physical block in unindexed | ||
809 | * tree holding this dirent. */ | ||
810 | }; | ||
811 | |||
812 | struct ocfs2_dx_entry_list { | ||
813 | __le32 de_reserved; | ||
814 | __le16 de_count; /* Maximum number of entries | ||
815 | * possible in de_entries */ | ||
816 | __le16 de_num_used; /* Current number of | ||
817 | * de_entries entries */ | ||
818 | struct ocfs2_dx_entry de_entries[0]; /* Indexed dir entries | ||
819 | * in a packed array of | ||
820 | * length de_num_used */ | ||
821 | }; | ||
822 | |||
823 | #define OCFS2_DX_FLAG_INLINE 0x01 | ||
824 | |||
825 | /* | ||
826 | * A directory indexing block. Each indexed directory has one of these, | ||
827 | * pointed to by ocfs2_dinode. | ||
828 | * | ||
829 | * This block stores an indexed btree root, and a set of free space | ||
830 | * start-of-list pointers. | ||
831 | */ | ||
832 | struct ocfs2_dx_root_block { | ||
833 | __u8 dr_signature[8]; /* Signature for verification */ | ||
834 | struct ocfs2_block_check dr_check; /* Error checking */ | ||
835 | __le16 dr_suballoc_slot; /* Slot suballocator this | ||
836 | * block belongs to. */ | ||
837 | __le16 dr_suballoc_bit; /* Bit offset in suballocator | ||
838 | * block group */ | ||
839 | __le32 dr_fs_generation; /* Must match super block */ | ||
840 | __le64 dr_blkno; /* Offset on disk, in blocks */ | ||
841 | __le64 dr_last_eb_blk; /* Pointer to last | ||
842 | * extent block */ | ||
843 | __le32 dr_clusters; /* Clusters allocated | ||
844 | * to the indexed tree. */ | ||
845 | __u8 dr_flags; /* OCFS2_DX_FLAG_* flags */ | ||
846 | __u8 dr_reserved0; | ||
847 | __le16 dr_reserved1; | ||
848 | __le64 dr_dir_blkno; /* Pointer to parent inode */ | ||
849 | __le32 dr_num_entries; /* Total number of | ||
850 | * names stored in | ||
851 | * this directory.*/ | ||
852 | __le32 dr_reserved2; | ||
853 | __le64 dr_free_blk; /* Pointer to head of free | ||
854 | * unindexed block list. */ | ||
855 | __le64 dr_reserved3[15]; | ||
856 | union { | ||
857 | struct ocfs2_extent_list dr_list; /* Keep this aligned to 128 | ||
858 | * bits for maximum space | ||
859 | * efficiency. */ | ||
860 | struct ocfs2_dx_entry_list dr_entries; /* In-root-block list of | ||
861 | * entries. We grow out | ||
862 | * to extents if this | ||
863 | * gets too big. */ | ||
864 | }; | ||
865 | }; | ||
866 | |||
867 | /* | ||
868 | * The header of a leaf block in the indexed tree. | ||
869 | */ | ||
870 | struct ocfs2_dx_leaf { | ||
871 | __u8 dl_signature[8];/* Signature for verification */ | ||
872 | struct ocfs2_block_check dl_check; /* Error checking */ | ||
873 | __le64 dl_blkno; /* Offset on disk, in blocks */ | ||
874 | __le32 dl_fs_generation;/* Must match super block */ | ||
875 | __le32 dl_reserved0; | ||
876 | __le64 dl_reserved1; | ||
877 | struct ocfs2_dx_entry_list dl_list; | ||
878 | }; | ||
879 | |||
784 | /* | 880 | /* |
785 | * On disk allocator group structure for OCFS2 | 881 | * On disk allocator group structure for OCFS2 |
786 | */ | 882 | */ |
@@ -1112,6 +1208,16 @@ static inline int ocfs2_extent_recs_per_inode_with_xattr( | |||
1112 | return size / sizeof(struct ocfs2_extent_rec); | 1208 | return size / sizeof(struct ocfs2_extent_rec); |
1113 | } | 1209 | } |
1114 | 1210 | ||
1211 | static inline int ocfs2_extent_recs_per_dx_root(struct super_block *sb) | ||
1212 | { | ||
1213 | int size; | ||
1214 | |||
1215 | size = sb->s_blocksize - | ||
1216 | offsetof(struct ocfs2_dx_root_block, dr_list.l_recs); | ||
1217 | |||
1218 | return size / sizeof(struct ocfs2_extent_rec); | ||
1219 | } | ||
1220 | |||
1115 | static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) | 1221 | static inline int ocfs2_chain_recs_per_inode(struct super_block *sb) |
1116 | { | 1222 | { |
1117 | int size; | 1223 | int size; |
@@ -1132,6 +1238,26 @@ static inline u16 ocfs2_extent_recs_per_eb(struct super_block *sb) | |||
1132 | return size / sizeof(struct ocfs2_extent_rec); | 1238 | return size / sizeof(struct ocfs2_extent_rec); |
1133 | } | 1239 | } |
1134 | 1240 | ||
1241 | static inline int ocfs2_dx_entries_per_leaf(struct super_block *sb) | ||
1242 | { | ||
1243 | int size; | ||
1244 | |||
1245 | size = sb->s_blocksize - | ||
1246 | offsetof(struct ocfs2_dx_leaf, dl_list.de_entries); | ||
1247 | |||
1248 | return size / sizeof(struct ocfs2_dx_entry); | ||
1249 | } | ||
1250 | |||
1251 | static inline int ocfs2_dx_entries_per_root(struct super_block *sb) | ||
1252 | { | ||
1253 | int size; | ||
1254 | |||
1255 | size = sb->s_blocksize - | ||
1256 | offsetof(struct ocfs2_dx_root_block, dr_entries.de_entries); | ||
1257 | |||
1258 | return size / sizeof(struct ocfs2_dx_entry); | ||
1259 | } | ||
1260 | |||
1135 | static inline u16 ocfs2_local_alloc_size(struct super_block *sb) | 1261 | static inline u16 ocfs2_local_alloc_size(struct super_block *sb) |
1136 | { | 1262 | { |
1137 | u16 size; | 1263 | u16 size; |