[Ocfs2-tools-devel] [PATCH 01/22] ocfs2-tools: Add disk layout for discontiguous block group.
Tao Ma
tao.ma at oracle.com
Wed Mar 31 21:41:05 PDT 2010
Add disk layout for discontiguous block group.
Signed-off-by: Tao Ma <tao.ma at oracle.com>
---
include/ocfs2-kernel/ocfs2_fs.h | 56 +++++++++++++++++++++++++++++++++++---
include/ocfs2/ocfs2.h | 8 +++++
sizetest/sizetest.c | 7 ++++-
3 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/include/ocfs2-kernel/ocfs2_fs.h b/include/ocfs2-kernel/ocfs2_fs.h
index c0638fc..bca7e3b 100644
--- a/include/ocfs2-kernel/ocfs2_fs.h
+++ b/include/ocfs2-kernel/ocfs2_fs.h
@@ -159,6 +159,9 @@
/* Refcount tree support */
#define OCFS2_FEATURE_INCOMPAT_REFCOUNT_TREE 0x1000
+/* Discontigous block groups */
+#define OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG 0x2000
+
/*
* backup superblock flag is used to indicate that this volume
* has backup superblocks.
@@ -562,7 +565,10 @@ struct ocfs2_extent_block
block group */
__le32 h_fs_generation; /* Must match super block */
__le64 h_blkno; /* Offset on disk, in blocks */
-/*20*/ __le64 h_reserved3;
+/*20*/ __le64 h_suballoc_loc; /* Suballocator block group this
+ eb belongs to. Only valid
+ if allocated from a
+ discontiguous block group */
__le64 h_next_leaf_blk; /* Offset on disk, in blocks,
of next leaf header pointing
to data */
@@ -728,7 +734,11 @@ struct ocfs2_dinode {
/*80*/ struct ocfs2_block_check i_check; /* Error checking */
__le64 i_dx_root;
/*90*/ __le64 i_refcount_loc;
- __le64 i_reserved2[4];
+ __le64 i_suballoc_loc; /* Suballocator block group this
+ inode belongs to. Only valid
+ if allocated from a
+ discontiguous block group */
+/*A0*/ __le64 i_reserved2[3];
/*B8*/ union {
__le64 i_pad1; /* Generic way to refer to this
64bit union */
@@ -805,6 +815,13 @@ struct ocfs2_dir_block_trailer {
};
/*
+ * Largest bitmap for a block (suballocator) group in bytes. This limit
+ * does not affect cluster groups (global allocator). Cluster group
+ * bitmaps run to the end of the block.
+ */
+#define OCFS2_MAX_BG_BITMAP_SIZE 256
+
+/*
* On disk allocator group structure for OCFS2
*/
struct ocfs2_group_desc
@@ -825,7 +842,29 @@ struct ocfs2_group_desc
__le64 bg_blkno; /* Offset on disk, in blocks */
/*30*/ struct ocfs2_block_check bg_check; /* Error checking */
__le64 bg_reserved2;
-/*40*/ __u8 bg_bitmap[0];
+/*40*/ union {
+ __u8 bg_bitmap[0];
+ struct {
+ /*
+ * Block groups may be discontiguous when
+ * OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG is set.
+ * The extents of a discontigous block group are
+ * stored in bg_list. It is a flat list.
+ * l_tree_depth must always be zero. A
+ * discontiguous group is signified by a non-zero
+ * bg_list->l_next_free_rec. Only block groups
+ * can be discontiguous; Cluster groups cannot.
+ * We've never made a block group with more than
+ * 2048 blocks (256 bytes of bg_bitmap). This
+ * codifies that limit so that we can fit bg_list.
+ * bg_size of a discontiguous block group will
+ * be 256 to match bg_bitmap_filler.
+ */
+ __u8 bg_bitmap_filler[OCFS2_MAX_BG_BITMAP_SIZE];
+/*140*/ struct ocfs2_extent_list bg_list;
+ };
+ };
+/* Actual on-disk size is one block */
};
struct ocfs2_refcount_rec {
@@ -870,7 +909,11 @@ struct ocfs2_refcount_block {
/*40*/ __le32 rf_generation; /* generation number. all be the same
* for the same refcount tree. */
__le32 rf_reserved0;
- __le64 rf_reserved1[7];
+ __le64 rf_suballoc_loc; /* Suballocator block group this
+ refcount block belongs to. Only
+ valid if allocated from a
+ discontiguous block group */
+/*50*/ __le64 rf_reserved1[6];
/*80*/ union {
struct ocfs2_refcount_list rf_records; /* List of refcount
records */
@@ -983,7 +1026,10 @@ struct ocfs2_xattr_block {
real xattr or a xattr tree. */
__le16 xb_reserved0;
__le32 xb_reserved1;
- __le64 xb_reserved2;
+ __le64 xb_suballoc_loc; /* Suballocator block group this
+ xattr block belongs to. Only
+ valid if allocated from a
+ discontiguous block group */
/*30*/ union {
struct ocfs2_xattr_header xb_header; /* xattr header if this
block contains xattr */
diff --git a/include/ocfs2/ocfs2.h b/include/ocfs2/ocfs2.h
index e302eb3..a0983f8 100644
--- a/include/ocfs2/ocfs2.h
+++ b/include/ocfs2/ocfs2.h
@@ -1250,6 +1250,14 @@ static inline int ocfs2_refcount_tree(struct ocfs2_super_block *osb)
return 0;
}
+static inline int ocfs2_supports_discontig_bg(struct ocfs2_super_block *osb)
+{
+ if (OCFS2_HAS_INCOMPAT_FEATURE(osb,
+ OCFS2_FEATURE_INCOMPAT_DISCONTIG_BG))
+ return 1;
+ return 0;
+}
+
/*
* shamelessly lifted from the kernel
*
diff --git a/sizetest/sizetest.c b/sizetest/sizetest.c
index bdb06a2..ddf24df 100644
--- a/sizetest/sizetest.c
+++ b/sizetest/sizetest.c
@@ -107,7 +107,7 @@ static void print_ocfs2_extent_block(void)
SHOW_OFFSET(struct ocfs2_extent_block, h_suballoc_bit);
SHOW_OFFSET(struct ocfs2_extent_block, h_fs_generation);
SHOW_OFFSET(struct ocfs2_extent_block, h_blkno);
- SHOW_OFFSET(struct ocfs2_extent_block, h_reserved3);
+ SHOW_OFFSET(struct ocfs2_extent_block, h_suballoc_loc);
SHOW_OFFSET(struct ocfs2_extent_block, h_next_leaf_blk);
SHOW_OFFSET(struct ocfs2_extent_block, h_list);
@@ -197,6 +197,9 @@ static void print_ocfs2_dinode(void)
SHOW_OFFSET(struct ocfs2_dinode, i_dyn_features);
SHOW_OFFSET(struct ocfs2_dinode, i_xattr_loc);
SHOW_OFFSET(struct ocfs2_dinode, i_check);
+ SHOW_OFFSET(struct ocfs2_dinode, i_dx_root);
+ SHOW_OFFSET(struct ocfs2_dinode, i_refcount_loc);
+ SHOW_OFFSET(struct ocfs2_dinode, i_suballoc_loc);
SHOW_OFFSET(struct ocfs2_dinode, i_reserved2);
SHOW_OFFSET(struct ocfs2_dinode, id1.i_pad1);
@@ -249,6 +252,8 @@ static void print_ocfs2_group_desc(void)
SHOW_OFFSET(struct ocfs2_group_desc, bg_check);
SHOW_OFFSET(struct ocfs2_group_desc, bg_reserved2);
SHOW_OFFSET(struct ocfs2_group_desc, bg_bitmap);
+ SHOW_OFFSET(struct ocfs2_group_desc, bg_bitmap_filler);
+ SHOW_OFFSET(struct ocfs2_group_desc, bg_list);
END_TYPE(struct ocfs2_group_desc);
printf("\n");
--
1.5.5
More information about the Ocfs2-tools-devel
mailing list