]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - fs/btrfs/ctree.h
Btrfs: Add backing store, memory management
[mirror_ubuntu-bionic-kernel.git] / fs / btrfs / ctree.h
CommitLineData
eb60ceac
CM
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