Linux-BTRFS Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] btrfs: qgroup: Fix the wrong io_tree when freeing reserved data space
@ 2019-09-12  1:13 Qu Wenruo
  2019-09-12  7:53 ` Filipe Manana
  0 siblings, 1 reply; 3+ messages in thread
From: Qu Wenruo @ 2019-09-12  1:13 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Josef Bacik

Commit bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by
only freeing reserved ranges") is freeing wrong range in
BTRFS_I()->io_failure_tree, which should be BTRFS_I()->io_tree.

Just fix it.

Reported-by: Josef Bacik <josef@toxicpanda.com>
Fixes: bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by only freeing reserved ranges")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 fs/btrfs/qgroup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
index 2891b57b9e1e..64bdc3e3652d 100644
--- a/fs/btrfs/qgroup.c
+++ b/fs/btrfs/qgroup.c
@@ -3492,7 +3492,7 @@ static int qgroup_free_reserved_data(struct inode *inode,
 		 * EXTENT_QGROUP_RESERVED, we won't double free.
 		 * So not need to rush.
 		 */
-		ret = clear_record_extent_bits(&BTRFS_I(inode)->io_failure_tree,
+		ret = clear_record_extent_bits(&BTRFS_I(inode)->io_tree,
 				free_start, free_start + free_len - 1,
 				EXTENT_QGROUP_RESERVED, &changeset);
 		if (ret < 0)
-- 
2.23.0


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

* Re: [PATCH] btrfs: qgroup: Fix the wrong io_tree when freeing reserved data space
  2019-09-12  1:13 [PATCH] btrfs: qgroup: Fix the wrong io_tree when freeing reserved data space Qu Wenruo
@ 2019-09-12  7:53 ` Filipe Manana
  2019-09-12  8:32   ` Qu Wenruo
  0 siblings, 1 reply; 3+ messages in thread
From: Filipe Manana @ 2019-09-12  7:53 UTC (permalink / raw)
  To: Qu Wenruo; +Cc: linux-btrfs, Josef Bacik

On Thu, Sep 12, 2019 at 2:31 AM Qu Wenruo <wqu@suse.com> wrote:
>
> Commit bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by
> only freeing reserved ranges") is freeing wrong range in
> BTRFS_I()->io_failure_tree, which should be BTRFS_I()->io_tree.

I think you meant wrong tree and not wrong range, since the code
doesn't change the range, only the target tree.

Also, for the sake of completeness, and no matter how obvious you
think it is, can you explicitly mention what's the consequence? I
presume it's a qgroup reserved space leak or underflow.

Thanks.

>
> Just fix it.
>
> Reported-by: Josef Bacik <josef@toxicpanda.com>
> Fixes: bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by only freeing reserved ranges")
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
>  fs/btrfs/qgroup.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
> index 2891b57b9e1e..64bdc3e3652d 100644
> --- a/fs/btrfs/qgroup.c
> +++ b/fs/btrfs/qgroup.c
> @@ -3492,7 +3492,7 @@ static int qgroup_free_reserved_data(struct inode *inode,
>                  * EXTENT_QGROUP_RESERVED, we won't double free.
>                  * So not need to rush.
>                  */
> -               ret = clear_record_extent_bits(&BTRFS_I(inode)->io_failure_tree,
> +               ret = clear_record_extent_bits(&BTRFS_I(inode)->io_tree,
>                                 free_start, free_start + free_len - 1,
>                                 EXTENT_QGROUP_RESERVED, &changeset);
>                 if (ret < 0)
> --
> 2.23.0
>


-- 
Filipe David Manana,

“Whether you think you can, or you think you can't — you're right.”

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

* Re: [PATCH] btrfs: qgroup: Fix the wrong io_tree when freeing reserved data space
  2019-09-12  7:53 ` Filipe Manana
@ 2019-09-12  8:32   ` Qu Wenruo
  0 siblings, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2019-09-12  8:32 UTC (permalink / raw)
  To: fdmanana, Qu Wenruo; +Cc: linux-btrfs, Josef Bacik

[-- Attachment #1.1: Type: text/plain, Size: 1911 bytes --]



On 2019/9/12 下午3:53, Filipe Manana wrote:
> On Thu, Sep 12, 2019 at 2:31 AM Qu Wenruo <wqu@suse.com> wrote:
>>
>> Commit bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by
>> only freeing reserved ranges") is freeing wrong range in
>> BTRFS_I()->io_failure_tree, which should be BTRFS_I()->io_tree.
> 
> I think you meant wrong tree and not wrong range, since the code
> doesn't change the range, only the target tree.

Right, wrong tree.

> 
> Also, for the sake of completeness, and no matter how obvious you
> think it is, can you explicitly mention what's the consequence? I
> presume it's a qgroup reserved space leak or underflow.

Yes, qgroup reserved space leak for some error path.

I'll enhance the comment, and also craft a test case for it.

Thanks,
Qu

> 
> Thanks.
> 
>>
>> Just fix it.
>>
>> Reported-by: Josef Bacik <josef@toxicpanda.com>
>> Fixes: bc42bda22345 ("btrfs: qgroup: Fix qgroup reserved space underflow by only freeing reserved ranges")
>> Signed-off-by: Qu Wenruo <wqu@suse.com>
>> ---
>>  fs/btrfs/qgroup.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
>> index 2891b57b9e1e..64bdc3e3652d 100644
>> --- a/fs/btrfs/qgroup.c
>> +++ b/fs/btrfs/qgroup.c
>> @@ -3492,7 +3492,7 @@ static int qgroup_free_reserved_data(struct inode *inode,
>>                  * EXTENT_QGROUP_RESERVED, we won't double free.
>>                  * So not need to rush.
>>                  */
>> -               ret = clear_record_extent_bits(&BTRFS_I(inode)->io_failure_tree,
>> +               ret = clear_record_extent_bits(&BTRFS_I(inode)->io_tree,
>>                                 free_start, free_start + free_len - 1,
>>                                 EXTENT_QGROUP_RESERVED, &changeset);
>>                 if (ret < 0)
>> --
>> 2.23.0
>>
> 
> 


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  1:13 [PATCH] btrfs: qgroup: Fix the wrong io_tree when freeing reserved data space Qu Wenruo
2019-09-12  7:53 ` Filipe Manana
2019-09-12  8:32   ` Qu Wenruo

Linux-BTRFS Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-btrfs/0 linux-btrfs/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-btrfs linux-btrfs/ https://lore.kernel.org/linux-btrfs \
		linux-btrfs@vger.kernel.org linux-btrfs@archiver.kernel.org
	public-inbox-index linux-btrfs


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-btrfs


AGPL code for this site: git clone https://public-inbox.org/ public-inbox