btrfs-progs: Refactor block sizes users in ctree.c and ctree.h
authorQu Wenruo <quwenruo@cn.fujitsu.com>
Thu, 18 May 2017 01:17:41 +0000 (09:17 +0800)
committerDavid Sterba <dsterba@suse.com>
Mon, 3 Jul 2017 11:35:10 +0000 (13:35 +0200)
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
ctree.c
ctree.h

diff --git a/ctree.c b/ctree.c
index 02c7180..266a3cf 100644 (file)
--- a/ctree.c
+++ b/ctree.c
@@ -650,7 +650,7 @@ struct extent_buffer *read_node_slot(struct btrfs_root *root,
                return NULL;
 
        return read_tree_block(root, btrfs_node_blockptr(parent, slot),
-                      root->nodesize,
+                      root->fs_info->nodesize,
                       btrfs_node_ptr_generation(parent, slot));
 }
 
@@ -987,7 +987,7 @@ void reada_for_search(struct btrfs_root *root, struct btrfs_path *path,
 
        node = path->nodes[level];
        search = btrfs_node_blockptr(node, slot);
-       blocksize = root->nodesize;
+       blocksize = root->fs_info->nodesize;
        eb = btrfs_find_tree_block(root, search, blocksize);
        if (eb) {
                free_extent_buffer(eb);
@@ -1420,7 +1420,7 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
        else
                btrfs_node_key(lower, &lower_key, 0);
 
-       c = btrfs_alloc_free_block(trans, root, root->nodesize,
+       c = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
                                   root->root_key.objectid, &lower_key, 
                                   level, root->node->start, 0);
 
@@ -1543,7 +1543,7 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
        mid = (c_nritems + 1) / 2;
        btrfs_node_key(c, &disk_key, mid);
 
-       split = btrfs_alloc_free_block(trans, root, root->nodesize,
+       split = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
                                        root->root_key.objectid,
                                        &disk_key, level, c->start, 0);
        if (IS_ERR(split))
@@ -2110,7 +2110,7 @@ again:
        else
                btrfs_item_key(l, &disk_key, mid);
 
-       right = btrfs_alloc_free_block(trans, root, root->nodesize,
+       right = btrfs_alloc_free_block(trans, root, root->fs_info->nodesize,
                                        root->root_key.objectid,
                                        &disk_key, 0, l->start, 0);
        if (IS_ERR(right)) {
diff --git a/ctree.h b/ctree.h
index 78956a4..84298c7 100644 (file)
--- a/ctree.h
+++ b/ctree.h
@@ -352,11 +352,11 @@ struct btrfs_header {
        u8 level;
 } __attribute__ ((__packed__));
 
-#define BTRFS_NODEPTRS_PER_BLOCK(r) (((r)->nodesize - \
+#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(r) (__BTRFS_LEAF_DATA_SIZE(r->nodesize))
+#define BTRFS_LEAF_DATA_SIZE(r) (__BTRFS_LEAF_DATA_SIZE(r->fs_info->nodesize))
 #define BTRFS_MAX_INLINE_DATA_SIZE(r) (BTRFS_LEAF_DATA_SIZE(r) - \
                                        sizeof(struct btrfs_item) - \
                                        sizeof(struct btrfs_file_extent_item))