Created attachment 165293 [details] Allow inode size < sizeof(struct ext2fs_dinode) when EXT2F_ROCOMPAT_EXTRA_ISIZE is set When making the EXT4 filesystem, mkfs.ext4 uses different inode sizes depending on the filesystem file. For a large filesystem, "dumpe2fs" returns these relevant fields: Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file huge_file uninit_bg dir_nlink extra_isize Inode size: 256 Required extra isize: 28 Desired extra isize: 28 For a small filesystem, "dumpe2fs" returns this instead, and "Required extra isize" and "Desired extra isize" are missing: Filesystem features: has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super huge_file uninit_bg dir_nlink extra_isize Inode size: 128 Bisection searching with different filesystem sizes ("dd if=/dev/zero of=/tmp/filesystem bs=1M count=..." + "mkfs.ext4 /tmp/filesystem" + "dumpe2fs -h /tmp/filesystem") shows inode size 256 is used for filesystems >= 512 MiB, and smaller filesystems use inode size 128. Attemping to mount the small filesystems fails with this error (and unless you've patched ext2fs with the patch from bug 206056, also panics the kernel!!): ext2fs: no space for extra inode timestamps That message comes from compute_sb_data() in ext2_vfsops.c, which does /* Check for extra isize in big inodes. */ if (EXT2_HAS_RO_COMPAT_FEATURE(fs, EXT2F_ROCOMPAT_EXTRA_ISIZE) && EXT2_INODE_SIZE(fs) < sizeof(struct ext2fs_dinode)) { printf("ext2fs: no space for extra inode timestamps\n"); return (EINVAL); } which must be wrong, because even small filesystems have the extra_isize feature set, yet the inode size is 128 which is smaller than sizeof(struct ext2fs_dinode). Since EXT2F_ROCOMPAT_EXTRA_ISIZE isn't used anywhere else in the ext2fs module, I've made a patch that deletes that entire section, and it gets the small filesystems to mount and work.
This is wrong: Look at struct ext2fs_dinode (ext2_dinode.h). If the inode size is 128, the extra timestamps really don't fit. Any attempt to read beyond the 128 would be a buffer overflow. I recall the big block sizes were used for handling (non standard) extended attributes and the extra_isize only started getting used with ext4. I think this might be a bug in the GNU ext2fsprogs: technically you should disable the extra_isize with tune2fs before mounting such filesystems.
As explained, I think we are doing the right thing here.