summaryrefslogtreecommitdiff
path: root/ctree.h
diff options
context:
space:
mode:
authorGu Jinxiang <gujx@cn.fujitsu.com>2018-01-26 15:26:01 +0800
committerDavid Sterba <dsterba@suse.com>2018-02-02 16:01:57 +0100
commit3809b36d855fd13aad31c3a426a4d7434180003a (patch)
tree842de957ad985ea5a19e4c53e80df6bd5d150f95 /ctree.h
parent26072f584d347ef2d471c02fbe27dbfedd606ac4 (diff)
btrfs-progs: Use fs_info instead of root for BTRFS_NODEPTRS_PER_BLOCK
Do a cleanup. Also make it consistent with kernel. Use fs_info instead of root for BTRFS_NODEPTRS_PER_BLOCK, since maybe in some situation we do not know root, but just know fs_info. To be consistent with kernel, change macro to inline function. Signed-off-by: Gu Jinxiang <gujx@cn.fujitsu.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'ctree.h')
-rw-r--r--ctree.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/ctree.h b/ctree.h
index d50866b1..0e5c774c 100644
--- a/ctree.h
+++ b/ctree.h
@@ -356,9 +356,6 @@ struct btrfs_header {
u8 level;
} __attribute__ ((__packed__));
-#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->fs_info->nodesize - \
- sizeof(struct btrfs_header)) / \
- sizeof(struct btrfs_key_ptr))
#define __BTRFS_LEAF_DATA_SIZE(bs) ((bs) - sizeof(struct btrfs_header))
#define BTRFS_LEAF_DATA_SIZE(fs_info) \
(__BTRFS_LEAF_DATA_SIZE(fs_info->nodesize))
@@ -1191,6 +1188,11 @@ struct btrfs_root {
struct rb_node rb_node;
};
+static inline u32 BTRFS_NODEPTRS_PER_BLOCK(const struct btrfs_fs_info *info)
+{
+ return BTRFS_LEAF_DATA_SIZE(info) / sizeof(struct btrfs_key_ptr);
+}
+
/*
* inode items have the data typically returned from stat and store other
* info about object characteristics. There is one for every file and dir in