e2fsprogs: modify dumpe2fs to report free block ranges for bigalloc
(cherry picked from commit 491eee61810b65846fa07ada00d5428e669782f4)
This commit is contained in:
parent
9779ca6902
commit
1d8a9f90df
@ -0,0 +1,66 @@
|
||||
From b31d5b582b4189a0ed27bced22276dd3f68c50a7 Mon Sep 17 00:00:00 2001
|
||||
From: Eric Whitney <enwlinux@gmail.com>
|
||||
Date: Fri, 21 Jul 2023 14:55:06 -0400
|
||||
Subject: [PATCH] e2fsprogs: modify dumpe2fs to report free block ranges for
|
||||
bigalloc
|
||||
|
||||
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 <enwlinux@gmail.com>
|
||||
Link: https://lore.kernel.org/r/20230721185506.1020225-1-enwlinux@gmail.com
|
||||
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
|
||||
---
|
||||
misc/dumpe2fs.c | 12 ++++++------
|
||||
1 file changed, 6 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
|
||||
index 7c080ed9f..d2d57fb0a 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;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
Name: e2fsprogs
|
||||
Version: 1.46.4
|
||||
Release: 25
|
||||
Release: 26
|
||||
Summary: Second extended file system management tools
|
||||
License: GPLv2+ and LGPLv2 and MIT
|
||||
URL: http://e2fsprogs.sourceforge.net/
|
||||
@ -51,6 +51,7 @@ Patch41: 0041-debugfs-Fix-infinite-loop-when-dump-log.patch
|
||||
Patch42: 0042-debugfs-Use-the-hash_version-from-superblock-if-a-fi.patch
|
||||
Patch43: 0043-tune2fs-fuse2fs-debugfs-save-error-information-durin.patch
|
||||
Patch44: 0044-resize2fs-use-Direct-I-O-when-reading-the-superblock.patch
|
||||
Patch45: 0045-modify-dumpe2fs-to-report-free-block-ranges-for-bigalloc.patch
|
||||
|
||||
BuildRequires: gcc pkgconfig texinfo
|
||||
BuildRequires: fuse-devel libblkid-devel libuuid-devel
|
||||
@ -191,6 +192,9 @@ exit 0
|
||||
%{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Tue May 07 2024 zhangxingrong <zhangxingrong@uniontech.com> - 1.46.4-26
|
||||
- backport upstream patch
|
||||
|
||||
* Sun Apr 7 2024 haowenchao <haowenchao2@huawei.com> - 1.46.4-25
|
||||
- Backports from mainline
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user