aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/ctree.h
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2007-03-13 10:46:10 -0400
committerDavid Woodhouse <dwmw2@hera.kernel.org>2007-03-13 10:46:10 -0400
commit234b63a091e1df6bd4261dd7b3a7490074830628 (patch)
tree1947f6e49aa3c19017c948205378c5cb76a7b536 /fs/btrfs/ctree.h
parentcf27e1eec063fa68a89c57ae0a83f93aa38851d6 (diff)
rename funcs and structs to btrfs
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r--fs/btrfs/ctree.h95
1 files changed, 48 insertions, 47 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index 90cc2c9bd79e..5dfcc90812c1 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -1,10 +1,10 @@
1#ifndef __CTREE__ 1#ifndef __BTRFS__
2#define __CTREE__ 2#define __BTRFS__
3 3
4#include "list.h" 4#include "list.h"
5#include "kerncompat.h" 5#include "kerncompat.h"
6 6
7#define CTREE_BLOCKSIZE 1024 7#define BTRFS_BLOCKSIZE 1024
8 8
9/* 9/*
10 * the key defines the order in the tree, and so it also defines (optimal) 10 * the key defines the order in the tree, and so it also defines (optimal)
@@ -46,21 +46,21 @@ struct btrfs_header {
46 /* generation flags to be added */ 46 /* generation flags to be added */
47} __attribute__ ((__packed__)); 47} __attribute__ ((__packed__));
48 48
49#define MAX_LEVEL 8 49#define BTRFS_MAX_LEVEL 8
50#define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) / \ 50#define NODEPTRS_PER_BLOCK ((BTRFS_BLOCKSIZE - sizeof(struct btrfs_header)) / \
51 (sizeof(struct btrfs_disk_key) + sizeof(u64))) 51 (sizeof(struct btrfs_disk_key) + sizeof(u64)))
52 52
53struct tree_buffer; 53struct btrfs_buffer;
54 54
55/* 55/*
56 * in ram representation of the tree. extent_root is used for all allocations 56 * in ram representation of the tree. extent_root is used for all allocations
57 * and for the extent tree extent_root root. current_insert is used 57 * and for the extent tree extent_root root. current_insert is used
58 * only for the extent tree. 58 * only for the extent tree.
59 */ 59 */
60struct ctree_root { 60struct btrfs_root {
61 struct tree_buffer *node; 61 struct btrfs_buffer *node;
62 struct tree_buffer *commit_root; 62 struct btrfs_buffer *commit_root;
63 struct ctree_root *extent_root; 63 struct btrfs_root *extent_root;
64 struct btrfs_key current_insert; 64 struct btrfs_key current_insert;
65 struct btrfs_key last_insert; 65 struct btrfs_key last_insert;
66 int fp; 66 int fp;
@@ -74,7 +74,7 @@ struct ctree_root {
74/* 74/*
75 * describes a tree on disk 75 * describes a tree on disk
76 */ 76 */
77struct ctree_root_info { 77struct btrfs_root_info {
78 u64 fsid[2]; /* FS specific uuid */ 78 u64 fsid[2]; /* FS specific uuid */
79 u64 blocknr; /* blocknr of this block */ 79 u64 blocknr; /* blocknr of this block */
80 u64 objectid; /* inode number of this root */ 80 u64 objectid; /* inode number of this root */
@@ -88,9 +88,9 @@ struct ctree_root_info {
88 * the super block basically lists the main trees of the FS 88 * the super block basically lists the main trees of the FS
89 * it currently lacks any block count etc etc 89 * it currently lacks any block count etc etc
90 */ 90 */
91struct ctree_super_block { 91struct btrfs_super_block {
92 struct ctree_root_info root_info; 92 struct btrfs_root_info root_info;
93 struct ctree_root_info extent_info; 93 struct btrfs_root_info extent_info;
94} __attribute__ ((__packed__)); 94} __attribute__ ((__packed__));
95 95
96/* 96/*
@@ -111,13 +111,13 @@ struct btrfs_item {
111 * The data is separate from the items to get the keys closer together 111 * The data is separate from the items to get the keys closer together
112 * during searches. 112 * during searches.
113 */ 113 */
114#define LEAF_DATA_SIZE (CTREE_BLOCKSIZE - sizeof(struct btrfs_header)) 114#define LEAF_DATA_SIZE (BTRFS_BLOCKSIZE - sizeof(struct btrfs_header))
115struct leaf { 115struct btrfs_leaf {
116 struct btrfs_header header; 116 struct btrfs_header header;
117 union { 117 union {
118 struct btrfs_item items[LEAF_DATA_SIZE/ 118 struct btrfs_item items[LEAF_DATA_SIZE/
119 sizeof(struct btrfs_item)]; 119 sizeof(struct btrfs_item)];
120 u8 data[CTREE_BLOCKSIZE-sizeof(struct btrfs_header)]; 120 u8 data[BTRFS_BLOCKSIZE - sizeof(struct btrfs_header)];
121 }; 121 };
122} __attribute__ ((__packed__)); 122} __attribute__ ((__packed__));
123 123
@@ -125,7 +125,7 @@ struct leaf {
125 * all non-leaf blocks are nodes, they hold only keys and pointers to 125 * all non-leaf blocks are nodes, they hold only keys and pointers to
126 * other blocks 126 * other blocks
127 */ 127 */
128struct node { 128struct btrfs_node {
129 struct btrfs_header header; 129 struct btrfs_header header;
130 struct btrfs_disk_key keys[NODEPTRS_PER_BLOCK]; 130 struct btrfs_disk_key keys[NODEPTRS_PER_BLOCK];
131 __le64 blockptrs[NODEPTRS_PER_BLOCK]; 131 __le64 blockptrs[NODEPTRS_PER_BLOCK];
@@ -135,50 +135,51 @@ struct node {
135 * items in the extent btree are used to record the objectid of the 135 * items in the extent btree are used to record the objectid of the
136 * owner of the block and the number of references 136 * owner of the block and the number of references
137 */ 137 */
138struct extent_item { 138struct btrfs_extent_item {
139 __le32 refs; 139 __le32 refs;
140 __le64 owner; 140 __le64 owner;
141} __attribute__ ((__packed__)); 141} __attribute__ ((__packed__));
142 142
143/* 143/*
144 * ctree_paths remember the path taken from the root down to the leaf. 144 * btrfs_paths remember the path taken from the root down to the leaf.
145 * level 0 is always the leaf, and nodes[1...MAX_LEVEL] will point 145 * level 0 is always the leaf, and nodes[1...BTRFS_MAX_LEVEL] will point
146 * to any other levels that are present. 146 * to any other levels that are present.
147 * 147 *
148 * The slots array records the index of the item or block pointer 148 * The slots array records the index of the item or block pointer
149 * used while walking the tree. 149 * used while walking the tree.
150 */ 150 */
151struct ctree_path { 151struct btrfs_path {
152 struct tree_buffer *nodes[MAX_LEVEL]; 152 struct btrfs_buffer *nodes[BTRFS_MAX_LEVEL];
153 int slots[MAX_LEVEL]; 153 int slots[BTRFS_MAX_LEVEL];
154}; 154};
155 155
156static inline u64 btrfs_extent_owner(struct extent_item *ei) 156static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei)
157{ 157{
158 return le64_to_cpu(ei->owner); 158 return le64_to_cpu(ei->owner);
159} 159}
160 160
161static inline void btrfs_set_extent_owner(struct extent_item *ei, u64 val) 161static inline void btrfs_set_extent_owner(struct btrfs_extent_item *ei, u64 val)
162{ 162{
163 ei->owner = cpu_to_le64(val); 163 ei->owner = cpu_to_le64(val);
164} 164}
165 165
166static inline u32 btrfs_extent_refs(struct extent_item *ei) 166static inline u32 btrfs_extent_refs(struct btrfs_extent_item *ei)
167{ 167{
168 return le32_to_cpu(ei->refs); 168 return le32_to_cpu(ei->refs);
169} 169}
170 170
171static inline void btrfs_set_extent_refs(struct extent_item *ei, u32 val) 171static inline void btrfs_set_extent_refs(struct btrfs_extent_item *ei, u32 val)
172{ 172{
173 ei->refs = cpu_to_le32(val); 173 ei->refs = cpu_to_le32(val);
174} 174}
175 175
176static inline u64 btrfs_node_blockptr(struct node *n, int nr) 176static inline u64 btrfs_node_blockptr(struct btrfs_node *n, int nr)
177{ 177{
178 return le64_to_cpu(n->blockptrs[nr]); 178 return le64_to_cpu(n->blockptrs[nr]);
179} 179}
180 180
181static inline void btrfs_set_node_blockptr(struct node *n, int nr, u64 val) 181static inline void btrfs_set_node_blockptr(struct btrfs_node *n, int nr,
182 u64 val)
182{ 183{
183 n->blockptrs[nr] = cpu_to_le64(val); 184 n->blockptrs[nr] = cpu_to_le64(val);
184} 185}
@@ -300,34 +301,34 @@ static inline void btrfs_set_header_flags(struct btrfs_header *h, u16 val)
300 301
301static inline int btrfs_header_level(struct btrfs_header *h) 302static inline int btrfs_header_level(struct btrfs_header *h)
302{ 303{
303 return btrfs_header_flags(h) & (MAX_LEVEL - 1); 304 return btrfs_header_flags(h) & (BTRFS_MAX_LEVEL - 1);
304} 305}
305 306
306static inline void btrfs_set_header_level(struct btrfs_header *h, int level) 307static inline void btrfs_set_header_level(struct btrfs_header *h, int level)
307{ 308{
308 u16 flags; 309 u16 flags;
309 BUG_ON(level > MAX_LEVEL); 310 BUG_ON(level > BTRFS_MAX_LEVEL);
310 flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1); 311 flags = btrfs_header_flags(h) & ~(BTRFS_MAX_LEVEL - 1);
311 btrfs_set_header_flags(h, flags | level); 312 btrfs_set_header_flags(h, flags | level);
312} 313}
313 314
314static inline int btrfs_is_leaf(struct node *n) 315static inline int btrfs_is_leaf(struct btrfs_node *n)
315{ 316{
316 return (btrfs_header_level(&n->header) == 0); 317 return (btrfs_header_level(&n->header) == 0);
317} 318}
318 319
319struct tree_buffer *alloc_free_block(struct ctree_root *root); 320struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_root *root);
320int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf); 321int btrfs_inc_ref(struct btrfs_root *root, struct btrfs_buffer *buf);
321int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks); 322int btrfs_free_extent(struct btrfs_root *root, u64 blocknr, u64 num_blocks);
322int search_slot(struct ctree_root *root, struct btrfs_key *key, 323int btrfs_search_slot(struct btrfs_root *root, struct btrfs_key *key,
323 struct ctree_path *p, int ins_len, int cow); 324 struct btrfs_path *p, int ins_len, int cow);
324void release_path(struct ctree_root *root, struct ctree_path *p); 325void btrfs_release_path(struct btrfs_root *root, struct btrfs_path *p);
325void init_path(struct ctree_path *p); 326void btrfs_init_path(struct btrfs_path *p);
326int del_item(struct ctree_root *root, struct ctree_path *path); 327int btrfs_del_item(struct btrfs_root *root, struct btrfs_path *path);
327int insert_item(struct ctree_root *root, struct btrfs_key *key, 328int btrfs_insert_item(struct btrfs_root *root, struct btrfs_key *key,
328 void *data, int data_size); 329 void *data, int data_size);
329int next_leaf(struct ctree_root *root, struct ctree_path *path); 330int btrfs_next_leaf(struct btrfs_root *root, struct btrfs_path *path);
330int leaf_free_space(struct leaf *leaf); 331int btrfs_leaf_free_space(struct btrfs_leaf *leaf);
331int btrfs_drop_snapshot(struct ctree_root *root, struct tree_buffer *snap); 332int btrfs_drop_snapshot(struct btrfs_root *root, struct btrfs_buffer *snap);
332int btrfs_finish_extent_commit(struct ctree_root *root); 333int btrfs_finish_extent_commit(struct btrfs_root *root);
333#endif 334#endif