diff mbox series

[05/10] btrfs: reduce parameters of btrfs_pin_extent_for_log_replay

Message ID 579a7f7e44703c87aa64a253e6f4c14b4bde8c24.1694126893.git.dsterba@suse.com (mailing list archive)
State New, archived
Headers show
Series Cleanups and struct packing | expand

Commit Message

David Sterba Sept. 7, 2023, 11:09 p.m. UTC
Both callers of btrfs_pin_extent_for_log_replay expand the parameters to
extent buffer members. We can simply pass the extent buffer instead.

Signed-off-by: David Sterba <dsterba@suse.com>
---
 fs/btrfs/extent-tree.c | 8 ++++----
 fs/btrfs/extent-tree.h | 2 +-
 fs/btrfs/tree-log.c    | 7 ++-----
 3 files changed, 7 insertions(+), 10 deletions(-)

Comments

Qu Wenruo Sept. 7, 2023, 11:57 p.m. UTC | #1
On 2023/9/8 07:09, David Sterba wrote:
> Both callers of btrfs_pin_extent_for_log_replay expand the parameters to
> extent buffer members. We can simply pass the extent buffer instead.
>
> Signed-off-by: David Sterba <dsterba@suse.com>

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

Thanks,
Qu

> ---
>   fs/btrfs/extent-tree.c | 8 ++++----
>   fs/btrfs/extent-tree.h | 2 +-
>   fs/btrfs/tree-log.c    | 7 ++-----
>   3 files changed, 7 insertions(+), 10 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 98d97c97ab8c..3e46bb4cc957 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -2567,12 +2567,12 @@ int btrfs_pin_extent(struct btrfs_trans_handle *trans,
>    * this function must be called within transaction
>    */
>   int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
> -				    u64 bytenr, u64 num_bytes)
> +				    const struct extent_buffer *eb)
>   {
>   	struct btrfs_block_group *cache;
>   	int ret;
>
> -	cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
> +	cache = btrfs_lookup_block_group(trans->fs_info, eb->start);
>   	if (!cache)
>   		return -EINVAL;
>
> @@ -2584,10 +2584,10 @@ int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
>   	if (ret)
>   		goto out;
>
> -	pin_down_extent(trans, cache, bytenr, num_bytes, 0);
> +	pin_down_extent(trans, cache, eb->start, eb->len, 0);
>
>   	/* remove us from the free space cache (if we're there at all) */
> -	ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
> +	ret = btrfs_remove_free_space(cache, eb->start, eb->len);
>   out:
>   	btrfs_put_block_group(cache);
>   	return ret;
> diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
> index c56f616dcd1b..dd31ee85f360 100644
> --- a/fs/btrfs/extent-tree.h
> +++ b/fs/btrfs/extent-tree.h
> @@ -103,7 +103,7 @@ int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
>   int btrfs_pin_extent(struct btrfs_trans_handle *trans, u64 bytenr, u64 num,
>   		     int reserved);
>   int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
> -				    u64 bytenr, u64 num_bytes);
> +				    const struct extent_buffer *eb);
>   int btrfs_exclude_logged_extents(struct extent_buffer *eb);
>   int btrfs_cross_ref_exist(struct btrfs_root *root,
>   			  u64 objectid, u64 offset, u64 bytenr, bool strict,
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 4f85c435b793..15c8cb6627fe 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -347,8 +347,7 @@ static int process_one_buffer(struct btrfs_root *log,
>   	}
>
>   	if (wc->pin) {
> -		ret = btrfs_pin_extent_for_log_replay(wc->trans, eb->start,
> -						      eb->len);
> +		ret = btrfs_pin_extent_for_log_replay(wc->trans, eb);
>   		if (ret)
>   			return ret;
>
> @@ -7203,9 +7202,7 @@ int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
>   			 * each subsequent pass.
>   			 */
>   			if (ret == -ENOENT)
> -				ret = btrfs_pin_extent_for_log_replay(trans,
> -							log->node->start,
> -							log->node->len);
> +				ret = btrfs_pin_extent_for_log_replay(trans, log->node);
>   			btrfs_put_root(log);
>
>   			if (!ret)
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 98d97c97ab8c..3e46bb4cc957 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -2567,12 +2567,12 @@  int btrfs_pin_extent(struct btrfs_trans_handle *trans,
  * this function must be called within transaction
  */
 int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
-				    u64 bytenr, u64 num_bytes)
+				    const struct extent_buffer *eb)
 {
 	struct btrfs_block_group *cache;
 	int ret;
 
-	cache = btrfs_lookup_block_group(trans->fs_info, bytenr);
+	cache = btrfs_lookup_block_group(trans->fs_info, eb->start);
 	if (!cache)
 		return -EINVAL;
 
@@ -2584,10 +2584,10 @@  int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
 	if (ret)
 		goto out;
 
-	pin_down_extent(trans, cache, bytenr, num_bytes, 0);
+	pin_down_extent(trans, cache, eb->start, eb->len, 0);
 
 	/* remove us from the free space cache (if we're there at all) */
-	ret = btrfs_remove_free_space(cache, bytenr, num_bytes);
+	ret = btrfs_remove_free_space(cache, eb->start, eb->len);
 out:
 	btrfs_put_block_group(cache);
 	return ret;
diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
index c56f616dcd1b..dd31ee85f360 100644
--- a/fs/btrfs/extent-tree.h
+++ b/fs/btrfs/extent-tree.h
@@ -103,7 +103,7 @@  int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 int btrfs_pin_extent(struct btrfs_trans_handle *trans, u64 bytenr, u64 num,
 		     int reserved);
 int btrfs_pin_extent_for_log_replay(struct btrfs_trans_handle *trans,
-				    u64 bytenr, u64 num_bytes);
+				    const struct extent_buffer *eb);
 int btrfs_exclude_logged_extents(struct extent_buffer *eb);
 int btrfs_cross_ref_exist(struct btrfs_root *root,
 			  u64 objectid, u64 offset, u64 bytenr, bool strict,
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 4f85c435b793..15c8cb6627fe 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -347,8 +347,7 @@  static int process_one_buffer(struct btrfs_root *log,
 	}
 
 	if (wc->pin) {
-		ret = btrfs_pin_extent_for_log_replay(wc->trans, eb->start,
-						      eb->len);
+		ret = btrfs_pin_extent_for_log_replay(wc->trans, eb);
 		if (ret)
 			return ret;
 
@@ -7203,9 +7202,7 @@  int btrfs_recover_log_trees(struct btrfs_root *log_root_tree)
 			 * each subsequent pass.
 			 */
 			if (ret == -ENOENT)
-				ret = btrfs_pin_extent_for_log_replay(trans,
-							log->node->start,
-							log->node->len);
+				ret = btrfs_pin_extent_for_log_replay(trans, log->node);
 			btrfs_put_root(log);
 
 			if (!ret)