linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anastasia Belova <abelova@astralinux.ru>
To: Chris Mason <clm@fb.com>
Cc: Anastasia Belova <abelova@astralinux.ru>,
	Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>, Dennis Zhou <dennis@kernel.org>,
	linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org
Subject: [PATCH 5.10] btrfs: fix region size in count_bitmap_extents
Date: Thu, 14 Sep 2023 12:45:55 +0300	[thread overview]
Message-ID: <20230914094555.25657-1-abelova@astralinux.ru> (raw)

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


             reply	other threads:[~2023-09-14  9:46 UTC|newest]

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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230914094555.25657-1-abelova@astralinux.ru \
    --to=abelova@astralinux.ru \
    --cc=clm@fb.com \
    --cc=dennis@kernel.org \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).