Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 9: The Extended Filesystem Family


❑ Thes_def_resuidands_def_resgidfields specify the user and group IDs of a system user for
whom a certain number of blocks has been exclusively reserved. The corresponding number is
stored ins_r_blocks_count.
No other user may use these blocks. What purpose does this serve? By default, both
s_def_resuidands_ref_gidare set to 0; this corresponds to the system superuser (or root
user). This user is able to write to filesystems that normal users see as already being full. This
additional free space is usually referred to as theroot reserve.
If this protection were not provided, it could happen, for instance, that certain daemons or
servers running under the root ID could no longer be started, thus rendering the system
unusable. Take, for example, the ssh server, which has to create a status file when a login is per-
formed. If the hard disk were totally full, no user — not even a system administrator — would
be able to log in. This would be a major catastrophe, particularly on remote systems such as
Internet servers.
The root reserve (usually≈5% of available space is set aside when a filesystem is created) helps
prevent such mishaps and provides the superuser (or any other user if the UID/GID is changed
accordingly in the above variables) with a safety margin to ensure that at least actions can be
taken to counter overfilling of the hard disk.


❑ Filesystem consistency checks are performed with the help of three variables:s_state,
s_lastcheck,ands_checkinterval. The first is used to specify the current state of the
filesystem. When a partition is properly unmounted, its state is set toEXT2_VALID_FS(in
ext2_fs.h) to indicate to themountprogram that the partition is OK. If the filesystem was
not correctly unmounted (because, e.g., thecomputer was shut down by switching off the
power), the variable still indicates the state to which it was set directly after the filesystem
was mounted, namely,EXT2_ERROR_FS. In this case, ane2fsckconsistency check is triggered
automatically.
Incorrect unmounting is not the only reason for initiating a consistency check. The date of the
last check is recorded ins_lastcheck.Ifs_checkintervalhas elapsed since this date, a check is
enforced even if the filesystem is in a clean state.
A third (and the most frequently used) way of enforcing a consistency check is implemented
with the help of counters calleds_max_mnt_countands_mnt_count. The latter counts the num-
ber of mount operations since the last check and the first the maximum number of mounts that
may be performed between two checks. When this value is exceeded, a consistency check with
e2fsckis initiated.


❑ The Ext2 filesystem was certainly not perfect when it was introduced and (like any other
software product) never will be. Ongoing technological development brings constant changes
and modifications to systems — understandably, these should be as easy as possible to integrate
into existing schemes. After all, nobody wants to have to completely rebuild a system every
2 weeks to enjoy the benefits of a new function.Care was therefore taken during design of
the Ext2 filesystem to ensure ease of integration of new features into the old design. For this
reason, three elements of the superblock structure are dedicated to describing additional
features:s_feature_compat,s_feature_incompat,ands_feature_ro_compat. As the names of
the variables indicate, there are three different classes into which new functions are
grouped.


❑ Compatible Features(s_feature_compat)—Canbeusedbynewversionsofthe
filesystem code and have no negative impact (or functional impairment) on older
Free download pdf