diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-03-12 12:01:18 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-03-12 12:01:18 -0400 |
commit | 7518a238ea0152dc849d1ed76d3cae8b44e12f46 (patch) | |
tree | 97e5c285f10bdb2576046e7bb15d239471815c28 /fs/btrfs/ctree.h | |
parent | 83e15a28e046dbb4534dd263d1d3dc867a8994a2 (diff) |
Btrfs: get/set for struct header fields
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 63 |
1 files changed, 59 insertions, 4 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 518326fa3694..60c21fe1566a 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -35,13 +35,10 @@ struct header { | |||
35 | /* generation flags to be added */ | 35 | /* generation flags to be added */ |
36 | } __attribute__ ((__packed__)); | 36 | } __attribute__ ((__packed__)); |
37 | 37 | ||
38 | #define MAX_LEVEL 8 | ||
38 | #define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct header)) / \ | 39 | #define NODEPTRS_PER_BLOCK ((CTREE_BLOCKSIZE - sizeof(struct header)) / \ |
39 | (sizeof(struct key) + sizeof(u64))) | 40 | (sizeof(struct key) + sizeof(u64))) |
40 | 41 | ||
41 | #define MAX_LEVEL 8 | ||
42 | #define node_level(f) ((f) & (MAX_LEVEL-1)) | ||
43 | #define is_leaf(f) (node_level(f) == 0) | ||
44 | |||
45 | struct tree_buffer; | 42 | struct tree_buffer; |
46 | 43 | ||
47 | /* | 44 | /* |
@@ -144,6 +141,64 @@ struct ctree_path { | |||
144 | int slots[MAX_LEVEL]; | 141 | int slots[MAX_LEVEL]; |
145 | }; | 142 | }; |
146 | 143 | ||
144 | static inline u64 btrfs_header_blocknr(struct header *h) | ||
145 | { | ||
146 | return h->blocknr; | ||
147 | } | ||
148 | |||
149 | static inline void btrfs_set_header_blocknr(struct header *h, u64 blocknr) | ||
150 | { | ||
151 | h->blocknr = blocknr; | ||
152 | } | ||
153 | |||
154 | static inline u64 btrfs_header_parentid(struct header *h) | ||
155 | { | ||
156 | return h->parentid; | ||
157 | } | ||
158 | |||
159 | static inline void btrfs_set_header_parentid(struct header *h, u64 parentid) | ||
160 | { | ||
161 | h->parentid = parentid; | ||
162 | } | ||
163 | |||
164 | static inline u32 btrfs_header_nritems(struct header *h) | ||
165 | { | ||
166 | return h->nritems; | ||
167 | } | ||
168 | |||
169 | static inline void btrfs_set_header_nritems(struct header *h, u32 val) | ||
170 | { | ||
171 | h->nritems = val; | ||
172 | } | ||
173 | |||
174 | static inline u32 btrfs_header_flags(struct header *h) | ||
175 | { | ||
176 | return h->flags; | ||
177 | } | ||
178 | |||
179 | static inline void btrfs_set_header_flags(struct header *h, u32 val) | ||
180 | { | ||
181 | h->flags = val; | ||
182 | } | ||
183 | |||
184 | static inline int btrfs_header_level(struct header *h) | ||
185 | { | ||
186 | return btrfs_header_flags(h) & (MAX_LEVEL - 1); | ||
187 | } | ||
188 | |||
189 | static inline void btrfs_set_header_level(struct header *h, int level) | ||
190 | { | ||
191 | u32 flags; | ||
192 | BUG_ON(level > MAX_LEVEL); | ||
193 | flags = btrfs_header_flags(h) & ~(MAX_LEVEL - 1); | ||
194 | btrfs_set_header_flags(h, flags | level); | ||
195 | } | ||
196 | |||
197 | static inline int btrfs_is_leaf(struct node *n) | ||
198 | { | ||
199 | return (btrfs_header_level(&n->header) == 0); | ||
200 | } | ||
201 | |||
147 | struct tree_buffer *alloc_free_block(struct ctree_root *root); | 202 | struct tree_buffer *alloc_free_block(struct ctree_root *root); |
148 | int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf); | 203 | int btrfs_inc_ref(struct ctree_root *root, struct tree_buffer *buf); |
149 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks); | 204 | int free_extent(struct ctree_root *root, u64 blocknr, u64 num_blocks); |