ctree.h (1d4f6404de26df49eb8452f8fdf7672b59f407fc) ctree.h (1e1d27017c5986c1ea81181506042cf9cba3f6ea)
1#ifndef __BTRFS__
2#define __BTRFS__
3
4#include "list.h"
5#include "kerncompat.h"
6
7#define BTRFS_MAGIC "_BtRfS_M"
8

--- 118 unchanged lines hidden (view full) ---

127 * items in the extent btree are used to record the objectid of the
128 * owner of the block and the number of references
129 */
130struct btrfs_extent_item {
131 __le32 refs;
132 __le64 owner;
133} __attribute__ ((__packed__));
134
1#ifndef __BTRFS__
2#define __BTRFS__
3
4#include "list.h"
5#include "kerncompat.h"
6
7#define BTRFS_MAGIC "_BtRfS_M"
8

--- 118 unchanged lines hidden (view full) ---

127 * items in the extent btree are used to record the objectid of the
128 * owner of the block and the number of references
129 */
130struct btrfs_extent_item {
131 __le32 refs;
132 __le64 owner;
133} __attribute__ ((__packed__));
134
135struct btrfs_inode_timespec {
136 __le32 sec;
137 __le32 nsec;
138} __attribute__ ((__packed__));
139
140/*
141 * there is no padding here on purpose. If you want to extent the inode,
142 * make a new item type
143 */
144struct btrfs_inode_item {
145 __le64 generation;
146 __le64 size;
147 __le64 nblocks;
148 __le32 nlink;
149 __le32 uid;
150 __le32 gid;
151 __le32 mode;
152 __le32 rdev;
153 __le16 flags;
154 __le16 compat_flags;
155 struct btrfs_inode_timespec atime;
156 struct btrfs_inode_timespec ctime;
157 struct btrfs_inode_timespec mtime;
158 struct btrfs_inode_timespec otime;
159} __attribute__ ((__packed__));
160
161/* inline data is just a blob of bytes */
162struct btrfs_inline_data_item {
163 u8 data;
164} __attribute__ ((__packed__));
165
135struct btrfs_dir_item {
136 __le64 objectid;
137 __le16 flags;
138 u8 type;
139} __attribute__ ((__packed__));
140
141struct btrfs_root_item {
142 __le64 blocknr;

--- 22 unchanged lines hidden (view full) ---

165 struct list_head cache;
166 int cache_size;
167 int ref_cows;
168 struct btrfs_root_item root_item;
169 struct btrfs_key root_key;
170 u32 blocksize;
171};
172
166struct btrfs_dir_item {
167 __le64 objectid;
168 __le16 flags;
169 u8 type;
170} __attribute__ ((__packed__));
171
172struct btrfs_root_item {
173 __le64 blocknr;

--- 22 unchanged lines hidden (view full) ---

196 struct list_head cache;
197 int cache_size;
198 int ref_cows;
199 struct btrfs_root_item root_item;
200 struct btrfs_key root_key;
201 u32 blocksize;
202};
203
173
174/* the lower bits in the key flags defines the item type */
175#define BTRFS_KEY_TYPE_MAX 256
176#define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1)
204/* the lower bits in the key flags defines the item type */
205#define BTRFS_KEY_TYPE_MAX 256
206#define BTRFS_KEY_TYPE_MASK (BTRFS_KEY_TYPE_MAX - 1)
207
208/*
209 * inode items have the data typically returned from stat and store other
210 * info about object characteristics. There is one for every file and dir in
211 * the FS
212 */
177#define BTRFS_INODE_ITEM_KEY 1
213#define BTRFS_INODE_ITEM_KEY 1
214
215/*
216 * dir items are the name -> inode pointers in a directory. There is one
217 * for every name in a directory.
218 */
178#define BTRFS_DIR_ITEM_KEY 2
219#define BTRFS_DIR_ITEM_KEY 2
179#define BTRFS_ROOT_ITEM_KEY 3
180#define BTRFS_EXTENT_ITEM_KEY 4
181#define BTRFS_STRING_ITEM_KEY 5
220/*
221 * inline data is file data that fits in the btree.
222 */
223#define BTRFS_INLINE_DATA_KEY 3
224/*
225 * extent data is for data that can't fit in the btree. It points to
226 * a (hopefully) huge chunk of disk
227 */
228#define BTRFS_EXTENT_DATA_KEY 4
229/*
230 * root items point to tree roots. There are typically in the root
231 * tree used by the super block to find all the other trees
232 */
233#define BTRFS_ROOT_ITEM_KEY 5
234/*
235 * extent items are in the extent map tree. These record which blocks
236 * are used, and how many references there are to each block
237 */
238#define BTRFS_EXTENT_ITEM_KEY 6
239/*
240 * string items are for debugging. They just store a short string of
241 * data in the FS
242 */
243#define BTRFS_STRING_ITEM_KEY 7
182
244
245static inline u64 btrfs_inode_generation(struct btrfs_inode_item *i)
246{
247 return le64_to_cpu(i->generation);
248}
249
250static inline void btrfs_set_inode_generation(struct btrfs_inode_item *i,
251 u64 val)
252{
253 i->generation = cpu_to_le64(val);
254}
255
256static inline u64 btrfs_inode_size(struct btrfs_inode_item *i)
257{
258 return le64_to_cpu(i->size);
259}
260
261static inline void btrfs_set_inode_size(struct btrfs_inode_item *i, u64 val)
262{
263 i->size = cpu_to_le64(val);
264}
265
266static inline u64 btrfs_inode_nblocks(struct btrfs_inode_item *i)
267{
268 return le64_to_cpu(i->nblocks);
269}
270
271static inline void btrfs_set_inode_nblocks(struct btrfs_inode_item *i, u64 val)
272{
273 i->nblocks = cpu_to_le64(val);
274}
275
276static inline u32 btrfs_inode_nlink(struct btrfs_inode_item *i)
277{
278 return le32_to_cpu(i->nlink);
279}
280
281static inline void btrfs_set_inode_nlink(struct btrfs_inode_item *i, u32 val)
282{
283 i->nlink = cpu_to_le32(val);
284}
285
286static inline u32 btrfs_inode_uid(struct btrfs_inode_item *i)
287{
288 return le32_to_cpu(i->uid);
289}
290
291static inline void btrfs_set_inode_uid(struct btrfs_inode_item *i, u32 val)
292{
293 i->uid = cpu_to_le32(val);
294}
295
296static inline u32 btrfs_inode_gid(struct btrfs_inode_item *i)
297{
298 return le32_to_cpu(i->gid);
299}
300
301static inline void btrfs_set_inode_gid(struct btrfs_inode_item *i, u32 val)
302{
303 i->gid = cpu_to_le32(val);
304}
305
306static inline u32 btrfs_inode_mode(struct btrfs_inode_item *i)
307{
308 return le32_to_cpu(i->mode);
309}
310
311static inline void btrfs_set_inode_mode(struct btrfs_inode_item *i, u32 val)
312{
313 i->mode = cpu_to_le32(val);
314}
315
316static inline u32 btrfs_inode_rdev(struct btrfs_inode_item *i)
317{
318 return le32_to_cpu(i->rdev);
319}
320
321static inline void btrfs_set_inode_rdev(struct btrfs_inode_item *i, u32 val)
322{
323 i->rdev = cpu_to_le32(val);
324}
325
326static inline u16 btrfs_inode_flags(struct btrfs_inode_item *i)
327{
328 return le16_to_cpu(i->flags);
329}
330
331static inline void btrfs_set_inode_flags(struct btrfs_inode_item *i, u16 val)
332{
333 i->flags = cpu_to_le16(val);
334}
335
336static inline u16 btrfs_inode_compat_flags(struct btrfs_inode_item *i)
337{
338 return le16_to_cpu(i->compat_flags);
339}
340
341static inline void btrfs_set_inode_compat_flags(struct btrfs_inode_item *i,
342 u16 val)
343{
344 i->compat_flags = cpu_to_le16(val);
345}
346
347
183static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei)
184{
185 return le64_to_cpu(ei->owner);
186}
187
188static inline void btrfs_set_extent_owner(struct btrfs_extent_item *ei, u64 val)
189{
190 ei->owner = cpu_to_le64(val);

--- 148 unchanged lines hidden (view full) ---

339static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u32 type)
340{
341 u32 flags = btrfs_disk_key_flags(key);
342 BUG_ON(type >= BTRFS_KEY_TYPE_MAX);
343 flags = (flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type;
344 btrfs_set_disk_key_flags(key, flags);
345}
346
348static inline u64 btrfs_extent_owner(struct btrfs_extent_item *ei)
349{
350 return le64_to_cpu(ei->owner);
351}
352
353static inline void btrfs_set_extent_owner(struct btrfs_extent_item *ei, u64 val)
354{
355 ei->owner = cpu_to_le64(val);

--- 148 unchanged lines hidden (view full) ---

504static inline void btrfs_set_disk_key_type(struct btrfs_disk_key *key, u32 type)
505{
506 u32 flags = btrfs_disk_key_flags(key);
507 BUG_ON(type >= BTRFS_KEY_TYPE_MAX);
508 flags = (flags & ~((u64)BTRFS_KEY_TYPE_MASK)) | type;
509 btrfs_set_disk_key_flags(key, flags);
510}
511
347
348
349static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
350{
351 return le64_to_cpu(h->blocknr);
352}
353
354static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
355{
356 h->blocknr = cpu_to_le64(blocknr);

--- 163 unchanged lines hidden ---
512static inline u64 btrfs_header_blocknr(struct btrfs_header *h)
513{
514 return le64_to_cpu(h->blocknr);
515}
516
517static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
518{
519 h->blocknr = cpu_to_le64(blocknr);

--- 163 unchanged lines hidden ---