diff mbox series

[03/13] btrfs-progs: store BTRFS_LEAF_DATA_SIZE in the fs_info

Message ID 94cb2a8f86edb5ecbe0874ccd7ca3d5514bdab6f.1645568701.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: cleanup btrfs_item* accessors | expand

Commit Message

Josef Bacik Feb. 22, 2022, 10:26 p.m. UTC
This is going to be a different value based on the incompat settings of
the file system, just store this in the fs_info instead of calculating
it every time.

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

Patch

diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index de5452f2..31169f33 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -363,8 +363,7 @@  static inline u32 __BTRFS_LEAF_DATA_SIZE(u32 nodesize)
 	return nodesize - sizeof(struct btrfs_header);
 }
 
-#define BTRFS_LEAF_DATA_SIZE(fs_info) \
-				(__BTRFS_LEAF_DATA_SIZE(fs_info->nodesize))
+#define BTRFS_LEAF_DATA_SIZE(fs_info) (fs_info->leaf_data_size)
 
 /*
  * this is a very generous portion of the super block, giving us
@@ -1271,6 +1270,7 @@  struct btrfs_fs_info {
 	u32 nodesize;
 	u32 sectorsize;
 	u32 stripesize;
+	u32 leaf_data_size;
 	u16 csum_type;
 	u16 csum_size;
 
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index f83ba884..0434ed7d 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -1552,6 +1552,7 @@  static struct btrfs_fs_info *__open_ctree_fd(int fp, struct open_ctree_flags *oc
 	fs_info->stripesize = btrfs_super_stripesize(disk_super);
 	fs_info->csum_type = btrfs_super_csum_type(disk_super);
 	fs_info->csum_size = btrfs_super_csum_size(disk_super);
+	fs_info->leaf_data_size = __BTRFS_LEAF_DATA_SIZE(fs_info->nodesize);
 
 	ret = btrfs_check_fs_compatibility(fs_info->super_copy, flags);
 	if (ret)