[PATCH 1/1] fs: btrfs: simplify close_ctree_fs_info()

Qu Wenruo wqu at suse.com
Fri Dec 25 14:08:58 CET 2020



On 2020/12/25 下午8:45, Heinrich Schuchardt wrote:
> At the beginning of close_ctree_fs_info() the value 0 is assigned to err
> and never changed before testing it.
> 
> Let's get rid of the superfluous variable.
> 
> Fixes: f06bfcf54d0e ("fs: btrfs: Crossport open_ctree_fs_info() from btrfs-progs")

This is because current btrfs implementation of U-boot only support RO 
mount.

In btrfs-progs, since we support RW support, we will try to commit 
transaction and we can hit error during transaction commit.
Thus we use @ret to record current error and @error to record the final 
return value.

I don't believe U-boot would support btrfs read-write any time soon, 
thus the cleanup should be OK.

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

Thanks,
Qu

> Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
> ---
>   fs/btrfs/disk-io.c | 5 +----
>   1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
> index 01e7cee520..b332ecb796 100644
> --- a/fs/btrfs/disk-io.c
> +++ b/fs/btrfs/disk-io.c
> @@ -1030,7 +1030,6 @@ out:
>   int close_ctree_fs_info(struct btrfs_fs_info *fs_info)
>   {
>   	int ret;
> -	int err = 0;
> 
>   	free_fs_roots_tree(&fs_info->fs_root_tree);
> 
> @@ -1038,9 +1037,7 @@ int close_ctree_fs_info(struct btrfs_fs_info *fs_info)
>   	ret = btrfs_close_devices(fs_info->fs_devices);
>   	btrfs_cleanup_all_caches(fs_info);
>   	btrfs_free_fs_info(fs_info);
> -	if (!err)
> -		err = ret;
> -	return err;
> +	return ret;
>   }
> 
>   int btrfs_buffer_uptodate(struct extent_buffer *buf, u64 parent_transid)
> --
> 2.29.2
> 



More information about the U-Boot mailing list