Why we need ext4? Robin Dong <sanbai@taobao.com>
ext2 global layout Image from: http://learn.akae.cn/media/ch29s02.html
ext2 global layout Super Block (1 block) GDT (multi blocks) Block Bitmap (1 block) Inode Bitmap (1 block) Inode table (multi blocks)
Super-block and GDT are vital, therefore other groups will store their copies. If mkfs with “sparse_super”(default) not all groups have the copy of super block and GDT, only Group 0,1,3,5,7,3 2 ,5 2 ,7 2 ,3 3 ,5 3 ,7 3 ....have it. ext2 global layout
There is a structure called  “Reserved GDT”  which is putted after GDT and before Block-bitmap, it is also a large file. It is used for “resize” feature which could expand the size of whole filesystem.
ext2 file layout Image from: http://e2fsprogs.sourceforge.net/ext2intro.html
The ext2 directory layout is just like regular file, but the content of its data block is stored by “struct ext2_dir_entry” ext2 directory layout Image from: http://www.pluto.it/files/journal/pj9811/e2fs.html
The length of ext2_dir_entry is obviously different, so when users try to find a file in directory, ext2 have to  check filename one by one. (It can't use some algorithm like binary-search)  If there is a large number of files in a directory, searching operation will be inefficent. ext2 directory layout
ext2 directory remove Image from: http://blog.csdn.net/anghlq/archive/2011/05/17/6427052.aspx
ext2 directory pack e2fsck -D
Optimize directories in filesystem.  This option causes e2fsck to try to optimize all directories, either  by reindexing them if the filesystem supports directory indexing,  or by sorting and compressing directories for smaller directories, or for filesystems using traditional linear directories.
Regular Symlink: link path is stored in data block
Fast Symlink: link path is stored in inode (if link path is smaller than 56 bytes) ext2 symlink
ext2 symlink Image from: http://www.pluto.it/files/journal/pj9811/e2fs.html
ext2 hard link
ext2 xattr
ext2 xattr *  +--------------------+
*  | header  |
*  | entry 1  |  |
*  | entry 2  |  | growing downwards
*  | entry 3  |  v
*  | four null bytes  |
*  | . . .  |
*  | value 1  | ^
*  | value 3  |  | growing upwards
*  | value 2  |  |
*  +--------------------+
ext2: badblock e2fsck use program “badblocks” to detect bad blocks and mark these blocks as “used” in block bitmap.
If meta-data is in bad blocks,e2fsck will try to allocate new block for it.
enhane of ext3 Journal
ext3 could be looked like an ext2 filesystem with a journal file
dir_index
more efficent directory-searching

why we need ext4