mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-13 09:11:36 +00:00
btrfs-progs: init new tree blocks in btrfs_alloc_tree_block
This is how the kernel initializes blocks, so anybody who uses btrfs_alloc_tree_block in the kernel expects the blocks to be already initialized. Put this init code into btrfs-progs so as we sync code from the kernel we get the correct behavior. Signed-off-by: Josef Bacik <josef@toxicpanda.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
f858c8b191
commit
e3f227c6c6
@ -2558,6 +2558,7 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
|
||||
u64 hint, u64 empty_size,
|
||||
enum btrfs_lock_nesting nest)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info = trans->fs_info;
|
||||
struct btrfs_key ins;
|
||||
int ret;
|
||||
struct extent_buffer *buf;
|
||||
@ -2578,6 +2579,14 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
|
||||
return ERR_PTR(-ENOMEM);
|
||||
}
|
||||
btrfs_set_buffer_uptodate(buf);
|
||||
memset_extent_buffer(buf, 0, 0, sizeof(struct btrfs_header));
|
||||
btrfs_set_header_level(buf, level);
|
||||
btrfs_set_header_bytenr(buf, buf->start);
|
||||
btrfs_set_header_generation(buf, trans->transid);
|
||||
btrfs_set_header_backref_rev(buf, BTRFS_MIXED_BACKREF_REV);
|
||||
btrfs_set_header_owner(buf, root_objectid);
|
||||
write_extent_buffer_fsid(buf, fs_info->fs_devices->metadata_uuid);
|
||||
write_extent_buffer_chunk_tree_uuid(buf, fs_info->chunk_tree_uuid);
|
||||
trans->blocks_used++;
|
||||
|
||||
return buf;
|
||||
|
Loading…
Reference in New Issue
Block a user