From 22cf63d8ee51681146860ea15e1c86feace603dc Mon Sep 17 00:00:00 2001 From: David Sterba Date: Tue, 27 Jun 2023 17:27:04 +0200 Subject: [PATCH] btrfs-progs: kernel-shared: add helper write_extent_buffer_chunk_tree_uuid Sync the helper write_extent_buffer_chunk_tree_uuid from kernel. Signed-off-by: David Sterba --- kernel-shared/ctree.c | 17 ++++------------- kernel-shared/ctree.h | 2 +- kernel-shared/disk-io.c | 5 ++--- kernel-shared/extent_io.c | 6 ++++++ kernel-shared/extent_io.h | 2 ++ 5 files changed, 15 insertions(+), 17 deletions(-) diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c index 44197fa2..51b126c6 100644 --- a/kernel-shared/ctree.c +++ b/kernel-shared/ctree.c @@ -392,9 +392,7 @@ int btrfs_create_root(struct btrfs_trans_handle *trans, btrfs_set_header_backref_rev(node, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(node, objectid); write_extent_buffer_fsid(node, fs_info->fs_devices->metadata_uuid); - write_extent_buffer(node, fs_info->chunk_tree_uuid, - btrfs_header_chunk_tree_uuid(node), - BTRFS_UUID_SIZE); + write_extent_buffer_chunk_tree_uuid(node, fs_info->chunk_tree_uuid); btrfs_set_header_nritems(node, 0); btrfs_set_header_level(node, 0); ret = btrfs_inc_ref(trans, new_root, node, 0); @@ -1736,10 +1734,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans, root_add_used(root, root->fs_info->nodesize); write_extent_buffer_fsid(c, root->fs_info->fs_devices->metadata_uuid); - write_extent_buffer(c, root->fs_info->chunk_tree_uuid, - btrfs_header_chunk_tree_uuid(c), - BTRFS_UUID_SIZE); - + write_extent_buffer_chunk_tree_uuid(c, root->fs_info->chunk_tree_uuid); btrfs_set_node_key(c, &lower_key, 0); btrfs_set_node_blockptr(c, 0, lower->start); lower_gen = btrfs_header_generation(lower); @@ -1856,9 +1851,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root btrfs_set_header_backref_rev(split, BTRFS_MIXED_BACKREF_REV); btrfs_set_header_owner(split, root->root_key.objectid); write_extent_buffer_fsid(split, root->fs_info->fs_devices->metadata_uuid); - write_extent_buffer(split, root->fs_info->chunk_tree_uuid, - btrfs_header_chunk_tree_uuid(split), - BTRFS_UUID_SIZE); + write_extent_buffer_chunk_tree_uuid(split, root->fs_info->chunk_tree_uuid); root_add_used(root, root->fs_info->nodesize); @@ -2425,9 +2418,7 @@ again: btrfs_set_header_owner(right, root->root_key.objectid); btrfs_set_header_level(right, 0); write_extent_buffer_fsid(right, root->fs_info->fs_devices->metadata_uuid); - write_extent_buffer(right, root->fs_info->chunk_tree_uuid, - btrfs_header_chunk_tree_uuid(right), - BTRFS_UUID_SIZE); + write_extent_buffer_chunk_tree_uuid(right, root->fs_info->chunk_tree_uuid); root_add_used(root, root->fs_info->nodesize); diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index c57ed511..59533879 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -732,7 +732,7 @@ static inline unsigned long btrfs_header_fsid(void) return offsetof(struct btrfs_header, fsid); } -static inline unsigned long btrfs_header_chunk_tree_uuid(struct extent_buffer *eb) +static inline unsigned long btrfs_header_chunk_tree_uuid(const struct extent_buffer *eb) { return offsetof(struct btrfs_header, chunk_tree_uuid); } diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c index 6ebeab9d..89b03aac 100644 --- a/kernel-shared/disk-io.c +++ b/kernel-shared/disk-io.c @@ -2335,9 +2335,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans, btrfs_set_header_owner(leaf, root->root_key.objectid); root->node = leaf; write_extent_buffer_fsid(leaf, fs_info->fs_devices->metadata_uuid); - write_extent_buffer(leaf, fs_info->chunk_tree_uuid, - btrfs_header_chunk_tree_uuid(leaf), - BTRFS_UUID_SIZE); + write_extent_buffer_chunk_tree_uuid(leaf, fs_info->chunk_tree_uuid); + btrfs_mark_buffer_dirty(leaf); extent_buffer_get(root->node); diff --git a/kernel-shared/extent_io.c b/kernel-shared/extent_io.c index 69ee0c0d..c653d7c3 100644 --- a/kernel-shared/extent_io.c +++ b/kernel-shared/extent_io.c @@ -614,6 +614,12 @@ void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src) write_extent_buffer(eb, src, btrfs_header_fsid(), BTRFS_FSID_SIZE); } +void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb, + const void *src) +{ + write_extent_buffer(eb, src, btrfs_header_chunk_tree_uuid(eb), BTRFS_FSID_SIZE); +} + void write_extent_buffer(const struct extent_buffer *eb, const void *src, unsigned long start, unsigned long len) { diff --git a/kernel-shared/extent_io.h b/kernel-shared/extent_io.h index 1a043bb3..520ccd78 100644 --- a/kernel-shared/extent_io.h +++ b/kernel-shared/extent_io.h @@ -110,6 +110,8 @@ int memcmp_extent_buffer(const struct extent_buffer *eb, const void *ptrv, void read_extent_buffer(const struct extent_buffer *eb, void *dst, unsigned long start, unsigned long len); void write_extent_buffer_fsid(const struct extent_buffer *eb, const void *src); +void write_extent_buffer_chunk_tree_uuid(const struct extent_buffer *eb, + const void *src); void write_extent_buffer(const struct extent_buffer *eb, const void *src, unsigned long start, unsigned long len); void copy_extent_buffer_full(const struct extent_buffer *dst,