Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


❑ Device files,named pipes,andpersistent socketsare also fully described by the information in the
inode. In memory, data also required are held in the inode structure of the VFS (i_cdevfor char-
acter devices andi_rdevfor block devices; all information can be reconstructed from these). On
the hard disk the first element of the data pointer arrayi_data[0]is used to store the additional
information; this does not cause any problems because device files require no data blocks; the
same trick is used as with symbolic links.

Data Structures in Memory


To dispense with the need to constantly read administration structures from slow hard disks, Linux
saves the most important information that these structures contain in special data structures that reside
permanently in RAM. Access is considerably faster, and less interaction with the hard disk is required.
Then why aren’t all filesystem management data held in RAM (with writeback of changes to disk at
regular intervals)? Although theoretically this would be possible, it does not work in practice because so
much memory would be required to hold all block andinode bitmaps of a large hard disk with several
gigabytes — as found on many computers today.

The virtual filesystem provides an element nameduin thestruct super_blockandstruct inodestruc-
tures. This element is used by the various filesystem implementations to store information not already
included in the filesystem-independent contents of the structure. The Second Extended Filesystem uses
theext2_sb_infoandext2_inode_infostructures for the same purpose. The latter is of no particular
interest as compared to its counterpart on the hard disk.

ext2_sb_infois defined as follows:

<ext2_fs_sb.h>
struct ext2_sb_info {
unsigned long s_frag_size; /* Size of a fragment in bytes */
unsigned long s_frags_per_block;/* Number of fragments per block */
unsigned long s_inodes_per_block;/* Number of inodes per block */
unsigned long s_frags_per_group;/* Number of fragments in a group */
unsigned long s_blocks_per_group;/* Number of blocks in a group */
unsigned long s_inodes_per_group;/* Number of inodes in a group */
unsigned long s_itb_per_group; /* Number of inode table blocks per group */
unsigned long s_gdb_count; /* Number of group descriptor blocks */
unsigned long s_desc_per_block; /* Number of group descriptors per block */
unsigned long s_groups_count; /* Number of groups in the fs */
unsigned long s_overhead_last; /* Last calculated overhead */
unsigned long s_blocks_last; /* Last seen block count */
struct buffer_head * s_sbh; /* Buffer containing the super block */
struct ext2_super_block * s_es; /* Pointer to the super block in the buffer
*/
struct buffer_head ** s_group_desc;
unsigned long s_mount_opt;
unsigned long s_sb_block;
uid_t s_resuid;
gid_t s_resgid;
unsigned short s_mount_state;
unsigned short s_pad;
int s_addr_per_block_bits;
int s_desc_per_block_bits;
int s_inode_size;
int s_first_ino;
Free download pdf