Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


The division of a partition into block groups makes sense for systematic reasons and also brings tangible
benefits in terms of speed. The filesystem always attempts to store the contents of a file in a single block
group to minimize the travel of the read/write head between inode, block bitmap, and data blocks.
Normally, this can be achieved, but there are, of course, situations in which files are spread over several
block groups because there is not enough space in a single block group. Because, depending on block
size, a block group can accept only a certain number of data blocks, there are maximum limits for file
sizes (see Table 9-2). If these are exceeded, files must be spread over several block groups at the price of
longer read/write head travel and reduced performance.

Inodes


Each block group also contains an inode bitmap and a local inode table that may extend over several
blocks. The bitmap contents relate to the local block group and are not copied to any other point in the
filesystem.

The inode bitmap is used to provide an overview of the used and free inodes of a group. As usual, each
inode is represented as ‘‘used‘‘ or ‘‘free‘‘ by means of a single bit. The inode data are stored in the inode
table with the help of a large number of sequential inode structures. How these data are held on the
storage medium is defined by the following lengthier structure:

<ext2_fs.h>
struct ext2_inode {
__le16 i_mode; /* File mode */
__le16 i_uid; /* Low 16 bits of Owner Uid */
__le32 i_size; /* Size in bytes */
__le32 i_atime; /* Access time */
__le32 i_ctime; /* Creation time */
__le32 i_mtime; /* Modification time */
__le32 i_dtime; /* Deletion Time */
__le16 i_gid; /* Low 16 bits of Group Id */
__le16 i_links_count; /* Links count */
__le32 i_blocks; /* Blocks count */
__le32 i_flags; /* File flags */
union {
struct {
__le32 l_i_reserved1;
} linux1;
struct {
...
} hurd1;
struct {
...
} masix1;
} osd1; /* OS dependent 1 */
__le32 i_block[EXT2_N_BLOCKS];/* Pointers to blocks */
__le32 i_generation; /* File version (for NFS) */
__le32 i_file_acl; /* File ACL */
__le32 i_dir_acl; /* Directory ACL */
__le32 i_faddr; /* Fragment address */
union {
struct {
__u8 l_i_frag; /* Fragment number */
__u8 l_i_fsize; /* Fragment size */
Free download pdf