diff --git a/fs/ext2/super.c b/fs/ext2/super.c index 80a3038e0e46..ad9fd08f66ba 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c @@ -780,8 +780,12 @@ static loff_t ext2_max_size(int bits) res += 1LL << (bits-2); res += 1LL << (2*(bits-2)); res += 1LL << (3*(bits-2)); + /* Compute how many metadata blocks are needed */ + meta_blocks = 1; + meta_blocks += 1 + ppb; + meta_blocks += 1 + ppb + ppb * ppb; /* Does block tree limit file size? */ - if (res < upper_limit) + if (res + meta_blocks <= upper_limit) goto check_lfs; res = upper_limit;