summaryrefslogtreecommitdiff
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorJeff Mahoney <jeffm@suse.com>2016-06-21 10:40:19 -0400
committerDavid Sterba <dsterba@suse.com>2016-12-06 16:06:57 +0100
commit5b4aacefb8fbfc996e68b9b083d30f8bc0972449 (patch)
treecd4f1669a5bf9f8f2896c27f4b0d9d51e8a68e43 /fs/btrfs/volumes.c
parent515bdc479097ec9d5f389202842345af3162f71c (diff)
btrfs: call functions that overwrite their root parameter with fs_info
There are 11 functions that accept a root parameter and immediately overwrite it. We can pass those an fs_info pointer instead. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c56
1 files changed, 25 insertions, 31 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 1886b94f13ac..17ab4b6b1fd9 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -1667,9 +1667,10 @@ error:
* the btrfs_device struct should be fully filled in
*/
static int btrfs_add_device(struct btrfs_trans_handle *trans,
- struct btrfs_root *root,
+ struct btrfs_fs_info *fs_info,
struct btrfs_device *device)
{
+ struct btrfs_root *root = fs_info->chunk_root;
int ret;
struct btrfs_path *path;
struct btrfs_dev_item *dev_item;
@@ -1677,8 +1678,6 @@ static int btrfs_add_device(struct btrfs_trans_handle *trans,
struct btrfs_key key;
unsigned long ptr;
- root = root->fs_info->chunk_root;
-
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
@@ -1737,16 +1736,15 @@ static void update_dev_time(char *path_name)
filp_close(filp, NULL);
}
-static int btrfs_rm_dev_item(struct btrfs_root *root,
+static int btrfs_rm_dev_item(struct btrfs_fs_info *fs_info,
struct btrfs_device *device)
{
+ struct btrfs_root *root = fs_info->chunk_root;
int ret;
struct btrfs_path *path;
struct btrfs_key key;
struct btrfs_trans_handle *trans;
- root = root->fs_info->chunk_root;
-
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
@@ -1909,7 +1907,7 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path, u64 devid)
* counter although write_all_supers() is not locked out. This
* could give a filesystem state which requires a degraded mount.
*/
- ret = btrfs_rm_dev_item(root->fs_info->chunk_root, device);
+ ret = btrfs_rm_dev_item(root->fs_info, device);
if (ret)
goto error_undo;
@@ -2241,8 +2239,9 @@ static int btrfs_prepare_sprout(struct btrfs_root *root)
* Store the expected generation for seed devices in device items.
*/
static int btrfs_finish_sprout(struct btrfs_trans_handle *trans,
- struct btrfs_root *root)
+ struct btrfs_fs_info *fs_info)
{
+ struct btrfs_root *root = fs_info->chunk_root;
struct btrfs_path *path;
struct extent_buffer *leaf;
struct btrfs_dev_item *dev_item;
@@ -2257,7 +2256,6 @@ static int btrfs_finish_sprout(struct btrfs_trans_handle *trans,
if (!path)
return -ENOMEM;
- root = root->fs_info->chunk_root;
key.objectid = BTRFS_DEV_ITEMS_OBJECTID;
key.offset = 0;
key.type = BTRFS_DEV_ITEM_KEY;
@@ -2452,7 +2450,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
}
}
- ret = btrfs_add_device(trans, root, device);
+ ret = btrfs_add_device(trans, root->fs_info, device);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto error_trans;
@@ -2461,7 +2459,7 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path)
if (seeding_dev) {
char fsid_buf[BTRFS_UUID_UNPARSED_SIZE];
- ret = btrfs_finish_sprout(trans, root);
+ ret = btrfs_finish_sprout(trans, root->fs_info);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto error_trans;
@@ -2716,14 +2714,14 @@ int btrfs_grow_device(struct btrfs_trans_handle *trans,
}
static int btrfs_free_chunk(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, u64 chunk_objectid,
+ struct btrfs_fs_info *fs_info, u64 chunk_objectid,
u64 chunk_offset)
{
+ struct btrfs_root *root = fs_info->chunk_root;
int ret;
struct btrfs_path *path;
struct btrfs_key key;
- root = root->fs_info->chunk_root;
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;
@@ -2800,8 +2798,9 @@ static int btrfs_del_sys_chunk(struct btrfs_root *root, u64 chunk_objectid, u64
}
int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
- struct btrfs_root *root, u64 chunk_offset)
+ struct btrfs_fs_info *fs_info, u64 chunk_offset)
{
+ struct btrfs_root *root = fs_info->chunk_root;
struct extent_map_tree *em_tree;
struct extent_map *em;
struct btrfs_root *extent_root = root->fs_info->extent_root;
@@ -2811,9 +2810,7 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
int i, ret = 0;
struct btrfs_fs_devices *fs_devices = root->fs_info->fs_devices;
- /* Just in case */
- root = root->fs_info->chunk_root;
- em_tree = &root->fs_info->mapping_tree.map_tree;
+ em_tree = &fs_info->mapping_tree.map_tree;
read_lock(&em_tree->lock);
em = lookup_extent_mapping(em_tree, chunk_offset, 1);
@@ -2875,7 +2872,8 @@ int btrfs_remove_chunk(struct btrfs_trans_handle *trans,
}
mutex_unlock(&fs_devices->device_list_mutex);
- ret = btrfs_free_chunk(trans, root, chunk_objectid, chunk_offset);
+ ret = btrfs_free_chunk(trans, root->fs_info, chunk_objectid,
+ chunk_offset);
if (ret) {
btrfs_abort_transaction(trans, ret);
goto out;
@@ -2903,15 +2901,13 @@ out:
return ret;
}
-static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset)
+static int btrfs_relocate_chunk(struct btrfs_fs_info *fs_info, u64 chunk_offset)
{
- struct btrfs_root *extent_root;
+ struct btrfs_root *root = fs_info->chunk_root;
+ struct btrfs_root *extent_root = fs_info->extent_root;
struct btrfs_trans_handle *trans;
int ret;
- root = root->fs_info->chunk_root;
- extent_root = root->fs_info->extent_root;
-
/*
* Prevent races with automatic removal of unused block groups.
* After we relocate and before we remove the chunk with offset
@@ -2949,7 +2945,7 @@ static int btrfs_relocate_chunk(struct btrfs_root *root, u64 chunk_offset)
* step two, delete the device extents and the
* chunk tree entries
*/
- ret = btrfs_remove_chunk(trans, root, chunk_offset);
+ ret = btrfs_remove_chunk(trans, fs_info, chunk_offset);
btrfs_end_transaction(trans, extent_root);
return ret;
}
@@ -3003,7 +2999,7 @@ again:
btrfs_release_path(path);
if (chunk_type & BTRFS_BLOCK_GROUP_SYSTEM) {
- ret = btrfs_relocate_chunk(chunk_root,
+ ret = btrfs_relocate_chunk(root->fs_info,
found_key.offset);
if (ret == -ENOSPC)
failed++;
@@ -3669,8 +3665,7 @@ again:
chunk_reserved = 1;
}
- ret = btrfs_relocate_chunk(chunk_root,
- found_key.offset);
+ ret = btrfs_relocate_chunk(fs_info, found_key.offset);
mutex_unlock(&fs_info->delete_unused_bgs_mutex);
if (ret && ret != -ENOSPC)
goto error;
@@ -4439,7 +4434,7 @@ again:
chunk_offset = btrfs_dev_extent_chunk_offset(l, dev_extent);
btrfs_release_path(path);
- ret = btrfs_relocate_chunk(root, chunk_offset);
+ ret = btrfs_relocate_chunk(root->fs_info, chunk_offset);
mutex_unlock(&root->fs_info->delete_unused_bgs_mutex);
if (ret && ret != -ENOSPC)
goto done;
@@ -6785,8 +6780,9 @@ out_short_read:
return -EIO;
}
-int btrfs_read_chunk_tree(struct btrfs_root *root)
+int btrfs_read_chunk_tree(struct btrfs_fs_info *fs_info)
{
+ struct btrfs_root *root = fs_info->chunk_root;
struct btrfs_path *path;
struct extent_buffer *leaf;
struct btrfs_key key;
@@ -6795,8 +6791,6 @@ int btrfs_read_chunk_tree(struct btrfs_root *root)
int slot;
u64 total_dev = 0;
- root = root->fs_info->chunk_root;
-
path = btrfs_alloc_path();
if (!path)
return -ENOMEM;