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 <tytso@mit.edu>
Cc: stable@kernel.org
This commit is contained in:
Theodore Ts'o 2022-04-14 21:57:49 -04:00
Родитель 10b01ee92d
Коммит 85d825dbf4
1 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -5289,9 +5289,18 @@ no_journal:
* Get the # of file system overhead blocks from the * Get the # of file system overhead blocks from the
* superblock if present. * superblock if present.
*/ */
if (es->s_overhead_clusters) sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters); /* ignore the precalculated value if it is ridiculous */
else { if (sbi->s_overhead > ext4_blocks_count(es))
sbi->s_overhead = 0;
/*
* If the bigalloc feature is not enabled recalculating the
* overhead doesn't take long, so we might as well just redo
* it to make sure we are using the correct value.
*/
if (!ext4_has_feature_bigalloc(sb))
sbi->s_overhead = 0;
if (sbi->s_overhead == 0) {
err = ext4_calculate_overhead(sb); err = ext4_calculate_overhead(sb);
if (err) if (err)
goto failed_mount_wq; goto failed_mount_wq;