btrfs: drop math for block_reserved which is block_rsv size
diff mbox series

Message ID 1580814358-1468-1-git-send-email-anand.jain@oracle.com
State New
Headers show
Series
  • btrfs: drop math for block_reserved which is block_rsv size
Related show

Commit Message

Anand Jain Feb. 4, 2020, 11:05 a.m. UTC
In btrfs_update_global_block_rsv the lines
  num_bytes = block_rsv->size - block_rsv->reserved;
  block_rsv->reserved += num_bytes;
imply
  block_rsv->reserved = block_rsv->size;

Just assign block_rsv->size to block_rsv->reserved instead of the math.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
 fs/btrfs/block-rsv.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nikolay Borisov Feb. 4, 2020, 11:10 a.m. UTC | #1
On 4.02.20 г. 13:05 ч., Anand Jain wrote:
> In btrfs_update_global_block_rsv the lines
>   num_bytes = block_rsv->size - block_rsv->reserved;
>   block_rsv->reserved += num_bytes;
> imply
>   block_rsv->reserved = block_rsv->size;
> 
> Just assign block_rsv->size to block_rsv->reserved instead of the math.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
>  fs/btrfs/block-rsv.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
> index 6dacde9a7e93..62e0885c1e5d 100644
> --- a/fs/btrfs/block-rsv.c
> +++ b/fs/btrfs/block-rsv.c
> @@ -304,9 +304,9 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
>  
>  	if (block_rsv->reserved < block_rsv->size) {
>  		num_bytes = block_rsv->size - block_rsv->reserved;
> -		block_rsv->reserved += num_bytes;
>  		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
>  						      num_bytes);
> +		block_rsv->reserved = block_rsv->size;

Any particular reason why you put the assignment after
btrfs_space_info_update_bytes_may_use and not before?
>  	} else if (block_rsv->reserved > block_rsv->size) {
>  		num_bytes = block_rsv->reserved - block_rsv->size;
>  		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
>
Anand Jain Feb. 4, 2020, 12:46 p.m. UTC | #2
On 2/4/20 7:10 PM, Nikolay Borisov wrote:
> 
> 
> On 4.02.20 г. 13:05 ч., Anand Jain wrote:
>> In btrfs_update_global_block_rsv the lines
>>    num_bytes = block_rsv->size - block_rsv->reserved;
>>    block_rsv->reserved += num_bytes;
>> imply
>>    block_rsv->reserved = block_rsv->size;
>>
>> Just assign block_rsv->size to block_rsv->reserved instead of the math.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>>   fs/btrfs/block-rsv.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
>> index 6dacde9a7e93..62e0885c1e5d 100644
>> --- a/fs/btrfs/block-rsv.c
>> +++ b/fs/btrfs/block-rsv.c
>> @@ -304,9 +304,9 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
>>   
>>   	if (block_rsv->reserved < block_rsv->size) {
>>   		num_bytes = block_rsv->size - block_rsv->reserved;
>> -		block_rsv->reserved += num_bytes;
>>   		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
>>   						      num_bytes);
>> +		block_rsv->reserved = block_rsv->size;
> 
> Any particular reason why you put the assignment after
> btrfs_space_info_update_bytes_may_use and not before?

  Oh. To make it similar to the else if part below.

Thanks.

>>   	} else if (block_rsv->reserved > block_rsv->size) {
>>   		num_bytes = block_rsv->reserved - block_rsv->size;
>>   		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
>>
David Sterba Feb. 24, 2020, 7:08 p.m. UTC | #3
On Tue, Feb 04, 2020 at 08:46:04PM +0800, Anand Jain wrote:
> 
> 
> On 2/4/20 7:10 PM, Nikolay Borisov wrote:
> > 
> > 
> > On 4.02.20 г. 13:05 ч., Anand Jain wrote:
> >> In btrfs_update_global_block_rsv the lines
> >>    num_bytes = block_rsv->size - block_rsv->reserved;
> >>    block_rsv->reserved += num_bytes;
> >> imply
> >>    block_rsv->reserved = block_rsv->size;
> >>
> >> Just assign block_rsv->size to block_rsv->reserved instead of the math.
> >>
> >> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> >> ---
> >>   fs/btrfs/block-rsv.c | 2 +-
> >>   1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
> >> index 6dacde9a7e93..62e0885c1e5d 100644
> >> --- a/fs/btrfs/block-rsv.c
> >> +++ b/fs/btrfs/block-rsv.c
> >> @@ -304,9 +304,9 @@ void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
> >>   
> >>   	if (block_rsv->reserved < block_rsv->size) {
> >>   		num_bytes = block_rsv->size - block_rsv->reserved;
> >> -		block_rsv->reserved += num_bytes;
> >>   		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
> >>   						      num_bytes);
> >> +		block_rsv->reserved = block_rsv->size;
> > 
> > Any particular reason why you put the assignment after
> > btrfs_space_info_update_bytes_may_use and not before?
> 
>   Oh. To make it similar to the else if part below.

Makes sense. For cleanup patches, such things can be mentioned in the
changelog, reordering lines may have indirect implications eg. if the
block_rsv would be used in btrfs_space_info_update_bytes_may_use (but it
is not). Patch added to misc-next, thanks.

Patch
diff mbox series

diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
index 6dacde9a7e93..62e0885c1e5d 100644
--- a/fs/btrfs/block-rsv.c
+++ b/fs/btrfs/block-rsv.c
@@ -304,9 +304,9 @@  void btrfs_update_global_block_rsv(struct btrfs_fs_info *fs_info)
 
 	if (block_rsv->reserved < block_rsv->size) {
 		num_bytes = block_rsv->size - block_rsv->reserved;
-		block_rsv->reserved += num_bytes;
 		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,
 						      num_bytes);
+		block_rsv->reserved = block_rsv->size;
 	} else if (block_rsv->reserved > block_rsv->size) {
 		num_bytes = block_rsv->reserved - block_rsv->size;
 		btrfs_space_info_update_bytes_may_use(fs_info, sinfo,