Go to the previous, next section.
In this section, the layout of a superblock is described. Here is the official structure of an ext2fs superblock [include/linux/ext2_fs.h]:
struct ext2_super_block { unsigned long s_inodes_count; unsigned long s_blocks_count; unsigned long s_r_blocks_count; unsigned long s_free_blocks_count; unsigned long s_free_inodes_count; unsigned long s_first_data_block; unsigned long s_log_block_size; long s_log_frag_size; unsigned long s_blocks_per_group; unsigned long s_frags_per_group; unsigned long s_inodes_per_group; unsigned long s_mtime; unsigned long s_wtime; unsigned short s_mnt_count; short s_max_mnt_count; unsigned short s_magic; unsigned short s_state; unsigned short s_errors; unsigned short s_pad; unsigned long s_lastcheck; unsigned long s_checkinterval; unsigned long s_reserved[238]; };
s_inodes_count
s_blocks_count
s_r_blocks_count
s_free_blocks_count
s_free_inodes_count
s_first_data_block
s_log_block_size
1024 << s_log_block_size
.
s_log_frag_size
1024 << s_log_frag_size
if s_log_frag_size
is positive
and 1024 >> -s_log_frag_size
if s_log_frag_size
is negative.
s_blocks_per_group
s_frags_per_group
s_inodes_per_group
s_mtime
s_wtime
s_mnt_count
s_max_mnt_count
s_magic
0xEF53
for a normal ext2fs and 0xEF51
for versions of
ext2fs prior to 0.2b.
s_state
s_errors
s_pad
s_lastcheck
s_checkinterval
s_reserved
Times are measured in seconds since 00:00:00 GMT, January 1, 1970.
Once the superblock is read in memory, the ext2fs kernel code calculates some other information and keeps them in another structure. This structure has the following layout:
struct ext2_sb_info { unsigned long s_frag_size; unsigned long s_frags_per_block; unsigned long s_inodes_per_block; unsigned long s_frags_per_group; unsigned long s_blocks_per_group; unsigned long s_inodes_per_group; unsigned long s_itb_per_group; unsigned long s_desc_per_block; unsigned long s_groups_count; struct buffer_head * s_sbh; struct ext2_super_block * s_es; struct buffer_head * s_group_desc[EXT2_MAX_GROUP_DESC]; unsigned short s_loaded_inode_bitmaps; unsigned short s_loaded_block_bitmaps; unsigned long s_inode_bitmap_number[EXT2_MAX_GROUP_LOADED]; struct buffer_head * s_inode_bitmap[EXT2_MAX_GROUP_LOADED]; unsigned long s_block_bitmap_number[EXT2_MAX_GROUP_LOADED]; struct buffer_head * s_block_bitmap[EXT2_MAX_GROUP_LOADED]; int s_rename_lock; struct wait_queue * s_rename_wait; unsigned long s_mount_opt; unsigned short s_mount_state; };
s_frag_size
s_frags_per_block
s_inodes_per_block
s_frags_per_group
s_blocks_per_group
s_inodes_per_group
s_itb_per_group
s_desc_per_block
s_groups_count
s_sbh
s_es
s_group_desc
s_loaded_inode_bitmaps
s_loaded_block_bitmaps
s_inode_bitmap_number
s_inode_bitmap
s_block_bitmap_number
s_block_bitmap
s_rename_lock
s_rename_wait
s_mount_opt
s_mount_state
Most of those values are computed from the superblock on disk.
Linux ext2fs manager caches access to the inodes and blocks bitmaps. This cache is a list of buffers ordered from the most recently used to the last recently used buffer. Managers should use the same kind of bitmap caching or other similar method of improving access time to disk.
Go to the previous, next section.