Re: [PATCH] btrfs: Simplify update space_info in __reserve_metadata_bytes()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 19.06.19 г. 17:12 ч., Goldwyn Rodrigues wrote:
> From: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>
> 
> Simplification.
> We don't need an if-else-if structure where we can use a
> simple OR since both conditions are performing the
> same action. The short-circuit for OR will ensure that if
> the first condition is true, can_overcommit() is not
> called.
> 
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn@xxxxxxxx>

Reviewed-by: Nikolay Borisov <nborisov@xxxxxxxx>

> ---
>  fs/btrfs/extent-tree.c | 14 +++++---------
>  1 file changed, 5 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
> index c7adff343ba9..84a33cbb1e68 100644
> --- a/fs/btrfs/extent-tree.c
> +++ b/fs/btrfs/extent-tree.c
> @@ -5158,17 +5158,13 @@ static int __reserve_metadata_bytes(struct btrfs_fs_info *fs_info,
>  	used = btrfs_space_info_used(space_info, true);
>  
>  	/*
> -	 * If we have enough space then hooray, make our reservation and carry
> -	 * on.  If not see if we can overcommit, and if we can, hooray carry on.
> +	 * Carry on if we have enough space (short-circuit) OR call
> +	 * can_overcommit() to ensure we can overcommit to carry on.
>  	 * If not things get more complicated.
>  	 */
> -	if (used + orig_bytes <= space_info->total_bytes) {
> -		update_bytes_may_use(space_info, orig_bytes);
> -		trace_btrfs_space_reservation(fs_info, "space_info",
> -					      space_info->flags, orig_bytes, 1);
> -		ret = 0;
> -	} else if (can_overcommit(fs_info, space_info, orig_bytes, flush,
> -				  system_chunk)) {
> +	if ((used + orig_bytes <= space_info->total_bytes) ||
> +	    can_overcommit(fs_info, space_info, orig_bytes, flush,
> +			    system_chunk)) {
>  		update_bytes_may_use(space_info, orig_bytes);
>  		trace_btrfs_space_reservation(fs_info, "space_info",
>  					      space_info->flags, orig_bytes, 1);
> 



[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux