ext4: do not trim the group with corrupted block bitmap

[ Upstream commit 172202152a125955367393956acf5f4ffd092e0d ]

Otherwise operating on an incorrupted block bitmap can lead to all sorts
of unknown problems.

Signed-off-by: Baokun Li <libaokun1@huawei.com>
Reviewed-by: Jan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20240104142040.2835097-3-libaokun1@huawei.com
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
(cherry picked from commit cac7c9fcd15e92184c8e621b1f33d97d99505366)
[Vegard: fix conflict in context due to missing commit
 cac7c9fcd15e92184c8e621b1f33d97d99505366 ("ext4: do not trim the group
 with corrupted block bitmap").]
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
This commit is contained in:
Baokun Li 2024-01-04 22:20:34 +08:00 committed by Vegard Nossum
parent 4297287b11
commit 0c2fd9f775

View File

@ -5222,6 +5222,9 @@ static int ext4_try_to_trim_range(struct super_block *sb,
void *bitmap;
int ret = 0;
if (unlikely(EXT4_MB_GRP_BBITMAP_CORRUPT(e4b->bd_info)))
return 0;
bitmap = e4b->bd_bitmap;
start = (e4b->bd_info->bb_first_free > start) ?
e4b->bd_info->bb_first_free : start;