Skip to contentSkip to conversation

add generic btree types

PATCH In review Christoph Hellwig 2 participants 2 messages Jul 23, 2008 – Jul 24, 2008 XFS filesystem

lore
Share & tools
lore
#0 lore raw

PATCH 4/15 add generic btree types

Add generic union types for btree pointers, keys and records. The generic btree pointer contains a 32 and 64bit big endian type for short and long form btrees, and the key and record contain the relevant type for each possible btree.

Split out from a bigger patch from Dave Chinner and simplified a little further.

fs/xfs/xfs_btree.h +25 -0
Index: linux-2.6-xfs/fs/xfs/xfs_btree.h
===================================================================
@@ -70,6 +70,12 @@ typedef struct xfs_btree_hdr
 	__be16		bb_numrecs;	/* current # of data records */
 } xfs_btree_hdr_t;
 
+/*
+ * Generic block, key, ptr and record wrapper structures
+ * These are disk format structures, and are converted where
+ * necessary be the btree specific code that needs to interpret
+ * them.
+ */
 typedef struct xfs_btree_block {
 	xfs_btree_hdr_t	bb_h;		/* header */
 	union {
@@ -84,6 +90,25 @@ typedef struct xfs_btree_block {
 	} bb_u;				/* rest */
 } xfs_btree_block_t;
 
+union xfs_btree_ptr {
+	__be32			s;	/* short form ptr */
+	__be64			l;	/* long form ptr */
+};
+
+union xfs_btree_key {
+	xfs_bmbt_key_t		bmbt;
+	xfs_bmdr_key_t		bmbr;	/* bmbt root block */
+	xfs_alloc_key_t		alloc;
+	xfs_inobt_key_t		inobt;
+};
+
+union xfs_btree_rec {
+	xfs_bmbt_rec_t		bmbt;
+	xfs_bmdr_rec_t		bmbr;	/* bmbt root block */
+	xfs_alloc_rec_t		alloc;
+	xfs_inobt_rec_t		inobt;
+};
+
 /*
  * For logging record fields.
  */
#1 lore raw
Quoted 7 lines · Christoph Hellwig

Add generic union types for btree pointers, keys and records. The generic btree pointer contains a 32 and 64bit big endian type for short and long form btrees, and the key and record contain the relevant type for each possible btree.

Split out from a bigger patch from Dave Chinner and simplified a little further.

Looks good.

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]