summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2022-04-14 21:57:49 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-04-27 14:41:16 +0200
commitb95e34bb7cca43afbe60d9727dd4ddc236da7a31 (patch)
tree222fe4b366c73ef9fc14d0cd20433d806f257551
parentdf602c1d8a7ea09dbf90a04acb3756a8ff77d9b3 (diff)
ext4: force overhead calculation if the s_overhead_cluster makes no sense
commit 85d825dbf4899a69407338bae462a59aa9a37326 upstream. 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 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--fs/ext4/super.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 53fd2dbb6e9e..465ca3cfc87e 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -5268,9 +5268,18 @@ no_journal:
* Get the # of file system overhead blocks from the
* superblock if present.
*/
- if (es->s_overhead_clusters)
- sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
- else {
+ sbi->s_overhead = le32_to_cpu(es->s_overhead_clusters);
+ /* ignore the precalculated value if it is ridiculous */
+ 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);
if (err)
goto failed_mount_wq;