ext2 | ext3 | ext4 | |
---|---|---|---|
Max File Size | 16GB~2TB | 16GB~2TB | 16GB~16TB |
Max File System size | 2TB~32TB | 4TB~32TB | 1EB |
Type | Disk data | Memory data | Caching mode |
---|---|---|---|
Superblock | ext4_super_block | ext4_sb_info | Always cached |
Group descriptor | ext4_group_desc | ext4_group_desc | Always cached |
Block bitmap | Bit array in block | Bit array in buffer | Dynamic |
inode bitmap | Bit array in block | Bit array in buffer | Dynamic |
inode | ext4_inode | ext4_inode_info | Dynamic |
// total: 1024 bytes
struct ext4_super_block {
// overall
__le32 s_inodes_count; /* Inodes count */
__le32 s_blocks_count_lo; /* Blocks count */
__le32 s_r_blocks_count_lo; /* Reserved blocks count */
__le32 s_free_blocks_count_lo; /* Free blocks count */
__le32 s_free_inodes_count; /* Free inodes count */
__le32 s_first_data_block; /* First Data Block */
__le32 s_log_block_size; /* Block size */
__le32 s_log_cluster_size; /* Allocation cluster size */
__le32 s_blocks_per_group; /* # Blocks per group */
__le32 s_clusters_per_group; /* # Clusters per group */
__le32 s_inodes_per_group; /* # Inodes per group */
...
// journaling
__u8 s_journal_uuid[16]; /* uuid of journal superblock */
__le32 s_journal_inum; /* inode number of journal file */
__le32 s_journal_dev; /* device number of journal file */
...
}
$ dumpe2fs –h /dev/sd[a-z]$n
// total 64bytes
struct ext4_group_desc {
__le32 bg_block_bitmap_lo; /* Blocks bitmap block */
__le32 bg_inode_bitmap_lo; /* Inodes bitmap block */
__le32 bg_inode_table_lo; /* Inodes table block */
__le16 bg_free_blocks_count_lo;/* Free blocks count */
__le16 bg_free_inodes_count_lo;/* Free inodes count */
__le16 bg_used_dirs_count_lo; /* Directories count */
__le16 bg_flags; /* EXT4_BG_flags */
…
}
$dumpe2fs /dev/sd[a-z]$n
ext4_fsblk_t ext4_mb_new_blocks(handle_t *handle,
struct ext4_allocation_request *ar, int *errp)
{
…
*errp = ext4_mb_regular_allocator(ac); /* allocate space in core */
}
ext3_fsblk_t ext3_new_blocks(handle_t *handle, struct inode *inode,
ext3_fsblk_t goal, unsigned long *count, int *errp)
{
…
for (bgi = 0; bgi < ngroups; bgi ++)
grp_alloc_blk = ext3_try_to_allocate_with_rsv(sb, handle,
group_no, bitmap_bh, -1, my_rsv,
&num, &fatal);
}
지연할당은 자유 블록 카운트만 갱신하고 실제 할당은 뒤로 미루는 방식(단편화 방지)
이전 파일 시스템의 할당 정책
Ex4의 지연 할당
int ext4_alloc_da_blocks (struct inode *inode)
{
trace_ext4_alloc_da_blocks(inode);
if (!EXT4_I(inode)->i_reserved_data_blocks &&
!EXT4_I(inode)->i_reserved_meta_blocks)
return 0;
return filemap_flush(inode->i_mapping);
}