linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 5.10] btrfs: fix region size in count_bitmap_extents
@ 2023-08-21  9:29 Anastasia Belova
  0 siblings, 0 replies; 3+ messages in thread
From: Anastasia Belova @ 2023-08-21  9:29 UTC (permalink / raw)
  To: Chris Mason
  Cc: Anastasia Belova, Josef Bacik, David Sterba, Dennis Zhou,
	linux-btrfs, linux-kernel, lvc-project

count_bitmap_extents was deleted in version 5.11, but
there is possible mistake in versions 5.6-5.10.

Region size should be calculated by subtracting
the end from the beginning.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: dfb79ddb130e ("btrfs: track discardable extents for async discard")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 fs/btrfs/free-space-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 4989c60b1df9..a34e266a0969 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1930,7 +1930,7 @@ static int count_bitmap_extents(struct btrfs_free_space_ctl *ctl,
 
 	bitmap_for_each_set_region(bitmap_info->bitmap, rs, re, 0,
 				   BITS_PER_BITMAP) {
-		bytes -= (rs - re) * ctl->unit;
+		bytes -= (re - rs) * ctl->unit;
 		count++;
 
 		if (!bytes)
-- 
2.30.2


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

* [PATCH 5.10] btrfs: fix region size in count_bitmap_extents
@ 2023-09-14  9:45 Anastasia Belova
       [not found] ` <798207fe-35ea-46b4-9e52-73efcbb061de@astralinux.ru>
  0 siblings, 1 reply; 3+ messages in thread
From: Anastasia Belova @ 2023-09-14  9:45 UTC (permalink / raw)
  To: Chris Mason
  Cc: Anastasia Belova, Josef Bacik, David Sterba, Dennis Zhou,
	linux-btrfs, linux-kernel, lvc-project, Greg Kroah-Hartman,
	stable

count_bitmap_extents was deleted in version 5.11, but
there is possible mistake in versions 5.6-5.10.

Region size should be calculated by subtracting
the end from the beginning.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: dfb79ddb130e ("btrfs: track discardable extents for async discard")
Signed-off-by: Anastasia Belova <abelova@astralinux.ru>
---
 fs/btrfs/free-space-cache.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
index 4989c60b1df9..a34e266a0969 100644
--- a/fs/btrfs/free-space-cache.c
+++ b/fs/btrfs/free-space-cache.c
@@ -1930,7 +1930,7 @@ static int count_bitmap_extents(struct btrfs_free_space_ctl *ctl,
 
 	bitmap_for_each_set_region(bitmap_info->bitmap, rs, re, 0,
 				   BITS_PER_BITMAP) {
-		bytes -= (rs - re) * ctl->unit;
+		bytes -= (re - rs) * ctl->unit;
 		count++;
 
 		if (!bytes)
-- 
2.30.2


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

* Re: [PATCH 5.10] btrfs: fix region size in count_bitmap_extents
       [not found] ` <798207fe-35ea-46b4-9e52-73efcbb061de@astralinux.ru>
@ 2023-10-03 12:48   ` Анастасия Любимова
  0 siblings, 0 replies; 3+ messages in thread
From: Анастасия Любимова @ 2023-10-03 12:48 UTC (permalink / raw)
  To: Chris Mason
  Cc: Josef Bacik, David Sterba, Dennis Zhou, linux-btrfs, linux-kernel,
	lvc-project, Greg Kroah-Hartman, stable


03/10/23 15:39, Anastasia Belova пишет:
>
> 14/09/23 12:45, Anastasia Belova пишет:
>> count_bitmap_extents was deleted in version 5.11, but
>> there is possible mistake in versions 5.6-5.10.
>>
>> Region size should be calculated by subtracting
>> the end from the beginning.
> Do I understand correctly that bytes should decrease and
> (rs - re) is always negative and should be replaced by (re - rs)?
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Fixes: dfb79ddb130e ("btrfs: track discardable extents for async discard")
>> Signed-off-by: Anastasia Belova<abelova@astralinux.ru>
>> ---
>>   fs/btrfs/free-space-cache.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c
>> index 4989c60b1df9..a34e266a0969 100644
>> --- a/fs/btrfs/free-space-cache.c
>> +++ b/fs/btrfs/free-space-cache.c
>> @@ -1930,7 +1930,7 @@ static int count_bitmap_extents(struct btrfs_free_space_ctl *ctl,
>>   
>>   	bitmap_for_each_set_region(bitmap_info->bitmap, rs, re, 0,
>>   				   BITS_PER_BITMAP) {
>> -		bytes -= (rs - re) * ctl->unit;
>> +		bytes -= (re - rs) * ctl->unit;
>>   		count++;
>>   
>>   		if (!bytes)
> Anastasia
Sorry for sending html accidentally

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

end of thread, other threads:[~2023-10-03 12:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-14  9:45 [PATCH 5.10] btrfs: fix region size in count_bitmap_extents Anastasia Belova
     [not found] ` <798207fe-35ea-46b4-9e52-73efcbb061de@astralinux.ru>
2023-10-03 12:48   ` Анастасия Любимова
  -- strict thread matches above, loose matches on Subject: below --
2023-08-21  9:29 Anastasia Belova

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).