165165/* Refcount tree support */
166166#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
167167
168+ /* Discontigous block groups */
169+ #define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
170+
168171/*
169172 * backup superblock flag is used to indicate that this volume
170173 * has backup superblocks.
@@ -831,6 +834,13 @@ struct ocfs2_dx_leaf {
831834 struct ocfs2_dx_entry_list dl_list ;
832835};
833836
837+ /*
838+ * Largest bitmap for a block (suballocator) group in bytes. This limit
839+ * does not affect cluster groups (global allocator). Cluster group
840+ * bitmaps run to the end of the block.
841+ */
842+ #define OCFS2_MAX_BG_BITMAP_SIZE 256
843+
834844/*
835845 * On disk allocator group structure for OCFS2
836846 */
@@ -852,7 +862,29 @@ struct ocfs2_group_desc
852862 __le64 bg_blkno ; /* Offset on disk, in blocks */
853863/*30*/ struct ocfs2_block_check bg_check ; /* Error checking */
854864 __le64 bg_reserved2 ;
855- /*40*/ __u8 bg_bitmap [0 ];
865+ /*40*/ union {
866+ __u8 bg_bitmap [0 ];
867+ struct {
868+ /*
869+ * Block groups may be discontiguous when
870+ * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
871+ * The extents of a discontigous block group are
872+ * stored in bg_list. It is a flat list.
873+ * l_tree_depth must always be zero. A
874+ * discontiguous group is signified by a non-zero
875+ * bg_list->l_next_free_rec. Only block groups
876+ * can be discontiguous; Cluster groups cannot.
877+ * We've never made a block group with more than
878+ * 2048 blocks (256 bytes of bg_bitmap). This
879+ * codifies that limit so that we can fit bg_list.
880+ * bg_size of a discontiguous block group will
881+ * be 256 to match bg_bitmap_filler.
882+ */
883+ __u8 bg_bitmap_filler [OCFS2_MAX_BG_BITMAP_SIZE ];
884+ /*140*/ struct ocfs2_extent_list bg_list ;
885+ };
886+ };
887+ /* Actual on-disk size is one block */
856888};
857889
858890struct ocfs2_refcount_rec {
@@ -1276,12 +1308,16 @@ static inline u16 ocfs2_local_alloc_size(struct super_block *sb)
12761308 return size ;
12771309}
12781310
1279- static inline int ocfs2_group_bitmap_size (struct super_block * sb )
1311+ static inline int ocfs2_group_bitmap_size (struct super_block * sb ,
1312+ int suballocator )
12801313{
12811314 int size ;
12821315
1283- size = sb -> s_blocksize -
1284- offsetof(struct ocfs2_group_desc , bg_bitmap );
1316+ if (suballocator )
1317+ size = OCFS2_MAX_BG_BITMAP_SIZE ;
1318+ else
1319+ size = sb -> s_blocksize -
1320+ offsetof(struct ocfs2_group_desc , bg_bitmap );
12851321
12861322 return size ;
12871323}
@@ -1404,12 +1440,15 @@ static inline int ocfs2_local_alloc_size(int blocksize)
14041440 return size ;
14051441}
14061442
1407- static inline int ocfs2_group_bitmap_size (int blocksize )
1443+ static inline int ocfs2_group_bitmap_size (int blocksize , int suballocator )
14081444{
14091445 int size ;
14101446
1411- size = blocksize -
1412- offsetof(struct ocfs2_group_desc , bg_bitmap );
1447+ if (suballocator )
1448+ size = OCFS2_MAX_BG_BITMAP_SIZE ;
1449+ else
1450+ size = blocksize -
1451+ offsetof(struct ocfs2_group_desc , bg_bitmap );
14131452
14141453 return size ;
14151454}
0 commit comments