Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1655432rwb; Mon, 7 Nov 2022 04:23:26 -0800 (PST) X-Google-Smtp-Source: AMsMyM4nC3DHfd0t5DCboXpx7I8ldbbblz56za55fDoyMFrO7irVG8WKM5Wf9ev9Y5RbxWy3Kndm X-Received: by 2002:a05:6402:35cf:b0:462:67bf:94a9 with SMTP id z15-20020a05640235cf00b0046267bf94a9mr49300213edc.1.1667823806029; Mon, 07 Nov 2022 04:23:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667823806; cv=none; d=google.com; s=arc-20160816; b=lXaf/C/FMctP4c5k5/0T60hLwi87sNHW1slYchup9RrbdWAXoaaxPsGazSxPsC5uvw AXZC0fpZgBV5Bf43LJk4PR1c0UaQjfjzkotnbFAGisZ9JLh1JgTukpYxTocwO+saH085 UtWI0AoFWgjCaPdJNeYhhH/v0DLVhS+lZ46W7esaQDb4tvC07C55F/RSjmxIj1FckD10 QZrguA3w+X5mEZpUC3RSth8/S+yILjGUeShe2QU/XEF1fUvupmOsIzHRbtpUUZUFDkeV J0B0Q7PJBJnZvyilccbKkAEbMsjgfcjR/84HFgdM5czgDPweksUSZJiLlodM662SnYGV YOWA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=PeguO5OJQkOMV7A3vjAm+yi2UDth+yAgHrBJt9W7x20=; b=Ldfot/dbq8CKU1cpA2ABz1mTpH3/bKVap0yhQr+ynbKMNYxZC9wmbxQj29fOOQqv9Q IFyvQvt49VufNCOgCZsDhIZIIU6azhcv0cvQSwjc5sy0mtEBNxAaeq5blKqukk0YtQ41 eGJqH1K+qwqhjoWLm39oNLm16/3o40K+NnIGpNcs+dvOvQTKXlZJ6C+M2m8nWu0Tldky 97XzY6gGLfI2e9LRABq55Mgi/myGhUh+AfZShNmznALCPCcOp29kIAbCS/dQuZCl0U8S 5/dAkY+fHB1dRbdTmzxtL4Pz3GLL2ZoGL1J2iLkzz14Uh4mMkO7w7V9fPkV3ZDr16m2P jEeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AIi2DCcH; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hr35-20020a1709073fa300b007ae29da29b3si9140110ejc.731.2022.11.07.04.23.02; Mon, 07 Nov 2022 04:23:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=AIi2DCcH; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232127AbiKGMWg (ORCPT + 99 others); Mon, 7 Nov 2022 07:22:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232070AbiKGMWf (ORCPT ); Mon, 7 Nov 2022 07:22:35 -0500 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF729D62 for ; Mon, 7 Nov 2022 04:22:34 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id c2so10879430plz.11 for ; Mon, 07 Nov 2022 04:22:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PeguO5OJQkOMV7A3vjAm+yi2UDth+yAgHrBJt9W7x20=; b=AIi2DCcHrqUqsdTtRq6K37rKo+F7IPFgqVwj1RGbeBIS2Ljqc4aKaNBCOwY7cLB4kY Sv0rdX1ZROE6jVBY9iS7+a626GaljeZFvJEvsKUrZvS8J+rF+/zTHogCLQaESGDOCYNG vbkls6mAObm3pTFT8nonK2/p02aygel4xgWVwuHNTpFFJc+XNZyi501fmmSsOtXMqHDI Ha6lmR1zVBknimeCAdOzZsKiJ77y/Etz2R+VR07t46/OGwvRb5racnqXV88Z7TgrKtpV EkGQWiANHuMK5HjNOrz16lMz5Mhv1zJzoVdXhDQuw240nWG00GKqpTxwDaktXMOCGD2x 6BYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PeguO5OJQkOMV7A3vjAm+yi2UDth+yAgHrBJt9W7x20=; b=jhPRCdxyPp08YX5uf36UirpPckR4j0i6cGPq+VSm2goRA7E2MB4PweGeK5uzTxAutA P7WDc+ztG39ZFBqx5EPUANPBVXSjxTrq8mxXZlnEVZWZ/p3zrwnQNu7dh37nk/FN76JY 6yXNNOmJs0ZD64GxSnIovz9UNrCmlCszgI315HooKNVgY3y6UxBn/WUKyPTYJGsmHQTn J5URdk8P82hsctb8bABwD1kVjkJcGKsIki6D69Ew48xcQNjCXsISn0ka8ypcNqIPvWSB a2U7KFOr7irn11V0ndYxwlYQfKb/ivrd+tp6eUyTCMoYKsVj+yZgr5Zj9aWFaHI/ZqUF BaZA== X-Gm-Message-State: ACrzQf3AWG0KEJae7DdUnadyzicxnyH7NwKI3UqAgPRXQCwGAg8jai6r UJ0ZyccBOJ6oaLfTWJs00Kg= X-Received: by 2002:a17:902:e74a:b0:186:a094:1d3 with SMTP id p10-20020a170902e74a00b00186a09401d3mr48851963plf.153.1667823754480; Mon, 07 Nov 2022 04:22:34 -0800 (PST) Received: from localhost ([2406:7400:63:f20b:312d:45b2:85c1:c486]) by smtp.gmail.com with ESMTPSA id y23-20020a17090264d700b0017f92246e4dsm4824708pli.181.2022.11.07.04.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Nov 2022 04:22:33 -0800 (PST) From: "Ritesh Harjani (IBM)" To: Theodore Ts'o Cc: linux-ext4@vger.kernel.org, Harshad Shirwadkar , Wang Shilong , Andreas Dilger , Li Xi , "Ritesh Harjani (IBM)" Subject: [RFCv1 02/72] gen_bitmaps: Fix ext2fs_compare_generic_bmap/bitmap logic Date: Mon, 7 Nov 2022 17:50:50 +0530 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,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-ext4@vger.kernel.org Currently this function was not correctly comparing against the right length of the bitmap. Also when we compare bitarray v/s rbtree bitmap the value returned by ext2fs_test_generic_bmap() could be different in these two implementations. Hence only check against boolean value. Signed-off-by: Ritesh Harjani (IBM) --- lib/ext2fs/gen_bitmap.c | 9 ++++++--- lib/ext2fs/gen_bitmap64.c | 10 +++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/ext2fs/gen_bitmap.c b/lib/ext2fs/gen_bitmap.c index 1536d4b3..f7764fca 100644 --- a/lib/ext2fs/gen_bitmap.c +++ b/lib/ext2fs/gen_bitmap.c @@ -385,10 +385,13 @@ errcode_t ext2fs_compare_generic_bitmap(errcode_t magic, errcode_t neq, (size_t) (bm1->end - bm1->start)/8))) return neq; - for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) - if (ext2fs_fast_test_block_bitmap(gen_bm1, i) != - ext2fs_fast_test_block_bitmap(gen_bm2, i)) + for (i = bm1->start; i <= bm1->end; i++) { + int ret1, ret2; + ret1 = !!ext2fs_fast_test_block_bitmap(gen_bm1, i); + ret2 = !!ext2fs_fast_test_block_bitmap(gen_bm2, i); + if (ret1 != ret2) return neq; + } return 0; } diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index c860c10e..f7710afd 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -629,10 +629,14 @@ errcode_t ext2fs_compare_generic_bmap(errcode_t neq, (bm1->end != bm2->end)) return neq; - for (i = bm1->end - ((bm1->end - bm1->start) % 8); i <= bm1->end; i++) - if (ext2fs_test_generic_bmap(gen_bm1, i) != - ext2fs_test_generic_bmap(gen_bm2, i)) + for (i = bm1->start; i < bm1->end; i++) { + int ret1, ret2; + ret1 = !!ext2fs_test_generic_bmap(gen_bm1, i); + ret2 = !!ext2fs_test_generic_bmap(gen_bm2, i); + if (ret1 != ret2) { return neq; + } + } return 0; } -- 2.37.3