Skip to content

Commit 85d825d

Browse files
committed
ext4: force overhead calculation if the s_overhead_cluster makes no sense
If the file system does not use bigalloc, calculating the overhead is cheap, so force the recalculation of the overhead so we don't have to trust the precalculated overhead in the superblock. Signed-off-by: Theodore Ts'o <[email protected]> Cc: [email protected]
1 parent 10b01ee commit 85d825d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

fs/ext4/super.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5289,9 +5289,18 @@ static int __ext4_fill_super(struct fs_context *fc, struct super_block *sb)
52895289
* Get the # of file system overhead blocks from the
52905290
* superblock if present.
52915291
*/
5292-
if (es->s_overhead_clusters)
5293-
sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
5294-
else {
5292+
sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
5293+
/* ignore the precalculated value if it is ridiculous */
5294+
if (sbi->s_overhead > ext4_blocks_count(es))
5295+
sbi->s_overhead = 0;
5296+
/*
5297+
* If the bigalloc feature is not enabled recalculating the
5298+
* overhead doesn't take long, so we might as well just redo
5299+
* it to make sure we are using the correct value.
5300+
*/
5301+
if (!ext4_has_feature_bigalloc(sb))
5302+
sbi->s_overhead = 0;
5303+
if (sbi->s_overhead == 0) {
52955304
err = ext4_calculate_overhead(sb);
52965305
if (err)
52975306
goto failed_mount_wq;

0 commit comments

Comments
 (0)