diff mbox series

[06/20] btrfs-progs: check: stop passing csum root around

Message ID d3f2065cdfc56e6fe96e7cf1b736899ef7699111.1636143924.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: extent tree v2 global root support prep work | expand

Commit Message

Josef Bacik Nov. 5, 2021, 8:28 p.m. UTC
We pass the csum root from way high in the call chain in check down to
where we actually need it.  However we can just get it from the fs_info
in these places, so clean up the functions to skip passing around the
csum root needlessly.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c | 22 +++++++++-------------
 1 file changed, 9 insertions(+), 13 deletions(-)

Comments

Qu Wenruo Nov. 6, 2021, 12:21 a.m. UTC | #1
On 2021/11/6 04:28, Josef Bacik wrote:
> We pass the csum root from way high in the call chain in check down to
> where we actually need it.  However we can just get it from the fs_info
> in these places, so clean up the functions to skip passing around the
> csum root needlessly.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> ---
>   check/main.c | 22 +++++++++-------------
>   1 file changed, 9 insertions(+), 13 deletions(-)
>
> diff --git a/check/main.c b/check/main.c
> index 08810c5f..22306cf4 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -9494,9 +9494,9 @@ static int populate_csum(struct btrfs_trans_handle *trans,
>   }
>
>   static int fill_csum_tree_from_one_fs_root(struct btrfs_trans_handle *trans,
> -				      struct btrfs_root *csum_root,
> -				      struct btrfs_root *cur_root)
> +					   struct btrfs_root *cur_root)
>   {
> +	struct btrfs_root *csum_root = gfs_info->csum_root;
>   	struct btrfs_path path;
>   	struct btrfs_key key;
>   	struct extent_buffer *node;
> @@ -9557,8 +9557,7 @@ out:
>   	return ret;
>   }
>
> -static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans,
> -				  struct btrfs_root *csum_root)
> +static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans)
>   {
>   	struct btrfs_path path;
>   	struct btrfs_root *tree_root = gfs_info->tree_root;
> @@ -9598,8 +9597,7 @@ static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans,
>   				key.objectid);
>   			goto out;
>   		}
> -		ret = fill_csum_tree_from_one_fs_root(trans, csum_root,
> -				cur_root);
> +		ret = fill_csum_tree_from_one_fs_root(trans, cur_root);
>   		if (ret < 0)
>   			goto out;
>   next:
> @@ -9617,10 +9615,10 @@ out:
>   	return ret;
>   }
>
> -static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans,
> -				      struct btrfs_root *csum_root)
> +static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans)
>   {
>   	struct btrfs_root *extent_root = gfs_info->extent_root;
> +	struct btrfs_root *csum_root = gfs_info->csum_root;
>   	struct btrfs_path path;
>   	struct btrfs_extent_item *ei;
>   	struct extent_buffer *leaf;
> @@ -9690,13 +9688,12 @@ static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans,
>    * will use fs/subvol trees to init the csum tree.
>    */
>   static int fill_csum_tree(struct btrfs_trans_handle *trans,
> -			  struct btrfs_root *csum_root,
>   			  int search_fs_tree)
>   {
>   	if (search_fs_tree)
> -		return fill_csum_tree_from_fs(trans, csum_root);
> +		return fill_csum_tree_from_fs(trans);
>   	else
> -		return fill_csum_tree_from_extent(trans, csum_root);
> +		return fill_csum_tree_from_extent(trans);
>   }
>
>   static void free_roots_info_cache(void)
> @@ -10700,8 +10697,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
>   				goto close_out;
>   			}
>
> -			ret = fill_csum_tree(trans, gfs_info->csum_root,
> -					     init_extent_tree);
> +			ret = fill_csum_tree(trans, init_extent_tree);
>   			err |= !!ret;
>   			if (ret) {
>   				error("checksum tree refilling failed: %d", ret);
>
diff mbox series

Patch

diff --git a/check/main.c b/check/main.c
index 08810c5f..22306cf4 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9494,9 +9494,9 @@  static int populate_csum(struct btrfs_trans_handle *trans,
 }
 
 static int fill_csum_tree_from_one_fs_root(struct btrfs_trans_handle *trans,
-				      struct btrfs_root *csum_root,
-				      struct btrfs_root *cur_root)
+					   struct btrfs_root *cur_root)
 {
+	struct btrfs_root *csum_root = gfs_info->csum_root;
 	struct btrfs_path path;
 	struct btrfs_key key;
 	struct extent_buffer *node;
@@ -9557,8 +9557,7 @@  out:
 	return ret;
 }
 
-static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans,
-				  struct btrfs_root *csum_root)
+static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans)
 {
 	struct btrfs_path path;
 	struct btrfs_root *tree_root = gfs_info->tree_root;
@@ -9598,8 +9597,7 @@  static int fill_csum_tree_from_fs(struct btrfs_trans_handle *trans,
 				key.objectid);
 			goto out;
 		}
-		ret = fill_csum_tree_from_one_fs_root(trans, csum_root,
-				cur_root);
+		ret = fill_csum_tree_from_one_fs_root(trans, cur_root);
 		if (ret < 0)
 			goto out;
 next:
@@ -9617,10 +9615,10 @@  out:
 	return ret;
 }
 
-static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans,
-				      struct btrfs_root *csum_root)
+static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans)
 {
 	struct btrfs_root *extent_root = gfs_info->extent_root;
+	struct btrfs_root *csum_root = gfs_info->csum_root;
 	struct btrfs_path path;
 	struct btrfs_extent_item *ei;
 	struct extent_buffer *leaf;
@@ -9690,13 +9688,12 @@  static int fill_csum_tree_from_extent(struct btrfs_trans_handle *trans,
  * will use fs/subvol trees to init the csum tree.
  */
 static int fill_csum_tree(struct btrfs_trans_handle *trans,
-			  struct btrfs_root *csum_root,
 			  int search_fs_tree)
 {
 	if (search_fs_tree)
-		return fill_csum_tree_from_fs(trans, csum_root);
+		return fill_csum_tree_from_fs(trans);
 	else
-		return fill_csum_tree_from_extent(trans, csum_root);
+		return fill_csum_tree_from_extent(trans);
 }
 
 static void free_roots_info_cache(void)
@@ -10700,8 +10697,7 @@  static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
 				goto close_out;
 			}
 
-			ret = fill_csum_tree(trans, gfs_info->csum_root,
-					     init_extent_tree);
+			ret = fill_csum_tree(trans, init_extent_tree);
 			err |= !!ret;
 			if (ret) {
 				error("checksum tree refilling failed: %d", ret);