diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-02-02 09:18:22 -0500 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-02-02 09:18:22 -0500 |
commit | eb60ceac0ebd11e9896ed1ca84fcad71a4b23601 (patch) | |
tree | 70d426737630b713bc18dc5ae8c342651f0f1f44 /fs/btrfs/ctree.h | |
parent | 4920c9ac9a4bbc6bf9acd8c614987ee6b378e78f (diff) |
Btrfs: Add backing store, memory management
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h new file mode 100644 index 000000000000..586bf1866042 --- /dev/null +++ b/fs/btrfs/ctree.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #ifndef __CTREE__ | ||
2 | #define __CTREE__ | ||
3 | |||
4 | #define CTREE_BLOCKSIZE 4096 | ||
5 | |||
6 | struct key { | ||
7 | u64 objectid; | ||
8 | u32 flags; | ||
9 | u64 offset; | ||
10 | } __attribute__ ((__packed__)); | ||
11 | |||
12 | struct header { | ||
13 | u64 fsid[2]; /* FS specific uuid */ | ||
14 | u64 blocknr; | ||
15 | u64 parentid; | ||
16 | u32 csum; | ||
17 | u32 ham; | ||
18 | u16 nritems; | ||
19 | u16 flags; | ||
20 | } __attribute__ ((__packed__)); | ||
21 | |||
22 | #define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct header)) / \ | ||
23 | (sizeof(struct key) + sizeof(u64))) | ||
24 | |||
25 | #define LEVEL_BITS 3 | ||
26 | #define MAX_LEVEL (1 << LEVEL_BITS) | ||
27 | #define node_level(f) ((f) & (MAX_LEVEL-1)) | ||
28 | #define is_leaf(f) (node_level(f) == 0) | ||
29 | |||
30 | struct tree_buffer; | ||
31 | struct ctree_root { | ||
32 | struct tree_buffer *node; | ||
33 | int fp; | ||
34 | struct radix_tree_root cache_radix; | ||
35 | }; | ||
36 | |||
37 | struct item { | ||
38 | struct key key; | ||
39 | u16 offset; | ||
40 | u16 size; | ||
41 | } __attribute__ ((__packed__)); | ||
42 | |||
43 | #define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct header)) | ||
44 | struct leaf { | ||
45 | struct header header; | ||
46 | union { | ||
47 | struct item items[LEAF_DATA_SIZE/sizeof(struct item)]; | ||
48 | u8 data[CTREE_BLOCKSIZE-sizeof(struct header)]; | ||
49 | }; | ||
50 | } __attribute__ ((__packed__)); | ||
51 | |||
52 | struct node { | ||
53 | struct header header; | ||
54 | struct key keys[NODEPTRS_PER_BLOCK]; | ||
55 | u64 blockptrs[NODEPTRS_PER_BLOCK]; | ||
56 | } __attribute__ ((__packed__)); | ||
57 | |||
58 | struct ctree_path { | ||
59 | struct tree_buffer *nodes[MAX_LEVEL]; | ||
60 | int slots[MAX_LEVEL]; | ||
61 | }; | ||
62 | #endif | ||