Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


What is the purpose of the individual structures in the block groups? Before answering this question, it
is best to briefly summarize their meaning:

❑ Thesuperblockis the central structure for storing meta-information on the filesystem itself. It
includes information on the number of free and used blocks, block size, current filesystem status
(needed when booting the system in order to detect a previous crash), and various time stamps
(e.g., time of last filesystem mount, time of last write operation). It also includes a magic number
so that the mount routine can establish whether the filesystem is of the correct type.
The kernel uses only the superblock of the first block group to read filesystem meta-information,
even if there are superblock objects in several block groups.
❑ Thegroup descriptorscontain information that reflects the status of the individual block groups
of the filesystem, for instance, information on the number of free blocks and inodes of the group.
Eachblock group includes group descriptors forallblock groups of the filesystem.
❑ Data block and inode bitmapsare used to hold long bit strings. These structures contain exactly
1 bit for each data block and each inode to indicate whether the block or inode is free or
in use.
❑ Theinode tablecontains all block group inodes that hold all metadata associated with the individ-
ual files and directories of the filesystem.
❑ As the name suggests, thedata block sectioncontains the useful data of the files in the filesystem.

Whereas inodes and block bitmaps always occupy an entire block, the remaining elements consist of
several blocks. The exact number depends not only onthe options selected when creating the filesystem
but also on the size of the storage medium.

The similarity of these structures with the elementsof the virtual filesystem (and the general concept
ofUnixfilesystems as discussed in Chapter 8) is unmistakable. Even though many problems, such as
directory representation, are solved by adopting this structure, the Ext2 filesystem still needs to address
several tricky issues.

A key problem in filesystem implementation is the fact that the individual files may differ
drastically — in terms of their size and purpose. While files with multimedia contents (e.g., videos) or
large databases can easily consume hundreds of megabytes or even gigabytes, small configuration files
often take up just a handful of bytes. There are also different types of meta-information. For example,
the information stored for device files differs fromthat for directories, regular files, or named pipes.

If filesystem contents are manipulated in memory only, these problems are not as serious as when
data are stored on slow external media. High-speed RAM is able to set up, scan, and modify the required
structures in no time at all, whereas the same operations are much slower and much more costly on
hard disk.

The structures used to store data must be designed tooptimally satisfy all filesystem requirements — not
always an easy task on hard disks, particularly with regard to capacity utilization and access speed. The
Second Extended Filesystem therefore resorts to the tricks and dodges described below.

Indirection


Even though the Ext2 filesystem adopts the classicUnixscheme of implementing files by means of linked
inodes, further problems of little consequence in an abstract concept need to be addressed. Hard disks
Free download pdf