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

Qu Wenruo
2024-03-19T23:47:21Z

在 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,