linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes
@ 2020-11-15  6:39 xiakaixu1987
  2020-11-16 15:15 ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: xiakaixu1987 @ 2020-11-15  6:39 UTC (permalink / raw)
  To: clm, josef, dsterba; +Cc: linux-btrfs, linux-kernel, Kaixu Xia

From: Kaixu Xia <kaixuxia@tencent.com>

The variable qgroup_to_release is overwritten by the following if/else
statement before it is used, so this assignment is useless. Remove it.

Reported-by: Tosk Robot <tencent_os_robot@tencent.com>
Signed-off-by: Kaixu Xia <kaixuxia@tencent.com>
---
 fs/btrfs/block-rsv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/btrfs/block-rsv.c b/fs/btrfs/block-rsv.c
index bc920afe23bf..8638327069b7 100644
--- a/fs/btrfs/block-rsv.c
+++ b/fs/btrfs/block-rsv.c
@@ -109,10 +109,8 @@ static u64 block_rsv_release_bytes(struct btrfs_fs_info *fs_info,
 	u64 ret;
 
 	spin_lock(&block_rsv->lock);
-	if (num_bytes == (u64)-1) {
+	if (num_bytes == (u64)-1)
 		num_bytes = block_rsv->size;
-		qgroup_to_release = block_rsv->qgroup_rsv_size;
-	}
 	block_rsv->size -= num_bytes;
 	if (block_rsv->reserved >= block_rsv->size) {
 		num_bytes = block_rsv->reserved - block_rsv->size;
-- 
2.20.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes
  2020-11-15  6:39 [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes xiakaixu1987
@ 2020-11-16 15:15 ` David Sterba
  2020-11-17  3:17   ` kaixuxia
  0 siblings, 1 reply; 4+ messages in thread
From: David Sterba @ 2020-11-16 15:15 UTC (permalink / raw)
  To: xiakaixu1987; +Cc: clm, josef, dsterba, linux-btrfs, linux-kernel, Kaixu Xia

On Sun, Nov 15, 2020 at 02:39:23PM +0800, xiakaixu1987@gmail.com wrote:
> From: Kaixu Xia <kaixuxia@tencent.com>
> 
> The variable qgroup_to_release is overwritten by the following if/else
> statement before it is used, so this assignment is useless. Remove it.

Again this lacks explanation why removing it is correct.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes
  2020-11-16 15:15 ` David Sterba
@ 2020-11-17  3:17   ` kaixuxia
  2020-11-23 17:58     ` David Sterba
  0 siblings, 1 reply; 4+ messages in thread
From: kaixuxia @ 2020-11-17  3:17 UTC (permalink / raw)
  To: dsterba, dsterba; +Cc: clm, josef, linux-btrfs, linux-kernel, Kaixu Xia



On 2020/11/16 23:15, David Sterba wrote:
> On Sun, Nov 15, 2020 at 02:39:23PM +0800, xiakaixu1987@gmail.com wrote:
>> From: Kaixu Xia <kaixuxia@tencent.com>
>>
>> The variable qgroup_to_release is overwritten by the following if/else
>> statement before it is used, so this assignment is useless. Remove it.
> 
> Again this lacks explanation why removing it is correct.
> 
Actually this assignment is redundant because the variable qgroup_to_release
has been overwritten before it is used. The logic like this,

 static u64 block_rsv_release_bytes(...)
 {
 ...
        if (num_bytes == (u64)-1) {
                num_bytes = block_rsv->size;
                qgroup_to_release = block_rsv->qgroup_rsv_size;
        }   
        
	//qgroup_to_release isn't used

        if (block_rsv->qgroup_rsv_reserved >= block_rsv->qgroup_rsv_size) {
                qgroup_to_release = block_rsv->qgroup_rsv_reserved -
                                    block_rsv->qgroup_rsv_size;
                block_rsv->qgroup_rsv_reserved = block_rsv->qgroup_rsv_size;
        } else {
                qgroup_to_release = 0;
        }//qgroup_to_release is overwritten    
 ...
 }

Thanks,
Kaixu

-- 
kaixuxia

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes
  2020-11-17  3:17   ` kaixuxia
@ 2020-11-23 17:58     ` David Sterba
  0 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2020-11-23 17:58 UTC (permalink / raw)
  To: kaixuxia
  Cc: dsterba, dsterba, clm, josef, linux-btrfs, linux-kernel, Kaixu Xia

On Tue, Nov 17, 2020 at 11:17:17AM +0800, kaixuxia wrote:
> 
> 
> On 2020/11/16 23:15, David Sterba wrote:
> > On Sun, Nov 15, 2020 at 02:39:23PM +0800, xiakaixu1987@gmail.com wrote:
> >> From: Kaixu Xia <kaixuxia@tencent.com>
> >>
> >> The variable qgroup_to_release is overwritten by the following if/else
> >> statement before it is used, so this assignment is useless. Remove it.
> > 
> > Again this lacks explanation why removing it is correct.
> > 
> Actually this assignment is redundant because the variable qgroup_to_release
> has been overwritten before it is used. The logic like this,

That's obvious and I did not mean that. Have you checked in which commit
the variable became unused and why? It's possible that it was indeed
just an oversight, but if not it could point to a bug.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-11-23 18:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-15  6:39 [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes xiakaixu1987
2020-11-16 15:15 ` David Sterba
2020-11-17  3:17   ` kaixuxia
2020-11-23 17:58     ` David Sterba

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).