mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/kdave/btrfs-progs.git
synced 2024-11-16 08:44:31 +08:00
generations on headers
This commit is contained in:
parent
9fb549a6c1
commit
132db51b1f
12
ctree.h
12
ctree.h
@ -45,6 +45,7 @@ struct btrfs_key {
|
||||
struct btrfs_header {
|
||||
u8 fsid[16]; /* FS specific uuid */
|
||||
__le64 blocknr; /* which block this node is supposed to live in */
|
||||
__le64 generation;
|
||||
__le64 parentid; /* objectid of the tree root */
|
||||
__le32 csum;
|
||||
__le32 ham;
|
||||
@ -572,6 +573,17 @@ static inline void btrfs_set_header_blocknr(struct btrfs_header *h, u64 blocknr)
|
||||
h->blocknr = cpu_to_le64(blocknr);
|
||||
}
|
||||
|
||||
static inline u64 btrfs_header_generation(struct btrfs_header *h)
|
||||
{
|
||||
return le64_to_cpu(h->generation);
|
||||
}
|
||||
|
||||
static inline void btrfs_set_header_generation(struct btrfs_header *h,
|
||||
u64 val)
|
||||
{
|
||||
h->generation = cpu_to_le64(val);
|
||||
}
|
||||
|
||||
static inline u64 btrfs_header_parentid(struct btrfs_header *h)
|
||||
{
|
||||
return le64_to_cpu(h->parentid);
|
||||
|
@ -459,6 +459,8 @@ struct btrfs_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans,
|
||||
}
|
||||
buf = find_tree_block(root, ins.objectid);
|
||||
dirty_tree_block(trans, root, buf);
|
||||
btrfs_set_header_generation(&buf->node.header,
|
||||
root->root_key.offset + 1);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
2
hasher.c
2
hasher.c
@ -15,6 +15,8 @@ int main() {
|
||||
break;
|
||||
if (strlen(line) == 0)
|
||||
continue;
|
||||
if (line[strlen(line)-1] == '\n')
|
||||
line[strlen(line)-1] = '\0';
|
||||
ret = btrfs_name_hash(line, strlen(line), &result);
|
||||
BUG_ON(ret);
|
||||
printf("hash returns %Lu\n", result);
|
||||
|
1
mkfs.c
1
mkfs.c
@ -114,6 +114,7 @@ int mkfs(int fd, u64 num_blocks, u32 blocksize)
|
||||
BTRFS_ROOT_TREE_OBJECTID);
|
||||
btrfs_set_header_blocknr(&empty_leaf->header, start_block + 1);
|
||||
btrfs_set_header_nritems(&empty_leaf->header, 3);
|
||||
btrfs_set_header_generation(&empty_leaf->header, 0);
|
||||
|
||||
/* create the items for the root tree */
|
||||
btrfs_set_root_blocknr(&root_item, start_block + 2);
|
||||
|
13
print-tree.c
13
print-tree.c
@ -17,9 +17,11 @@ void btrfs_print_leaf(struct btrfs_root *root, struct btrfs_leaf *l)
|
||||
struct btrfs_inode_item *ii;
|
||||
u32 type;
|
||||
|
||||
printf("leaf %Lu total ptrs %d free space %d\n",
|
||||
printf("leaf %Lu ptrs %d free space %d parent %Lu generation %Lu\n",
|
||||
btrfs_header_blocknr(&l->header), nr,
|
||||
btrfs_leaf_free_space(root, l));
|
||||
btrfs_leaf_free_space(root, l),
|
||||
btrfs_header_parentid(&l->header),
|
||||
btrfs_header_generation(&l->header));
|
||||
fflush(stdout);
|
||||
for (i = 0 ; i < nr ; i++) {
|
||||
item = l->items + i;
|
||||
@ -87,9 +89,12 @@ void btrfs_print_tree(struct btrfs_root *root, struct btrfs_buffer *t)
|
||||
btrfs_print_leaf(root, (struct btrfs_leaf *)c);
|
||||
return;
|
||||
}
|
||||
printf("node %Lu level %d total ptrs %d free spc %u\n", t->blocknr,
|
||||
printf("node %Lu level %d ptrs %d free %u parent %Lu generation %Lu\n",
|
||||
t->blocknr,
|
||||
btrfs_header_level(&c->header), nr,
|
||||
(u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr);
|
||||
(u32)BTRFS_NODEPTRS_PER_BLOCK(root) - nr,
|
||||
btrfs_header_parentid(&c->header),
|
||||
btrfs_header_generation(&c->header));
|
||||
fflush(stdout);
|
||||
for (i = 0; i < nr; i++) {
|
||||
printf("\tkey %d (%Lu %u %Lu) block %Lu\n",
|
||||
|
Loading…
Reference in New Issue
Block a user