diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-12-11 09:25:06 -0500 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2008-09-25 11:03:58 -0400 |
commit | 74493f7a59bfd4d1c7029c74ab2cd0e400612c6b (patch) | |
tree | b5fc75b08d2edcf8218c814ea02ab6c548e73652 /fs/btrfs/ctree.h | |
parent | 17636e03f42a1a42fed3834859de4702bd655fd1 (diff) |
Btrfs: Implement generation numbers in block pointers
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/ctree.h')
-rw-r--r-- | fs/btrfs/ctree.h | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h index 9bc1b0a8615f..fd58dd846e61 100644 --- a/fs/btrfs/ctree.h +++ b/fs/btrfs/ctree.h | |||
@@ -110,7 +110,7 @@ struct btrfs_header { | |||
110 | #define BTRFS_MAX_LEVEL 8 | 110 | #define BTRFS_MAX_LEVEL 8 |
111 | #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ | 111 | #define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \ |
112 | sizeof(struct btrfs_header)) / \ | 112 | sizeof(struct btrfs_header)) / \ |
113 | (sizeof(struct btrfs_disk_key) + sizeof(u64))) | 113 | sizeof(struct btrfs_key_ptr)) |
114 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) | 114 | #define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header)) |
115 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize)) | 115 | #define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->leafsize)) |
116 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ | 116 | #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \ |
@@ -168,6 +168,7 @@ struct btrfs_leaf { | |||
168 | struct btrfs_key_ptr { | 168 | struct btrfs_key_ptr { |
169 | struct btrfs_disk_key key; | 169 | struct btrfs_disk_key key; |
170 | __le64 blockptr; | 170 | __le64 blockptr; |
171 | __le64 generation; | ||
171 | } __attribute__ ((__packed__)); | 172 | } __attribute__ ((__packed__)); |
172 | 173 | ||
173 | struct btrfs_node { | 174 | struct btrfs_node { |
@@ -196,7 +197,13 @@ struct btrfs_path { | |||
196 | */ | 197 | */ |
197 | struct btrfs_extent_item { | 198 | struct btrfs_extent_item { |
198 | __le32 refs; | 199 | __le32 refs; |
199 | __le64 owner; | 200 | } __attribute__ ((__packed__)); |
201 | |||
202 | struct btrfs_extent_ref { | ||
203 | __le64 root; | ||
204 | __le64 generation; | ||
205 | __le64 objectid; | ||
206 | __le64 offset; | ||
200 | } __attribute__ ((__packed__)); | 207 | } __attribute__ ((__packed__)); |
201 | 208 | ||
202 | struct btrfs_inode_timespec { | 209 | struct btrfs_inode_timespec { |
@@ -402,12 +409,13 @@ struct btrfs_root { | |||
402 | * are used, and how many references there are to each block | 409 | * are used, and how many references there are to each block |
403 | */ | 410 | */ |
404 | #define BTRFS_EXTENT_ITEM_KEY 33 | 411 | #define BTRFS_EXTENT_ITEM_KEY 33 |
412 | #define BTRFS_EXTENT_REF_KEY 34 | ||
405 | 413 | ||
406 | /* | 414 | /* |
407 | * block groups give us hints into the extent allocation trees. Which | 415 | * block groups give us hints into the extent allocation trees. Which |
408 | * blocks are free etc etc | 416 | * blocks are free etc etc |
409 | */ | 417 | */ |
410 | #define BTRFS_BLOCK_GROUP_ITEM_KEY 34 | 418 | #define BTRFS_BLOCK_GROUP_ITEM_KEY 50 |
411 | 419 | ||
412 | /* | 420 | /* |
413 | * string items are for debugging. They just store a short string of | 421 | * string items are for debugging. They just store a short string of |
@@ -529,15 +537,25 @@ BTRFS_SETGET_FUNCS(timespec_nsec, struct btrfs_inode_timespec, nsec, 32); | |||
529 | 537 | ||
530 | /* struct btrfs_extent_item */ | 538 | /* struct btrfs_extent_item */ |
531 | BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); | 539 | BTRFS_SETGET_FUNCS(extent_refs, struct btrfs_extent_item, refs, 32); |
532 | BTRFS_SETGET_FUNCS(extent_owner, struct btrfs_extent_item, owner, 64); | 540 | |
541 | /* struct btrfs_extent_ref */ | ||
542 | BTRFS_SETGET_FUNCS(ref_root, struct btrfs_extent_ref, root, 64); | ||
543 | BTRFS_SETGET_FUNCS(ref_generation, struct btrfs_extent_ref, generation, 64); | ||
544 | BTRFS_SETGET_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); | ||
545 | BTRFS_SETGET_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64); | ||
546 | |||
547 | BTRFS_SETGET_STACK_FUNCS(ref_root, struct btrfs_extent_ref, root, 64); | ||
548 | BTRFS_SETGET_STACK_FUNCS(ref_generation, struct btrfs_extent_ref, | ||
549 | generation, 64); | ||
550 | BTRFS_SETGET_STACK_FUNCS(ref_objectid, struct btrfs_extent_ref, objectid, 64); | ||
551 | BTRFS_SETGET_STACK_FUNCS(ref_offset, struct btrfs_extent_ref, offset, 64); | ||
533 | 552 | ||
534 | BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, | 553 | BTRFS_SETGET_STACK_FUNCS(stack_extent_refs, struct btrfs_extent_item, |
535 | refs, 32); | 554 | refs, 32); |
536 | BTRFS_SETGET_STACK_FUNCS(stack_extent_owner, struct btrfs_extent_item, | ||
537 | owner, 64); | ||
538 | 555 | ||
539 | /* struct btrfs_node */ | 556 | /* struct btrfs_node */ |
540 | BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); | 557 | BTRFS_SETGET_FUNCS(key_blockptr, struct btrfs_key_ptr, blockptr, 64); |
558 | BTRFS_SETGET_FUNCS(key_generation, struct btrfs_key_ptr, generation, 64); | ||
541 | 559 | ||
542 | static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr) | 560 | static inline u64 btrfs_node_blockptr(struct extent_buffer *eb, int nr) |
543 | { | 561 | { |
@@ -556,6 +574,23 @@ static inline void btrfs_set_node_blockptr(struct extent_buffer *eb, | |||
556 | btrfs_set_key_blockptr(eb, (struct btrfs_key_ptr *)ptr, val); | 574 | btrfs_set_key_blockptr(eb, (struct btrfs_key_ptr *)ptr, val); |
557 | } | 575 | } |
558 | 576 | ||
577 | static inline u64 btrfs_node_ptr_generation(struct extent_buffer *eb, int nr) | ||
578 | { | ||
579 | unsigned long ptr; | ||
580 | ptr = offsetof(struct btrfs_node, ptrs) + | ||
581 | sizeof(struct btrfs_key_ptr) * nr; | ||
582 | return btrfs_key_generation(eb, (struct btrfs_key_ptr *)ptr); | ||
583 | } | ||
584 | |||
585 | static inline void btrfs_set_node_ptr_generation(struct extent_buffer *eb, | ||
586 | int nr, u64 val) | ||
587 | { | ||
588 | unsigned long ptr; | ||
589 | ptr = offsetof(struct btrfs_node, ptrs) + | ||
590 | sizeof(struct btrfs_key_ptr) * nr; | ||
591 | btrfs_set_key_generation(eb, (struct btrfs_key_ptr *)ptr, val); | ||
592 | } | ||
593 | |||
559 | static inline unsigned long btrfs_node_key_ptr_offset(int nr) | 594 | static inline unsigned long btrfs_node_key_ptr_offset(int nr) |
560 | { | 595 | { |
561 | return offsetof(struct btrfs_node, ptrs) + | 596 | return offsetof(struct btrfs_node, ptrs) + |