mirror of https://github.com/vitalif/e2fsprogs
Revert "mke2fs: prevent creation of unmountable ext4 with large flex_bg count"
This reverts commit d988201ef9
.
The problem with this commit is that causes common small file system
configurations to fail. For example:
mke2fs -O flex_bg -b 4096 -I 1024 -F /tmp/tt 79106
mke2fs 1.42.11 (09-Jul-2014)
/tmp/tt: Invalid argument passed to ext2 library while setting
up superblock
This check in ext2fs_initialize() was added to prevent the metadata
from being allocated beyond the end of the filesystem, but it is
also causing a wide range of failures for small filesystems.
We'll address this in a different way, by using a smarter algorithm
for deciding the layout of metadata blocks for the last flex block
group.
Reported-by: Andreas Dilger <andreas.dilger@intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
test-maint
parent
bf140bf298
commit
457e49981e
|
@ -91,10 +91,8 @@ errcode_t ext2fs_initialize(const char *name, int flags,
|
||||||
unsigned int rem;
|
unsigned int rem;
|
||||||
unsigned int overhead = 0;
|
unsigned int overhead = 0;
|
||||||
unsigned int ipg;
|
unsigned int ipg;
|
||||||
unsigned int flexbg_size;
|
|
||||||
dgrp_t i;
|
dgrp_t i;
|
||||||
blk64_t free_blocks;
|
blk64_t free_blocks;
|
||||||
blk64_t flexbg_overhead;
|
|
||||||
blk_t numblocks;
|
blk_t numblocks;
|
||||||
int rsv_gdt;
|
int rsv_gdt;
|
||||||
int csum_flag;
|
int csum_flag;
|
||||||
|
@ -420,28 +418,6 @@ ipg_retry:
|
||||||
goto retry;
|
goto retry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Calculate the flex_bg related metadata blocks count.
|
|
||||||
* It includes the boot block, the super block,
|
|
||||||
* the block group descriptors, the reserved gdt blocks,
|
|
||||||
* the block bitmaps, the inode bitmaps and the inode tables.
|
|
||||||
* This is a simple check, so that the backup superblock and
|
|
||||||
* other feature related blocks are not considered.
|
|
||||||
*/
|
|
||||||
flexbg_size = 1 << fs->super->s_log_groups_per_flex;
|
|
||||||
flexbg_overhead = super->s_first_data_block + 1 +
|
|
||||||
fs->desc_blocks + super->s_reserved_gdt_blocks +
|
|
||||||
(__u64)flexbg_size * (2 + fs->inode_blocks_per_group);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Disallow creating ext4 which breaks flex_bg metadata layout
|
|
||||||
* obviously.
|
|
||||||
*/
|
|
||||||
if (flexbg_overhead > ext2fs_blocks_count(fs->super)) {
|
|
||||||
retval = EXT2_ET_INVALID_ARGUMENT;
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* At this point we know how big the filesystem will be. So
|
* At this point we know how big the filesystem will be. So
|
||||||
* we can do any and all allocations that depend on the block
|
* we can do any and all allocations that depend on the block
|
||||||
|
|
Loading…
Reference in New Issue