From patchwork Mon Aug 21 09:29:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anastasia Belova X-Patchwork-Id: 136366 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b82d:0:b0:3f2:4152:657d with SMTP id z13csp2908930vqi; Mon, 21 Aug 2023 03:34:04 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFQ5to0O2fE9VOyXmqvhEx86neLHSevrqA/+39ULnQHi5lQQPh0gpqxrn23GwRAZIGtntix X-Received: by 2002:a17:906:cc5e:b0:993:f90b:e549 with SMTP id mm30-20020a170906cc5e00b00993f90be549mr4480548ejb.37.1692614044083; Mon, 21 Aug 2023 03:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1692614044; cv=none; d=google.com; s=arc-20160816; b=HOt4u589DkRGVPzkAZKJcKnASz1uf8ZNKQVfWGDn95Vvn1W6thS4NYQ6kChNwCh0YB weIJsCxjICIN6KOmIi8q9lKZ3p8vWrQXfXkoojoplHA4+sRurZQBzNSabkmOaYryrof8 VuB6Yl6f+kd3XpxY1tpYHFdL8QAuRS1C0uvkxtbN56aB02HpZl5g503vNokBpaNrEH4A SF7lVtGsMqrL40TsNMhnwaI6ZH5MMzvzbFaLdp8GwhzdaEUeG2o4Wrb8wMTzhnjh/O39 kh2d8pb2LDQhwSfeYeebuPCY/10HYk6P9o+M/Lr+XvW2Gmb+Fha9Li+TXyM6MtFOXeiG DZ1g== 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=fiFJ4kRJPOXXmNllX+Cle5R7OpDf6RMM/JCG1sc0O4k=; b=W6Klo5RXCPaGkYoOmqnpKR3ltU/XO34wJN8br51hLe0Fbvz6he1jRfyH7xW+to+JJ6 nF1xfXdvGt19+2J+KhXcFc4f36CdMJd0Z/oHNtgrbMS++8je56Fnpen1KsuXdkOGVZNv wiLDuw2RTJ3W7J1u2MkcLnooz0KLqa1CEAtndGyZKedqHJjes1IUi+G5vOH8mSZHRZ6U Fja4lyBzA45nCtU/HSLZ++mgJ4sCVxUIlaxigMaVoAz/0MXk8ptfC46aEI/pMrRi5c8n XsYjS+p4NacoCZTSU9QfBfiFhHNWxaSjb41QQolf3LKiscuxJyJvOXCQ7NBBeVFG/zPU 10BA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gf17-20020a170906e21100b00993a68a3af9si5651161ejb.535.2023.08.21.03.33.31; Mon, 21 Aug 2023 03:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233656AbjHUJ3e (ORCPT + 99 others); Mon, 21 Aug 2023 05:29:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234326AbjHUJ3c (ORCPT ); Mon, 21 Aug 2023 05:29:32 -0400 Received: from mail.astralinux.ru (mail.astralinux.ru [217.74.38.119]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E4891; Mon, 21 Aug 2023 02:29:29 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id BDC0018666CB; Mon, 21 Aug 2023 12:29:25 +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 Tm0BQ5SqM1UM; Mon, 21 Aug 2023 12:29:25 +0300 (MSK) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.astralinux.ru (Postfix) with ESMTP id 0C6BE1865CA8; Mon, 21 Aug 2023 12:29:25 +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 zpMtGT6orwvn; Mon, 21 Aug 2023 12:29:24 +0300 (MSK) Received: from rbta-msk-lt-106062.astralinux.ru (unknown [10.177.13.132]) by mail.astralinux.ru (Postfix) with ESMTPSA id DED1B1865E97; Mon, 21 Aug 2023 12:29:22 +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 Subject: [PATCH 5.10] btrfs: fix region size in count_bitmap_extents Date: Mon, 21 Aug 2023 12:29:02 +0300 Message-Id: <20230821092902.31808-1-abelova@astralinux.ru> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1774834463724371134 X-GMAIL-MSGID: 1774834463724371134 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)