From 8efa8092aaba13b0782eadf9ae392a0b4d068831 Mon Sep 17 00:00:00 2001 From: Qu Wenruo Date: Fri, 26 Jul 2024 18:10:50 +0930 Subject: [PATCH] btrfs-progs: move uuid-tree definitions to kernel-shared/uuid-tree.h Currently we already have a kernel-shared/uuid-tree.c, which is mostly shared with kernel. Kernel also has a uuid-tree.h, but we are still using ctree.h for the header. Move all the uuid-tree related definitions to kernel-shared/uuid-tree.h, making future code sync easier. Signed-off-by: Qu Wenruo --- common/send-utils.c | 1 + kernel-shared/README.md | 1 + kernel-shared/ctree.h | 11 ----------- kernel-shared/uuid-tree.c | 1 + kernel-shared/uuid-tree.h | 33 +++++++++++++++++++++++++++++++++ mkfs/main.c | 1 + 6 files changed, 37 insertions(+), 11 deletions(-) create mode 100644 kernel-shared/uuid-tree.h diff --git a/common/send-utils.c b/common/send-utils.c index 173333e3..8c13ffa1 100644 --- a/common/send-utils.c +++ b/common/send-utils.c @@ -29,6 +29,7 @@ #include "kernel-shared/uapi/btrfs_tree.h" #include "kernel-shared/uapi/btrfs.h" #include "kernel-shared/ctree.h" +#include "kernel-shared/uuid-tree.h" #include "common/send-utils.h" #include "common/messages.h" #include "common/utils.h" diff --git a/kernel-shared/README.md b/kernel-shared/README.md index 50be72e3..4ae00f01 100644 --- a/kernel-shared/README.md +++ b/kernel-shared/README.md @@ -49,6 +49,7 @@ Status and progress of kernel/userspace synchronization. - ulist.c - done - ulist.h - done - uuid-tree.c - partial +- uuid-tree.h - partial, local changes - volumes.c - todo, local changes - volumes.h - todo, local changes - zoned.c - todo diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h index 2388879d..7761b3f6 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -1192,15 +1192,6 @@ int btrfs_del_inode_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root, const char *name, int name_len, u64 ino, u64 parent_ino, u64 *index); -/* uuid-tree.c, interface for mounted mounted filesystem */ -int btrfs_lookup_uuid_subvol_item(int fd, const u8 *uuid, u64 *subvol_id); -int btrfs_lookup_uuid_received_subvol_item(int fd, const u8 *uuid, - u64 *subvol_id); - -/* uuid-tree.c, interface for unmounte filesystem */ -int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type, - u64 subid); - static inline int is_fstree(u64 rootid) { if (rootid == BTRFS_FS_TREE_OBJECTID || @@ -1209,8 +1200,6 @@ static inline int is_fstree(u64 rootid) return 0; } -void btrfs_uuid_to_key(const u8 *uuid, u8 type, struct btrfs_key *key); - /* inode.c */ int btrfs_find_free_dir_index(struct btrfs_root *root, u64 dir_ino, u64 *ret_ino); diff --git a/kernel-shared/uuid-tree.c b/kernel-shared/uuid-tree.c index 766cd31e..26359520 100644 --- a/kernel-shared/uuid-tree.c +++ b/kernel-shared/uuid-tree.c @@ -29,6 +29,7 @@ #include "kernel-shared/ctree.h" #include "kernel-shared/messages.h" #include "kernel-shared/transaction.h" +#include "kernel-shared/uuid-tree.h" #include "common/messages.h" #include "common/utils.h" diff --git a/kernel-shared/uuid-tree.h b/kernel-shared/uuid-tree.h new file mode 100644 index 00000000..0cdc2228 --- /dev/null +++ b/kernel-shared/uuid-tree.h @@ -0,0 +1,33 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public + * License v2 as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 021110-1307, USA. + */ + +#ifndef __BTRFS_UUID_TREE_H__ +#define __BTRFS_UUID_TREE_H__ + +#include "kerncompat.h" +#include "kernel-shared/uapi/btrfs_tree.h" + +/* uuid-tree.c, interface for mounted mounted filesystem */ +int btrfs_lookup_uuid_subvol_item(int fd, const u8 *uuid, u64 *subvol_id); +int btrfs_lookup_uuid_received_subvol_item(int fd, const u8 *uuid, + u64 *subvol_id); + +/* uuid-tree.c, interface for unmounte filesystem */ +int btrfs_uuid_tree_remove(struct btrfs_trans_handle *trans, u8 *uuid, u8 type, + u64 subid); +void btrfs_uuid_to_key(const u8 *uuid, u8 type, struct btrfs_key *key); + +#endif diff --git a/mkfs/main.c b/mkfs/main.c index cf5cae45..9a6047f7 100644 --- a/mkfs/main.c +++ b/mkfs/main.c @@ -41,6 +41,7 @@ #include "kernel-shared/volumes.h" #include "kernel-shared/transaction.h" #include "kernel-shared/zoned.h" +#include "kernel-shared/uuid-tree.h" #include "crypto/hash.h" #include "common/defs.h" #include "common/internal.h"