diff mbox series

[04/10] btrfs: reduce parameters of btrfs_pin_reserved_extent

Message ID 339252a0cd7e42cbd8f527601b3c9e7f0d565231.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
There is only one caller of btrfs_pin_reserved_extent that expands 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 | 10 +++++-----
 fs/btrfs/extent-tree.h |  3 ++-
 fs/btrfs/tree-log.c    |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

Comments

Qu Wenruo Sept. 7, 2023, 11:57 p.m. UTC | #1
On 2023/9/8 07:09, David Sterba wrote:
> There is only one caller of btrfs_pin_reserved_extent that expands 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 | 10 +++++-----
>   fs/btrfs/extent-tree.h |  3 ++-
>   fs/btrfs/tree-log.c    |  2 +-
>   3 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index 5ef4e852ae2e..98d97c97ab8c 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -4560,20 +4560,20 @@ int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
>   	return 0;
>   }
>
> -int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start,
> -			      u64 len)
> +int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans,
> +			      const struct extent_buffer *eb)
>   {
>   	struct btrfs_block_group *cache;
>   	int ret = 0;
>
> -	cache = btrfs_lookup_block_group(trans->fs_info, start);
> +	cache = btrfs_lookup_block_group(trans->fs_info, eb->start);
>   	if (!cache) {
>   		btrfs_err(trans->fs_info, "unable to find block group for %llu",
> -			  start);
> +			  eb->start);
>   		return -ENOSPC;
>   	}
>
> -	ret = pin_down_extent(trans, cache, start, len, 1);
> +	ret = pin_down_extent(trans, cache, eb->start, eb->len, 1);
>   	btrfs_put_block_group(cache);
>   	return ret;
>   }
> diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
> index 2109c72aea2a..c56f616dcd1b 100644
> --- a/fs/btrfs/extent-tree.h
> +++ b/fs/btrfs/extent-tree.h
> @@ -139,7 +139,8 @@ int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
>
>   int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
>   			       u64 start, u64 len, int delalloc);
> -int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start, u64 len);
> +int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans,
> +			      const struct extent_buffer *eb);
>   int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
>   int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, struct btrfs_ref *generic_ref);
>   int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref,
> diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
> index 1834a6ec12bd..4f85c435b793 100644
> --- a/fs/btrfs/tree-log.c
> +++ b/fs/btrfs/tree-log.c
> @@ -2574,7 +2574,7 @@ static int clean_log_buffer(struct btrfs_trans_handle *trans,
>   	btrfs_tree_unlock(eb);
>
>   	if (trans) {
> -		ret = btrfs_pin_reserved_extent(trans, eb->start, eb->len);
> +		ret = btrfs_pin_reserved_extent(trans, eb);
>   		if (ret)
>   			return ret;
>   		btrfs_redirty_list_add(trans->transaction, eb);
diff mbox series

Patch

diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 5ef4e852ae2e..98d97c97ab8c 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -4560,20 +4560,20 @@  int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
 	return 0;
 }
 
-int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start,
-			      u64 len)
+int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans,
+			      const struct extent_buffer *eb)
 {
 	struct btrfs_block_group *cache;
 	int ret = 0;
 
-	cache = btrfs_lookup_block_group(trans->fs_info, start);
+	cache = btrfs_lookup_block_group(trans->fs_info, eb->start);
 	if (!cache) {
 		btrfs_err(trans->fs_info, "unable to find block group for %llu",
-			  start);
+			  eb->start);
 		return -ENOSPC;
 	}
 
-	ret = pin_down_extent(trans, cache, start, len, 1);
+	ret = pin_down_extent(trans, cache, eb->start, eb->len, 1);
 	btrfs_put_block_group(cache);
 	return ret;
 }
diff --git a/fs/btrfs/extent-tree.h b/fs/btrfs/extent-tree.h
index 2109c72aea2a..c56f616dcd1b 100644
--- a/fs/btrfs/extent-tree.h
+++ b/fs/btrfs/extent-tree.h
@@ -139,7 +139,8 @@  int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_ref *ref);
 
 int btrfs_free_reserved_extent(struct btrfs_fs_info *fs_info,
 			       u64 start, u64 len, int delalloc);
-int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans, u64 start, u64 len);
+int btrfs_pin_reserved_extent(struct btrfs_trans_handle *trans,
+			      const struct extent_buffer *eb);
 int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans);
 int btrfs_inc_extent_ref(struct btrfs_trans_handle *trans, struct btrfs_ref *generic_ref);
 int btrfs_drop_snapshot(struct btrfs_root *root, int update_ref,
diff --git a/fs/btrfs/tree-log.c b/fs/btrfs/tree-log.c
index 1834a6ec12bd..4f85c435b793 100644
--- a/fs/btrfs/tree-log.c
+++ b/fs/btrfs/tree-log.c
@@ -2574,7 +2574,7 @@  static int clean_log_buffer(struct btrfs_trans_handle *trans,
 	btrfs_tree_unlock(eb);
 
 	if (trans) {
-		ret = btrfs_pin_reserved_extent(trans, eb->start, eb->len);
+		ret = btrfs_pin_reserved_extent(trans, eb);
 		if (ret)
 			return ret;
 		btrfs_redirty_list_add(trans->transaction, eb);