diff mbox series

[36/38] btrfs-progs: inline btrfs_name_hash and btrfs_extref_hash

Message ID be9c4bebbc502233f94879c61dcc8b7a30f34317.1692800904.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: sync ctree.c into btrfs-progs | expand

Commit Message

Josef Bacik Aug. 23, 2023, 2:33 p.m. UTC
This is the opposite of what we do in the kernel, however in the kernel
we put the helpers in dir-item.h and inode-item.h respectively.  Those
do not exist in btrfs-progs right now, so instead of doing all that work
right now simply inline them in ctree.h to make it easier to sync
ctree.c from the kernel.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/ctree.c | 14 --------------
 kernel-shared/ctree.h | 16 ++++++++++++++--
 2 files changed, 14 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index fb3b9899..0bfebdc2 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -24,7 +24,6 @@ 
 #include "kernel-shared/print-tree.h"
 #include "kernel-shared/tree-checker.h"
 #include "kernel-shared/volumes.h"
-#include "crypto/crc32c.h"
 #include "common/internal.h"
 #include "common/messages.h"
 #include "common/utils.h"
@@ -188,19 +187,6 @@  u16 btrfs_csum_type_size(u16 csum_type)
 	return btrfs_csums[csum_type].size;
 }
 
-u64 btrfs_name_hash(const char *name, int len)
-{
-	return crc32c((u32)~1, name, len);
-}
-
-/*
- * Figure the key offset of an extended inode ref
- */
-u64 btrfs_extref_hash(u64 parent_objectid, const char *name, int len)
-{
-	return (u64)crc32c(parent_objectid, name, len);
-}
-
 struct btrfs_path *btrfs_alloc_path(void)
 {
 	might_sleep();
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 67c5a6f8..7ffef9fa 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -25,6 +25,7 @@ 
 #include "kernel-lib/rbtree.h"
 #include "kerncompat.h"
 #include "common/extent-cache.h"
+#include "crypto/crc32c.h"
 #include "kernel-shared/uapi/btrfs.h"
 #include "kernel-shared/uapi/btrfs_tree.h"
 #include "kernel-shared/extent_io.h"
@@ -869,8 +870,19 @@  static inline int __btrfs_fs_compat_ro(struct btrfs_fs_info *fs_info, u64 flag)
 	return !!(btrfs_super_compat_ro_flags(disk_super) & flag);
 }
 
-u64 btrfs_name_hash(const char *name, int len);
-u64 btrfs_extref_hash(u64 parent_objectid, const char *name, int len);
+static inline u64 btrfs_name_hash(const char *name, int len)
+{
+	return crc32c((u32)~1, name, len);
+}
+
+/*
+ * Figure the key offset of an extended inode ref
+ */
+static inline u64 btrfs_extref_hash(u64 parent_objectid, const char *name,
+				    int len)
+{
+	return (u64)crc32c(parent_objectid, name, len);
+}
 
 /* extent-tree.c */
 int btrfs_reserve_extent(struct btrfs_trans_handle *trans,