Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5b4aacef authored by Jeff Mahoney's avatar Jeff Mahoney Committed by David Sterba
Browse files

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: default avatarJeff Mahoney <jeffm@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent 515bdc47
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -2639,7 +2639,7 @@ int btrfs_setup_space_cache(struct btrfs_trans_handle *trans,
			    struct btrfs_root *root);
			    struct btrfs_root *root);
int btrfs_extent_readonly(struct btrfs_root *root, u64 bytenr);
int btrfs_extent_readonly(struct btrfs_root *root, u64 bytenr);
int btrfs_free_block_groups(struct btrfs_fs_info *info);
int btrfs_free_block_groups(struct btrfs_fs_info *info);
int btrfs_read_block_groups(struct btrfs_root *root);
int btrfs_read_block_groups(struct btrfs_fs_info *info);
int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr);
int btrfs_can_relocate(struct btrfs_root *root, u64 bytenr);
int btrfs_make_block_group(struct btrfs_trans_handle *trans,
int btrfs_make_block_group(struct btrfs_trans_handle *trans,
			   struct btrfs_root *root, u64 bytes_used,
			   struct btrfs_root *root, u64 bytes_used,
@@ -3055,7 +3055,7 @@ int btrfs_find_name_in_ext_backref(struct btrfs_path *path,
/* file-item.c */
/* file-item.c */
struct btrfs_dio_private;
struct btrfs_dio_private;
int btrfs_del_csums(struct btrfs_trans_handle *trans,
int btrfs_del_csums(struct btrfs_trans_handle *trans,
		    struct btrfs_root *root, u64 bytenr, u64 len);
		    struct btrfs_fs_info *fs_info, u64 bytenr, u64 len);
int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
int btrfs_lookup_bio_sums(struct btrfs_root *root, struct inode *inode,
			  struct bio *bio, u32 *dst);
			  struct bio *bio, u32 *dst);
int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
int btrfs_lookup_bio_sums_dio(struct btrfs_root *root, struct inode *inode,
+2 −2
Original line number Original line Diff line number Diff line
@@ -2937,7 +2937,7 @@ int open_ctree(struct super_block *sb,
	read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid,
	read_extent_buffer(chunk_root->node, fs_info->chunk_tree_uuid,
	   btrfs_header_chunk_tree_uuid(chunk_root->node), BTRFS_UUID_SIZE);
	   btrfs_header_chunk_tree_uuid(chunk_root->node), BTRFS_UUID_SIZE);


	ret = btrfs_read_chunk_tree(chunk_root);
	ret = btrfs_read_chunk_tree(fs_info);
	if (ret) {
	if (ret) {
		btrfs_err(fs_info, "failed to read chunk tree: %d", ret);
		btrfs_err(fs_info, "failed to read chunk tree: %d", ret);
		goto fail_tree_roots;
		goto fail_tree_roots;
@@ -3038,7 +3038,7 @@ int open_ctree(struct super_block *sb,
		goto fail_sysfs;
		goto fail_sysfs;
	}
	}


	ret = btrfs_read_block_groups(fs_info->extent_root);
	ret = btrfs_read_block_groups(fs_info);
	if (ret) {
	if (ret) {
		btrfs_err(fs_info, "failed to read block groups: %d", ret);
		btrfs_err(fs_info, "failed to read block groups: %d", ret);
		goto fail_sysfs;
		goto fail_sysfs;
+9 −8
Original line number Original line Diff line number Diff line
@@ -2414,7 +2414,7 @@ static int run_one_delayed_ref(struct btrfs_trans_handle *trans,
			btrfs_pin_extent(root, node->bytenr,
			btrfs_pin_extent(root, node->bytenr,
					 node->num_bytes, 1);
					 node->num_bytes, 1);
			if (head->is_data) {
			if (head->is_data) {
				ret = btrfs_del_csums(trans, root,
				ret = btrfs_del_csums(trans, root->fs_info,
						      node->bytenr,
						      node->bytenr,
						      node->num_bytes);
						      node->num_bytes);
			}
			}
@@ -3622,7 +3622,8 @@ int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans,


		if (cache->disk_cache_state == BTRFS_DC_SETUP) {
		if (cache->disk_cache_state == BTRFS_DC_SETUP) {
			cache->io_ctl.inode = NULL;
			cache->io_ctl.inode = NULL;
			ret = btrfs_write_out_cache(root, trans, cache, path);
			ret = btrfs_write_out_cache(root->fs_info, trans,
						    cache, path);
			if (ret == 0 && cache->io_ctl.inode) {
			if (ret == 0 && cache->io_ctl.inode) {
				num_started++;
				num_started++;
				should_put = 0;
				should_put = 0;
@@ -3774,7 +3775,8 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,


		if (!ret && cache->disk_cache_state == BTRFS_DC_SETUP) {
		if (!ret && cache->disk_cache_state == BTRFS_DC_SETUP) {
			cache->io_ctl.inode = NULL;
			cache->io_ctl.inode = NULL;
			ret = btrfs_write_out_cache(root, trans, cache, path);
			ret = btrfs_write_out_cache(root->fs_info, trans,
						    cache, path);
			if (ret == 0 && cache->io_ctl.inode) {
			if (ret == 0 && cache->io_ctl.inode) {
				num_started++;
				num_started++;
				should_put = 0;
				should_put = 0;
@@ -7068,7 +7070,7 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans,
		btrfs_release_path(path);
		btrfs_release_path(path);


		if (is_data) {
		if (is_data) {
			ret = btrfs_del_csums(trans, root, bytenr, num_bytes);
			ret = btrfs_del_csums(trans, info, bytenr, num_bytes);
			if (ret) {
			if (ret) {
				btrfs_abort_transaction(trans, ret);
				btrfs_abort_transaction(trans, ret);
				goto out;
				goto out;
@@ -9925,12 +9927,12 @@ btrfs_create_block_group_cache(struct btrfs_root *root, u64 start, u64 size)
	return cache;
	return cache;
}
}


int btrfs_read_block_groups(struct btrfs_root *root)
int btrfs_read_block_groups(struct btrfs_fs_info *info)
{
{
	struct btrfs_root *root = info->extent_root;
	struct btrfs_path *path;
	struct btrfs_path *path;
	int ret;
	int ret;
	struct btrfs_block_group_cache *cache;
	struct btrfs_block_group_cache *cache;
	struct btrfs_fs_info *info = root->fs_info;
	struct btrfs_space_info *space_info;
	struct btrfs_space_info *space_info;
	struct btrfs_key key;
	struct btrfs_key key;
	struct btrfs_key found_key;
	struct btrfs_key found_key;
@@ -9943,7 +9945,6 @@ int btrfs_read_block_groups(struct btrfs_root *root)
	feature = btrfs_super_incompat_flags(info->super_copy);
	feature = btrfs_super_incompat_flags(info->super_copy);
	mixed = !!(feature & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS);
	mixed = !!(feature & BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS);


	root = info->extent_root;
	key.objectid = 0;
	key.objectid = 0;
	key.offset = 0;
	key.offset = 0;
	key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
	key.type = BTRFS_BLOCK_GROUP_ITEM_KEY;
@@ -10733,7 +10734,7 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
		 * Btrfs_remove_chunk will abort the transaction if things go
		 * Btrfs_remove_chunk will abort the transaction if things go
		 * horribly wrong.
		 * horribly wrong.
		 */
		 */
		ret = btrfs_remove_chunk(trans, root,
		ret = btrfs_remove_chunk(trans, fs_info,
					 block_group->key.objectid);
					 block_group->key.objectid);


		if (ret) {
		if (ret) {
+2 −3
Original line number Original line Diff line number Diff line
@@ -590,8 +590,9 @@ static noinline void truncate_one_csum(struct btrfs_root *root,
 * range of bytes.
 * range of bytes.
 */
 */
int btrfs_del_csums(struct btrfs_trans_handle *trans,
int btrfs_del_csums(struct btrfs_trans_handle *trans,
		    struct btrfs_root *root, u64 bytenr, u64 len)
		    struct btrfs_fs_info *fs_info, u64 bytenr, u64 len)
{
{
	struct btrfs_root *root = fs_info->csum_root;
	struct btrfs_path *path;
	struct btrfs_path *path;
	struct btrfs_key key;
	struct btrfs_key key;
	u64 end_byte = bytenr + len;
	u64 end_byte = bytenr + len;
@@ -601,8 +602,6 @@ int btrfs_del_csums(struct btrfs_trans_handle *trans,
	u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
	u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
	int blocksize_bits = root->fs_info->sb->s_blocksize_bits;
	int blocksize_bits = root->fs_info->sb->s_blocksize_bits;


	root = root->fs_info->csum_root;

	path = btrfs_alloc_path();
	path = btrfs_alloc_path();
	if (!path)
	if (!path)
		return -ENOMEM;
		return -ENOMEM;
+2 −3
Original line number Original line Diff line number Diff line
@@ -1350,17 +1350,16 @@ static int __btrfs_write_out_cache(struct btrfs_root *root, struct inode *inode,
	goto out;
	goto out;
}
}


int btrfs_write_out_cache(struct btrfs_root *root,
int btrfs_write_out_cache(struct btrfs_fs_info *fs_info,
			  struct btrfs_trans_handle *trans,
			  struct btrfs_trans_handle *trans,
			  struct btrfs_block_group_cache *block_group,
			  struct btrfs_block_group_cache *block_group,
			  struct btrfs_path *path)
			  struct btrfs_path *path)
{
{
	struct btrfs_root *root = fs_info->tree_root;
	struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
	struct btrfs_free_space_ctl *ctl = block_group->free_space_ctl;
	struct inode *inode;
	struct inode *inode;
	int ret = 0;
	int ret = 0;


	root = root->fs_info->tree_root;

	spin_lock(&block_group->lock);
	spin_lock(&block_group->lock);
	if (block_group->disk_cache_state < BTRFS_DC_SETUP) {
	if (block_group->disk_cache_state < BTRFS_DC_SETUP) {
		spin_unlock(&block_group->lock);
		spin_unlock(&block_group->lock);
Loading