diff mbox series

[13/29] btrfs: __btrfs_wait_marked_extents rename werr to ret err to ret2

Message ID 2e8fef09405de09488a3dde439d213dee33e117e.1710857863.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series trivial adjustments for return variable coding style | expand

Commit Message

Anand Jain March 19, 2024, 2:55 p.m. UTC
Rename the function's local variable werr to ret, and err to ret2.
Also, align these two variable declarations with the other declarations in
the function for better function space alignment.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/transaction.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Josef Bacik March 19, 2024, 5:54 p.m. UTC | #1
On Tue, Mar 19, 2024 at 08:25:21PM +0530, Anand Jain wrote:
> Rename the function's local variable werr to ret, and err to ret2.
> Also, align these two variable declarations with the other declarations in
> the function for better function space alignment.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/transaction.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
> 
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 167893457b58..f344f97a6035 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -1173,12 +1173,12 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
>  static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
>  				       struct extent_io_tree *dirty_pages)
>  {
> -	int err = 0;
> -	int werr = 0;
>  	struct address_space *mapping = fs_info->btree_inode->i_mapping;
>  	struct extent_state *cached_state = NULL;
>  	u64 start = 0;
>  	u64 end;
> +	int ret = 0;
> +	int ret2 = 0;
>  
>  	while (find_first_extent_bit(dirty_pages, start, &start, &end,
>  				     EXTENT_NEED_WAIT, &cached_state)) {
> @@ -1190,22 +1190,22 @@ static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
>  		 * concurrently - we do it only at transaction commit time when
>  		 * it's safe to do it (through extent_io_tree_release()).
>  		 */
> -		err = clear_extent_bit(dirty_pages, start, end,
> -				       EXTENT_NEED_WAIT, &cached_state);
> -		if (err == -ENOMEM)
> -			err = 0;
> -		if (!err)
> -			err = filemap_fdatawait_range(mapping, start, end);
> -		if (err)
> -			werr = err;
> +		ret2 = clear_extent_bit(dirty_pages, start, end,
> +					EXTENT_NEED_WAIT, &cached_state);
> +		if (ret2 == -ENOMEM)
> +			ret2 = 0;
> +		if (!ret2)
> +			ret2 = filemap_fdatawait_range(mapping, start, end);
> +		if (ret2)
> +			ret = ret2;

Same comment here as the previous one.  In fact now that I think about it I'd
rather you fix this problem first, and then do the cleanup, so we can easily
backport the fix to stable kernels.

Then once you clean everything up you can change this to just use one ret
variable.  Thanks,

Josef
Qu Wenruo March 19, 2024, 11:47 p.m. UTC | #2
在 2024/3/20 01:25, Anand Jain 写道:
> Rename the function's local variable werr to ret, and err to ret2.
> Also, align these two variable declarations with the other declarations in
> the function for better function space alignment.
>
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Again, not a fan of @ret2.

And IIRC we can declare the variable used inside the loop local, by
making sure we set the global ret properly before breaking the loop.

Thanks,
Qu
> ---
>   fs/btrfs/transaction.c | 26 +++++++++++++-------------
>   1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
> index 167893457b58..f344f97a6035 100644
> --- a/fs/btrfs/transaction.c
> +++ b/fs/btrfs/transaction.c
> @@ -1173,12 +1173,12 @@ int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
>   static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
>   				       struct extent_io_tree *dirty_pages)
>   {
> -	int err = 0;
> -	int werr = 0;
>   	struct address_space *mapping = fs_info->btree_inode->i_mapping;
>   	struct extent_state *cached_state = NULL;
>   	u64 start = 0;
>   	u64 end;
> +	int ret = 0;
> +	int ret2 = 0;
>
>   	while (find_first_extent_bit(dirty_pages, start, &start, &end,
>   				     EXTENT_NEED_WAIT, &cached_state)) {
> @@ -1190,22 +1190,22 @@ static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
>   		 * concurrently - we do it only at transaction commit time when
>   		 * it's safe to do it (through extent_io_tree_release()).
>   		 */
> -		err = clear_extent_bit(dirty_pages, start, end,
> -				       EXTENT_NEED_WAIT, &cached_state);
> -		if (err == -ENOMEM)
> -			err = 0;
> -		if (!err)
> -			err = filemap_fdatawait_range(mapping, start, end);
> -		if (err)
> -			werr = err;
> +		ret2 = clear_extent_bit(dirty_pages, start, end,
> +					EXTENT_NEED_WAIT, &cached_state);
> +		if (ret2 == -ENOMEM)
> +			ret2 = 0;
> +		if (!ret2)
> +			ret2 = filemap_fdatawait_range(mapping, start, end);
> +		if (ret2)
> +			ret = ret2;
>   		free_extent_state(cached_state);
>   		cached_state = NULL;
>   		cond_resched();
>   		start = end + 1;
>   	}
> -	if (err)
> -		werr = err;
> -	return werr;
> +	if (ret2)
> +		ret = ret2;
> +	return ret;
>   }
>
>   static int btrfs_wait_extents(struct btrfs_fs_info *fs_info,
diff mbox series

Patch

diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c
index 167893457b58..f344f97a6035 100644
--- a/fs/btrfs/transaction.c
+++ b/fs/btrfs/transaction.c
@@ -1173,12 +1173,12 @@  int btrfs_write_marked_extents(struct btrfs_fs_info *fs_info,
 static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
 				       struct extent_io_tree *dirty_pages)
 {
-	int err = 0;
-	int werr = 0;
 	struct address_space *mapping = fs_info->btree_inode->i_mapping;
 	struct extent_state *cached_state = NULL;
 	u64 start = 0;
 	u64 end;
+	int ret = 0;
+	int ret2 = 0;
 
 	while (find_first_extent_bit(dirty_pages, start, &start, &end,
 				     EXTENT_NEED_WAIT, &cached_state)) {
@@ -1190,22 +1190,22 @@  static int __btrfs_wait_marked_extents(struct btrfs_fs_info *fs_info,
 		 * concurrently - we do it only at transaction commit time when
 		 * it's safe to do it (through extent_io_tree_release()).
 		 */
-		err = clear_extent_bit(dirty_pages, start, end,
-				       EXTENT_NEED_WAIT, &cached_state);
-		if (err == -ENOMEM)
-			err = 0;
-		if (!err)
-			err = filemap_fdatawait_range(mapping, start, end);
-		if (err)
-			werr = err;
+		ret2 = clear_extent_bit(dirty_pages, start, end,
+					EXTENT_NEED_WAIT, &cached_state);
+		if (ret2 == -ENOMEM)
+			ret2 = 0;
+		if (!ret2)
+			ret2 = filemap_fdatawait_range(mapping, start, end);
+		if (ret2)
+			ret = ret2;
 		free_extent_state(cached_state);
 		cached_state = NULL;
 		cond_resched();
 		start = end + 1;
 	}
-	if (err)
-		werr = err;
-	return werr;
+	if (ret2)
+		ret = ret2;
+	return ret;
 }
 
 static int btrfs_wait_extents(struct btrfs_fs_info *fs_info,