From patchwork Thu Sep 14 09:45:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 139474 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp239511vqi; Thu, 14 Sep 2023 03:11:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHN33sodRp2MNL7qVNKJe/Hb8EvDx3bHjnBbBolCBwgxsug8pi/6XV5HmJJoHjpXHa03K4H X-Received: by 2002:a05:6a20:12d3:b0:14b:f86f:d9c3 with SMTP id v19-20020a056a2012d300b0014bf86fd9c3mr5490016pzg.61.1694686287492; Thu, 14 Sep 2023 03:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694686287; cv=none; d=google.com; s=arc-20160816; b=Opx0s96BMmb1dB+j806Ba4U8uwxZhScw/oyoISpAOvrs08ZxWXezaPfbpqtSXSLHQ8 pqBLzXsvhg5WhmoF4ZdJfmAgmxg0jPquoUbnCKjTTYZ0Kc6mxloZWJTYbLV4bPuD0BiZ htpNlHskoe4PGx0xrhTFHyb1mdOrAmWSF/EoulwQr/deEr6Jko0ydsaIkLNjL+l87WJl VbZ/DVmtU7vmdVHh+Yz53lTjQ8XaHu0uDc4pGl6JDn3olC8ftmewyq+YklvltrI6Hiiy rCYhkfJa6wVuGsEMGB10+CTx3/6op99WtefJPwBIYZ4FeSxvj8gT/xiMyJHuWT1y32aa pgLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=7+BWJl7jUbw18j6mRQMSjiiIIn0v1G/Viynwc1dBORE=; fh=uGgBrLNQNf7Vbe71oX97SpxO5j29DZHNnULPFgpE9hA=; b=QD8y+Ys5s6SW6U/2eekYFwNw83/Q7DJBlGndgjyFBpRNImeuatpWC18nkO6hxqUTVj vMhNp/bwZIWYblMcjrnLkt1pTAWyF6kzDd5nMJ7z8+yCsyhQcLroFCrCdO30ZIRkuHhN AtpHRwGlRehQnDnhGd8xhx7FX+XuosRU459NS5WmGJCRdMmpUsw2qYZvwADqwM22g8Y/ Bwn9Uh8XmnEZ8LVee8gXGoe/YtvOqJMszAAlKY/hzLUc5ddr1WPeghU19QOwpdHHRw06 K8Vm6czpfo4wEp8nvXx/NZMREHR4vAF4PMwLGaA1O0Nqz9yte64KnjYmk7TvKCUbFtUj B5mA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id eb25-20020a056a004c9900b0068aca5175f7si1277192pfb.255.2023.09.14.03.11.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:11:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 74004801D839; Thu, 14 Sep 2023 02:47:05 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237466AbjINJqr (ORCPT + 35 others); Thu, 14 Sep 2023 05:46:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237761AbjINJq0 (ORCPT ); Thu, 14 Sep 2023 05:46:26 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 907201FC6; Thu, 14 Sep 2023 02:46:20 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id B0F9F1864859; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id 21PzqHuNWfIK; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 6A54A186337A; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) X-Virus-Scanned: amavisd-new at astralinux.ru Received: from mail.astralinux.ru ([127.0.0.1]) by localhost (rbta-msk-vsrv-mail01.astralinux.ru [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id Bf6bOSsUcO7o; Thu, 14 Sep 2023 12:46:16 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.13.132]) by mail.astralinux.ru (Postfix) with ESMTPSA id 34B591864965; Thu, 14 Sep 2023 12:46:15 +0300 (MSK) From: Anastasia Belova To: Chris Mason Cc: Anastasia Belova , Josef Bacik , David Sterba , Dennis Zhou , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Greg Kroah-Hartman , 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 Message-Id: <20230914094555.25657-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:47:05 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777007368656105474 X-GMAIL-MSGID: 1777007368656105474 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 --- 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)