Received: by 2002:a05:6358:701b:b0:131:369:b2a3 with SMTP id 27csp290922rwo; Fri, 21 Jul 2023 11:56:36 -0700 (PDT) X-Google-Smtp-Source: APBJJlE+1G8c//x60OuwVNzledYjrp77ZdsLRd1uYNru1ND/D0VFtLWqOYAtbb/zzqYm5YWb+I2P X-Received: by 2002:a17:907:7757:b0:99b:627b:e962 with SMTP id kx23-20020a170907775700b0099b627be962mr2375794ejc.47.1689965796104; Fri, 21 Jul 2023 11:56:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689965796; cv=none; d=google.com; s=arc-20160816; b=KV6Qt1g3eyai3dhcs1ity38tw4LowttjtWBNfDk7U2Y6H7RpGwm9IdEfsAqkRGfEgj 9kUj2W1c5/WnpGaEAwOu/DJr1OcEb9AJqBzjF6iaTOm2GHc0Us3YwPpANujyeCfyUS/+ iCn/QRSfvdxLsiE9EMfUnP7FwnK+aLCGIp7TBTpM7rEoJ18C3ikk+XsmXqiaxb7EU3Mr A+uW2cYzOauoI+pmz+SaZYDxjawY06OEeFqTvIpThKsYN5bc1rvuoU22Cm69pjtWllv2 Lk5jJ7aDMW6yUz1l6Z9K3Iy7XCOATcEiutWDFOzmksqmY/78B8D45fwvitWj6nCWGxRH h4hg== 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:dkim-signature; bh=3Y6KtmmjFqHmJrfTGwtLo5U3CvX7kiUQqxJ8NaF4Z1Q=; fh=Ik82Y0MsMXeRpCkGbDF5QMZfna+7rR+sRbXSi36IWZE=; b=mYeCaQHOE9QW2x7hhYKZXQ72437sD7o/0IAB0Wjhj6zhw4B7gkA+OuRmsPaKoOEsqG A9nl6gQitPvU4keoq0AhXnNIKtwDttHk7JAiJWGFpr+N2b3QLeKyEE/25RGh7YGAYGhi s6C1d/jxwB/BjWpICnS1Y5OIBfUNrHxl6BmrWGZKTja2QzkrtsWe8fYBcfzED1YgRKxm dES+Ffy2vS5OFfxCTfMmXomF8HFJgu8FfOFqhy8oZYEM8GCLtXJqLk4M8zz74P9NgHRN tnkYE5aSzMPg28aK9Yius4X794O+YlQ9JI2nkgKO/beIwUhMnnGme8LAsVGCdiGz911N 294g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=bbx2PP0E; 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 k7-20020a1709061c0700b009938abf8917si2621429ejg.995.2023.07.21.11.55.45; Fri, 21 Jul 2023 11:56:36 -0700 (PDT) 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=20221208 header.b=bbx2PP0E; 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 S231320AbjGUSzh (ORCPT + 99 others); Fri, 21 Jul 2023 14:55:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230349AbjGUSzf (ORCPT ); Fri, 21 Jul 2023 14:55:35 -0400 Received: from mail-qk1-x730.google.com (mail-qk1-x730.google.com [IPv6:2607:f8b0:4864:20::730]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D14323A9C for ; Fri, 21 Jul 2023 11:55:24 -0700 (PDT) Received: by mail-qk1-x730.google.com with SMTP id af79cd13be357-7658430eb5dso226312685a.2 for ; Fri, 21 Jul 2023 11:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689965723; x=1690570523; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3Y6KtmmjFqHmJrfTGwtLo5U3CvX7kiUQqxJ8NaF4Z1Q=; b=bbx2PP0EUBQ9VY6gX4TpbfewIYeawiHLiq4jPINrs/32ZcYUpmZaidLYIigJZFAs2g +/n0VRZd7DPbVwJDRkozs6lNvOdeEVwB3QkhYKKX6Lrpc2EvbB8I0DxqF2aUspXLJ7+1 s8lCpYB36T79Shxo8VGJyBzL2mUNZHSSVxAsPoKW/QCr5HJ51eQp5AfCQ76SNEV/edsL G0Ir30Lmeg5jwUWGIvHi3EifVXCZodKO6ncCnuWeGCA2x58/bpaXjMgd4sT10gjjwFeB tVUZQLuYj2LTH49Yx3Rj1Xclj8m7uvo2zTwnUYk2isieHrloPx2Z6T88UItsUiKPH15M GsbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689965723; x=1690570523; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3Y6KtmmjFqHmJrfTGwtLo5U3CvX7kiUQqxJ8NaF4Z1Q=; b=UudS6loLbpDdw9jEs7xFawds181XAMLoZ+7fjG6vNvmqbG2dUJ4t9CNhOWrDHR+2Bh ixyOpswpuY3C8D8doy7E5WsO/la2LxUaDtEigNyHdTqSG7UV42MBSrUpG4PF2VVj3zJ0 byAPr/BXO+MsNdUFlDTkm8vsU0Zl2MuRWx/2e3WrbrUjEzuuTBgNPk4B6aM9yjf197Cs Hcc0fIjA42rr+SutnDeCaFq7W360fS+/zJlytpLY1LrhoU2w8RBU4kyUdbAeqIhTGlEP ZPbdSy6ePMWCsCnjHPuiv4L6E9XsApSbWRJ7+ENT3/GxwMzUl1Bm2cQXCp9ORyev2nJE oW3g== X-Gm-Message-State: ABy/qLZzKGLDd1eoZG+6bw9Y90oj7a+yQytlBR3Jj32iYT+WnWFahdmw g/kHocnGQbqlT1v8wJl2MweCKRauhOA= X-Received: by 2002:a05:620a:4546:b0:767:28ca:3f4 with SMTP id u6-20020a05620a454600b0076728ca03f4mr945855qkp.55.1689965723268; Fri, 21 Jul 2023 11:55:23 -0700 (PDT) Received: from localhost.localdomain (h64-35-202-119.cntcnh.broadband.dynamic.tds.net. [64.35.202.119]) by smtp.gmail.com with ESMTPSA id p28-20020a05620a133c00b00768283dcb63sm1285745qkj.123.2023.07.21.11.55.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Jul 2023 11:55:23 -0700 (PDT) From: Eric Whitney To: linux-ext4@vger.kernel.org Cc: tytso@mit.edu, Eric Whitney Subject: [PATCH] e2fsprogs: modify dumpe2fs to report free block ranges for bigalloc Date: Fri, 21 Jul 2023 14:55:06 -0400 Message-Id: <20230721185506.1020225-1-enwlinux@gmail.com> X-Mailer: git-send-email 2.30.2 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_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 dumpe2fs has never been modified to correctly report block ranges corresponding to free clusters in block allocation bitmaps from bigalloc file systems. Rather than reporting block ranges covering all the blocks in free clusters found in a block bitmap, it either reports just the first block number in a cluster for a single free cluster, or a range beginning with the first block number in the first cluster in a series of free clusters, and ending with the first block number in the last cluster in that series. This behavior causes xfstest shared/298 to fail when run on a bigalloc file system with a 1k block size. The test uses dumpe2fs to collect a list of the blocks freed when files are deleted from a file system. When the test deletes a file containing blocks located after the first block in the last cluster in a series of clusters, dumpe2fs does not report those blocks as free per the test's expectations. Modify dumpe2fs to report full block ranges for free clusters. At the same time, fix a small bug causing unnecessary !in_use() retests while iterating over a block bitmap. Signed-off-by: Eric Whitney --- misc/dumpe2fs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c index 7c080ed9..d2d57fb0 100644 --- a/misc/dumpe2fs.c +++ b/misc/dumpe2fs.c @@ -84,8 +84,7 @@ static void print_free(unsigned long group, char * bitmap, unsigned long num, unsigned long offset, int ratio) { int p = 0; - unsigned long i; - unsigned long j; + unsigned long i, j; offset /= ratio; offset += group * num; @@ -95,13 +94,14 @@ static void print_free(unsigned long group, char * bitmap, if (p) printf (", "); print_number((i + offset) * ratio); - for (j = i; j < num && !in_use (bitmap, j); j++) + for (j = i + 1; j < num && !in_use(bitmap, j); j++) ; - if (--j != i) { + if (j != i + 1 || ratio > 1) { fputc('-', stdout); - print_number((j + offset) * ratio); - i = j; + print_number(((j - 1 + offset) * ratio) + + ratio - 1); } + i = j; p = 1; } } -- 2.30.2