Re: [PATCH] btrfs: remove the useless value assignment in block_rsv_release_bytes
From: kaixuxia
Date: Mon Nov 16 2020 - 22:18:17 EST
On 2020/11/16 23:15, David Sterba wrote:
> On Sun, Nov 15, 2020 at 02:39:23PM +0800, xiakaixu1987@xxxxxxxxx wrote:
>> From: Kaixu Xia <kaixuxia@xxxxxxxxxxx>
>>
>> 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