Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


The operations in the structure do not change the contents of inodes but control the way in which inode
data are obtained and returned to the underlying implementations. The structure also includes methods
for carrying out relatively extensive tasks such asremounting filesystems. As the names of the function
pointers clearly indicate the actions performed by thefunctions, I describe them in a very cursory fashion
below.


❑ read_inodereads inode data; strangely, it requires a pointer to an inode structure but no other
parameters. How does the function then know whichinodetoread?Theanswerisrelatively
simple. Thei_inofield of the passed inode holds an inode number that uniquely identifies the
desired inode in the filesystem. The routines of the low-level implementation read this value,
fetch the relevant data from the storage medium, and fill the remaining fields of the inode object.
❑ dirty_inodemarks the passed inode structure as ‘‘dirty‘‘ because its data have been modified.
❑ delete_inodedeletes the inode from memory and from the underlying storage medium.

As you will see when examining the filesystem implementations, deleting an inode
from a storage medium causes the pointer to the associated data blocks to be
removed but leaves the file data untouched (they are overwritten at an unspecified
time in the future). Knowledge of the filesystem structure coupled with physical
access to the computer are therefore sufficient to restore deleted files — and this
could be a problem where sensitive data are concerned.

❑ put_inodedecrements the inode usage counter in memory when a process finishes using the
data.

The object cannot be removed from memory until all users have invoked this
function and the counter has reached 0.

❑ clear_inodeis invoked internally by the VFS when there is no further use for an inode. It frees
all associated memory pages still containing data.clear_inodeis not implemented by all filesys-
tems as these are able to release memory in other ways.
❑ write_superandwrite_super_lockfswrite the superblock to the storage medium. The differ-
ence between the two functions is the way in which they use kernel locking. The kernel must
select the function appropriate to the situation. I won’t bother discussing the detailed differences
in code because both alternatives do basically the same work.
❑ unlockfsis used by the Ext3 and Reiserfs journaling filesystem to ensure correct interaction with
the Device Mapper Code.
❑ remount_fsremounts a mounted filesystem with modified options (this happens at boot time,
e.g., to allow Write access to the root filesystem previously mounted with Read Only access).
❑ put_superremoves private information of the superblock from memory when a filesystem is
unmounted and the data are no longer needed.
❑ statfsdelivers statistics information on the filesystem — for instance, the number of used and
unused data blocks or the maximum length of filenames. It works hand-in-hand with the system
call of the same name.
❑ umount_beginis used only by networking filesystems (NFS, CIFS, and 9fs) and userspace filesys-
tems (FUSE). It permits communication with the remote partnerbeforethe unmounting operation
Free download pdf