aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h62
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
6struct key {
7 u64 objectid;
8 u32 flags;
9 u64 offset;
10} __attribute__ ((__packed__));
11
12struct 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
30struct tree_buffer;
31struct ctree_root {
32 struct tree_buffer *node;
33 int fp;
34 struct radix_tree_root cache_radix;
35};
36
37struct 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))
44struct 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
52struct node {
53 struct header header;
54 struct key keys[NODEPTRS_PER_BLOCK];
55 u64 blockptrs[NODEPTRS_PER_BLOCK];
56} __attribute__ ((__packed__));
57
58struct ctree_path {
59 struct tree_buffer *nodes[MAX_LEVEL];
60 int slots[MAX_LEVEL];
61};
62#endif