public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: Anand Jain <anand.jain@oracle.com>
Cc: linux-btrfs@vger.kernel.org
Subject: Re: [PATCH 18/29] btrfs: btrfs_relocate_block_group rename ret to ret2 and err ro ret
Date: Tue, 19 Mar 2024 14:04:34 -0400	[thread overview]
Message-ID: <20240319180434.GG2982591@perftesting> (raw)
In-Reply-To: <2af7ad0bfb1d016f4e5668d96cfc7d41c185cce7.1710857863.git.anand.jain@oracle.com>

On Tue, Mar 19, 2024 at 08:25:26PM +0530, Anand Jain wrote:
> Renaem the existing ret variable is renamed to ret2.
> Since the variable err is the return variable of the function,
> rename it to ret. 
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/relocation.c | 56 +++++++++++++++++++++----------------------
>  1 file changed, 28 insertions(+), 28 deletions(-)
> 
> diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
> index 16a3882a4a7c..030262943190 100644
> --- a/fs/btrfs/relocation.c
> +++ b/fs/btrfs/relocation.c
> @@ -4070,18 +4070,18 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  	struct reloc_control *rc;
>  	struct inode *inode;
>  	struct btrfs_path *path;
> -	int ret;
> +	int ret2;
>  	int rw = 0;
> -	int err = 0;
> +	int ret = 0;
>  
>  	/*
>  	 * This only gets set if we had a half-deleted snapshot on mount.  We
>  	 * cannot allow relocation to start while we're still trying to clean up
>  	 * these pending deletions.
>  	 */
> -	ret = wait_on_bit(&fs_info->flags, BTRFS_FS_UNFINISHED_DROPS, TASK_INTERRUPTIBLE);
> -	if (ret)
> -		return ret;
> +	ret2 = wait_on_bit(&fs_info->flags, BTRFS_FS_UNFINISHED_DROPS, TASK_INTERRUPTIBLE);
> +	if (ret2)
> +		return ret2;
>  
>  	/* We may have been woken up by close_ctree, so bail if we're closing. */
>  	if (btrfs_fs_closing(fs_info))
> @@ -4113,25 +4113,25 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  		return -ENOMEM;
>  	}
>  
> -	ret = reloc_chunk_start(fs_info);
> -	if (ret < 0) {
> -		err = ret;
> +	ret2 = reloc_chunk_start(fs_info);
> +	if (ret2 < 0) {
> +		ret = ret2;
>  		goto out_put_bg;
>  	}
>  
>  	rc->extent_root = extent_root;
>  	rc->block_group = bg;
>  
> -	ret = btrfs_inc_block_group_ro(rc->block_group, true);
> -	if (ret) {
> -		err = ret;
> +	ret2 = btrfs_inc_block_group_ro(rc->block_group, true);
> +	if (ret2) {
> +		ret = ret2;
>  		goto out;
>  	}
>  	rw = 1;
>  
>  	path = btrfs_alloc_path();
>  	if (!path) {
> -		err = -ENOMEM;
> +		ret = -ENOMEM;
>  		goto out;
>  	}
>  
> @@ -4139,18 +4139,18 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  	btrfs_free_path(path);
>  
>  	if (!IS_ERR(inode))
> -		ret = delete_block_group_cache(fs_info, rc->block_group, inode, 0);
> +		ret2 = delete_block_group_cache(fs_info, rc->block_group, inode, 0);
>  	else
> -		ret = PTR_ERR(inode);
> +		ret2 = PTR_ERR(inode);
>  
> -	if (ret && ret != -ENOENT) {
> -		err = ret;
> +	if (ret2 && ret2 != -ENOENT) {
> +		ret = ret2;
>  		goto out;
>  	}
>  
>  	rc->data_inode = create_reloc_inode(fs_info, rc->block_group);
>  	if (IS_ERR(rc->data_inode)) {
> -		err = PTR_ERR(rc->data_inode);
> +		ret = PTR_ERR(rc->data_inode);
>  		rc->data_inode = NULL;
>  		goto out;
>  	}
> @@ -4163,17 +4163,17 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  				 rc->block_group->start,
>  				 rc->block_group->length);
>  
> -	ret = btrfs_zone_finish(rc->block_group);
> -	WARN_ON(ret && ret != -EAGAIN);
> +	ret2 = btrfs_zone_finish(rc->block_group);
> +	WARN_ON(ret2 && ret2 != -EAGAIN);
>  
>  	while (1) {
>  		enum reloc_stage finishes_stage;
>  
>  		mutex_lock(&fs_info->cleaner_mutex);
> -		ret = relocate_block_group(rc);
> +		ret2 = relocate_block_group(rc);
>  		mutex_unlock(&fs_info->cleaner_mutex);
> -		if (ret < 0)
> -			err = ret;
> +		if (ret2 < 0)
> +			ret = ret2;
>  
>  		finishes_stage = rc->stage;
>  		/*
> @@ -4186,16 +4186,16 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start)
>  		 * out of the loop if we hit an error.
>  		 */
>  		if (rc->stage == MOVE_DATA_EXTENTS && rc->found_file_extent) {
> -			ret = btrfs_wait_ordered_range(rc->data_inode, 0,
> +			ret2 = btrfs_wait_ordered_range(rc->data_inode, 0,
>  						       (u64)-1);
> -			if (ret)
> -				err = ret;
> +			if (ret2)
> +				ret = ret2;

Ok this is another place where we'll lose ret if it was already set from higher
up.  It's less bad here because we're only doing it if there was an error in
btrfs_wait_ordered_range().  But nonetheless I would like to preserve the error
code from higher up.  So add this to the series you write to fixup the other
error handling.

Then once you've done that, fix this patch to _only_ use ret2 in this block,
because for the rest of the code we can use ret for everything else.  Thanks,

Josef

  reply	other threads:[~2024-03-19 18:04 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-19 14:55 [PATCH 00/29] trivial adjustments for return variable coding style Anand Jain
2024-03-19 14:55 ` [PATCH 01/29] btrfs: btrfs_cleanup_fs_roots rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:38   ` Josef Bacik
2024-03-19 20:43   ` Qu Wenruo
2024-04-17  3:24     ` Anand Jain
2024-04-17  3:59       ` Qu Wenruo
2024-03-20 21:17   ` Goffredo Baroncelli
2024-03-19 14:55 ` [PATCH 02/29] btrfs: btrfs_initxattrs rename " Anand Jain
2024-03-19 14:55 ` [PATCH 03/29] btrfs: send_extent_data " Anand Jain
2024-03-20 12:59   ` Filipe Manana
2024-03-19 14:55 ` [PATCH 04/29] btrfs: btrfs_rmdir " Anand Jain
2024-03-19 14:55 ` [PATCH 05/29] btrfs: btrfs_cont_expand " Anand Jain
2024-03-19 14:55 ` [PATCH 06/29] btrfs: btrfs_setsize rename err to ret2 Anand Jain
2024-03-19 14:55 ` [PATCH 07/29] btrfs: btrfs_find_orphan_roots rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:44   ` Josef Bacik
2024-03-19 21:09   ` Qu Wenruo
2024-03-19 14:55 ` [PATCH 08/29] btrfs: btrfs_ioctl_snap_destroy rename " Anand Jain
2024-03-19 14:55 ` [PATCH 09/29] btrfs: __set_extent_bit " Anand Jain
2024-03-19 14:55 ` [PATCH 10/29] btrfs: convert_extent_bit " Anand Jain
2024-03-19 14:55 ` [PATCH 11/29] btrfs: __btrfs_end_transaction " Anand Jain
2024-03-19 14:55 ` [PATCH 12/29] btrfs: btrfs_write_marked_extents rename werr to ret err to ret2 Anand Jain
2024-03-19 17:53   ` Josef Bacik
2024-04-16  2:39     ` Anand Jain
2024-03-19 21:25   ` Qu Wenruo
2024-04-16  3:18     ` Anand Jain
2024-03-19 14:55 ` [PATCH 13/29] btrfs: __btrfs_wait_marked_extents " Anand Jain
2024-03-19 17:54   ` Josef Bacik
2024-03-19 23:47   ` Qu Wenruo
2024-03-19 14:55 ` [PATCH 14/29] btrfs: build_backref_tree rename err to ret and ret " Anand Jain
2024-03-19 17:57   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 15/29] btrfs: relocate_tree_blocks rename ret to ret2 and err to ret Anand Jain
2024-03-19 17:58   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 16/29] btrfs: relocate_block_group " Anand Jain
2024-03-19 14:55 ` [PATCH 17/29] btrfs: create_reloc_inode rename " Anand Jain
2024-03-19 14:55 ` [PATCH 18/29] btrfs: btrfs_relocate_block_group rename ret to ret2 and err ro ret Anand Jain
2024-03-19 18:04   ` Josef Bacik [this message]
2024-03-19 14:55 ` [PATCH 19/29] btrfs: mark_garbage_root rename err to ret2 Anand Jain
2024-03-19 18:07   ` Josef Bacik
2024-03-22  2:29     ` David Sterba
2024-03-19 14:55 ` [PATCH 20/29] btrfs: btrfs_recover_relocation rename ret to ret2 and err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 21/29] btrfs: quick_update_accounting rename err to ret2 Anand Jain
2024-03-19 18:10   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 22/29] btrfs: btrfs_qgroup_rescan_worker rename ret to ret2 and err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 23/29] btrfs: lookup_extent_data_ref " Anand Jain
2024-03-19 18:17   ` Josef Bacik
2024-04-18  6:55     ` Anand Jain
2024-03-19 14:55 ` [PATCH 24/29] btrfs: btrfs_drop_snapshot " Anand Jain
2024-03-19 18:20   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 25/29] btrfs: btrfs_drop_subtree rename retw to ret2 Anand Jain
2024-03-19 18:22   ` Josef Bacik
2024-03-19 14:55 ` [PATCH 26/29] btrfs: btrfs_dirty_pages rename variable err to ret Anand Jain
2024-03-19 14:55 ` [PATCH 27/29] btrfs: prepare_pages rename " Anand Jain
2024-03-19 14:55 ` [PATCH 28/29] btrfs: btrfs_direct_write " Anand Jain
2024-03-19 14:55 ` [PATCH 29/29] btrfs: fixup_tree_root_location rename ret to ret2 and " Anand Jain
2024-03-19 18:24   ` Josef Bacik
2024-04-16 10:42     ` Anand Jain
2024-04-16 10:44       ` Anand Jain
2024-03-22  2:32 ` [PATCH 00/29] trivial adjustments for return variable coding style David Sterba
2024-03-25  9:37   ` Anand Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240319180434.GG2982591@perftesting \
    --to=josef@toxicpanda.com \
    --cc=anand.jain@oracle.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox