btrfs: free-space-cache, clean up unnecessary root arguments
authorJeff Mahoney <jeffm@suse.com>
Wed, 15 Feb 2017 21:28:30 +0000 (16:28 -0500)
committerDavid Sterba <dsterba@suse.com>
Fri, 17 Feb 2017 11:03:56 +0000 (12:03 +0100)
The free space cache APIs accept a root but always use the tree root.

Also, btrfs_truncate_free_space_cache accepts a root AND an inode but
the inode always points to the root anyway, so let's just pass the inode.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/extent-tree.c
fs/btrfs/free-space-cache.c
fs/btrfs/free-space-cache.h
fs/btrfs/inode-map.c
fs/btrfs/relocation.c

index 24d6adcecdded00e1baf7d7b28284d3db0a8a396..c35b966335543cfa5f499e30efda9d5f6eb554af 100644 (file)
@@ -3374,7 +3374,7 @@ static int cache_save_setup(struct btrfs_block_group_cache *block_group,
        if (trans->aborted)
                return 0;
 again:
-       inode = lookup_free_space_inode(root, block_group, path);
+       inode = lookup_free_space_inode(fs_info, block_group, path);
        if (IS_ERR(inode) && PTR_ERR(inode) != -ENOENT) {
                ret = PTR_ERR(inode);
                btrfs_release_path(path);
@@ -3388,7 +3388,8 @@ again:
                if (block_group->ro)
                        goto out_free;
 
-               ret = create_free_space_inode(root, trans, block_group, path);
+               ret = create_free_space_inode(fs_info, trans, block_group,
+                                             path);
                if (ret)
                        goto out_free;
                goto again;
@@ -3430,7 +3431,7 @@ again:
                if (ret)
                        goto out_put;
 
-               ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode);
+               ret = btrfs_truncate_free_space_cache(trans, NULL, inode);
                if (ret)
                        goto out_put;
        }
@@ -10314,7 +10315,7 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans,
         * get the inode first so any iput calls done for the io_list
         * aren't the final iput (no unlinks allowed now)
         */
-       inode = lookup_free_space_inode(tree_root, block_group, path);
+       inode = lookup_free_space_inode(fs_info, block_group, path);
 
        mutex_lock(&trans->transaction->cache_write_mutex);
        /*
index adf9da9076946bd1b37fd5bd190f3d7732bdf86c..27820d48a6f336973773b36f749d6e9f3837185e 100644 (file)
@@ -94,12 +94,11 @@ static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
        return inode;
 }
 
-struct inode *lookup_free_space_inode(struct btrfs_root *root,
+struct inode *lookup_free_space_inode(struct btrfs_fs_info *fs_info,
                                      struct btrfs_block_group_cache
                                      *block_group, struct btrfs_path *path)
 {
        struct inode *inode = NULL;
-       struct btrfs_fs_info *fs_info = root->fs_info;
        u32 flags = BTRFS_INODE_NODATASUM | BTRFS_INODE_NODATACOW;
 
        spin_lock(&block_group->lock);
@@ -109,7 +108,7 @@ struct inode *lookup_free_space_inode(struct btrfs_root *root,
        if (inode)
                return inode;
 
-       inode = __lookup_free_space_inode(root, path,
+       inode = __lookup_free_space_inode(fs_info->tree_root, path,
                                          block_group->key.objectid);
        if (IS_ERR(inode))
                return inode;
@@ -192,7 +191,7 @@ static int __create_free_space_inode(struct btrfs_root *root,
        return 0;
 }
 
-int create_free_space_inode(struct btrfs_root *root,
+int create_free_space_inode(struct btrfs_fs_info *fs_info,
                            struct btrfs_trans_handle *trans,
                            struct btrfs_block_group_cache *block_group,
                            struct btrfs_path *path)
@@ -200,11 +199,11 @@ int create_free_space_inode(struct btrfs_root *root,
        int ret;
        u64 ino;
 
-       ret = btrfs_find_free_objectid(root, &ino);
+       ret = btrfs_find_free_objectid(fs_info->tree_root, &ino);
        if (ret < 0)
                return ret;
 
-       return __create_free_space_inode(root, trans, path, ino,
+       return __create_free_space_inode(fs_info->tree_root, trans, path, ino,
                                         block_group->key.objectid);
 }
 
@@ -227,11 +226,11 @@ int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
        return ret;
 }
 
-int btrfs_truncate_free_space_cache(struct btrfs_root *root,
-                                   struct btrfs_trans_handle *trans,
+int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
                                    struct btrfs_block_group_cache *block_group,
                                    struct inode *inode)
 {
+       struct btrfs_root *root = BTRFS_I(inode)->root;
        int ret = 0;
        struct btrfs_path *path = btrfs_alloc_path();
        bool locked = false;
@@ -824,7 +823,6 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
                          struct btrfs_block_group_cache *block_group)
 {
        struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
-       struct btrfs_root *root = fs_info->tree_root;
        struct inode *inode;
        struct btrfs_path *path;
        int ret = 0;
@@ -848,7 +846,7 @@ int load_free_space_cache(struct btrfs_fs_info *fs_info,
        path->search_commit_root = 1;
        path->skip_locking = 1;
 
-       inode = lookup_free_space_inode(root, block_group, path);
+       inode = lookup_free_space_inode(fs_info, block_group, path);
        if (IS_ERR(inode)) {
                btrfs_free_path(path);
                return 0;
@@ -1370,7 +1368,6 @@ int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
                          struct btrfs_block_group_cache *block_group,
                          struct btrfs_path *path)
 {
-       struct btrfs_root *root = fs_info->tree_root;
        struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
        struct inode *inode;
        int ret = 0;
@@ -1382,12 +1379,12 @@ int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
        }
        spin_unlock(&block_group->lock);
 
-       inode = lookup_free_space_inode(root, block_group, path);
+       inode = lookup_free_space_inode(fs_info, block_group, path);
        if (IS_ERR(inode))
                return 0;
 
-       ret = __btrfs_write_out_cache(root, inode, ctl, block_group,
-                                     &block_group->io_ctl, trans);
+       ret = __btrfs_write_out_cache(fs_info->tree_root, inode, ctl,
+                               block_group, &block_group->io_ctl, trans);
        if (ret) {
 #ifdef DEBUG
                btrfs_err(fs_info,
index 6f3c025a2c6c8686daf8787377aae17358dfd2c3..79eca4cabb1c6ae6822c241dfa8cdf37ed908855 100644 (file)
@@ -51,18 +51,17 @@ struct btrfs_free_space_op {
 
 struct btrfs_io_ctl;
 
-struct inode *lookup_free_space_inode(struct btrfs_root *root,
+struct inode *lookup_free_space_inode(struct btrfs_fs_info *fs_info,
                                      struct btrfs_block_group_cache
                                      *block_group, struct btrfs_path *path);
-int create_free_space_inode(struct btrfs_root *root,
+int create_free_space_inode(struct btrfs_fs_info *fs_info,
                            struct btrfs_trans_handle *trans,
                            struct btrfs_block_group_cache *block_group,
                            struct btrfs_path *path);
 
 int btrfs_check_trunc_cache_free_space(struct btrfs_fs_info *fs_info,
                                       struct btrfs_block_rsv *rsv);
-int btrfs_truncate_free_space_cache(struct btrfs_root *root,
-                                   struct btrfs_trans_handle *trans,
+int btrfs_truncate_free_space_cache(struct btrfs_trans_handle *trans,
                                    struct btrfs_block_group_cache *block_group,
                                    struct inode *inode);
 int load_free_space_cache(struct btrfs_fs_info *fs_info,
index 144b119ff43f1e50b0eb2d7074c5112689c4df24..3bbb8f0959535235b1c043a6520e54d05ad291d5 100644 (file)
@@ -467,7 +467,7 @@ again:
        }
 
        if (i_size_read(inode) > 0) {
-               ret = btrfs_truncate_free_space_cache(root, trans, NULL, inode);
+               ret = btrfs_truncate_free_space_cache(trans, NULL, inode);
                if (ret) {
                        if (ret != -ENOSPC)
                                btrfs_abort_transaction(trans, ret);
index e2cf65cd8f17f381363a50715bdeaa0a68c22fcc..ddbde0f0836537aba470882528d808755d618cec 100644 (file)
@@ -3543,7 +3543,7 @@ truncate:
                goto out;
        }
 
-       ret = btrfs_truncate_free_space_cache(root, trans, block_group, inode);
+       ret = btrfs_truncate_free_space_cache(trans, block_group, inode);
 
        btrfs_end_transaction(trans);
        btrfs_btree_balance_dirty(fs_info);
@@ -4347,8 +4347,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
                goto out;
        }
 
-       inode = lookup_free_space_inode(fs_info->tree_root, rc->block_group,
-                                       path);
+       inode = lookup_free_space_inode(fs_info, rc->block_group, path);
        btrfs_free_path(path);
 
        if (!IS_ERR(inode))