Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


is started. It is invoked only when a filesystem is forced to unmount; in other words, it is only
used whenMNT_FORCEforces the kernel to perform theumountoperation, although there are still
references to the filesystem.
❑ sync_fssynchronizes the filesystem data with the data on the underlying block device.
❑ show_optionsis used by theprocfilesystem to display the filesystem mount options.
show_statsprovides filesystem statistics for the same purpose.

The Mount System Call


The point of entry for themountsystem call is thesys_mountfunction defined infs/namespace.c.
Figure 8-5 shows the associated code flow diagram.

Copy mount options

sys_mount

Call flag specific mount function

do_mount

path_lookup

Figure 8-5: Code flow diagram forsys_mount.

The approach described here is used only to mount a new filesystem in an existing root filesystem. A
modified version of the above algorithm mounts the rootfilesystem itself, but is not sufficiently interest-
ing to merit a separate description (its code can be found inmount_rootininit/do_mounts.c).

After the mount options (type, device, and options) have been copied from userspace bysys_mount,the
kernel transfers control todo_mount, where the information passed is analyzed, and the relevant flags
areset.Thisisalsowherethedentryentry of the mount point is found using thepath_lookupfunction
discussed below.

do_mountacts as a multiplexer to delegate work that still needs to be done to various mount type-
dependent functions.

❑ do_remountmodifies the options of a filesystem already mounted (MS_REMOUNT).
❑ do_loopbackis invoked to mount a filesystem via the loopback interface (theMS_BINDflag is
required to do this).^15
❑ do_move_mount(MS_MOVE) is used to move a mounted filesystem.
❑ do_change_typeis responsible for handling shared, slave, and unbindable mounts by changing
the mount flags or building up the required data structure connections between thevfsmount
instances involved.
❑ do_new_mounthandles normal mount operations. This is the default situation, so no special flags
are required.

(^15) A loopback mount involves mounting a filesystem whose data reside in a file and not on a normal block device.
This is useful to quickly test new filesystems or to check CD-ROM filesystems before writing them to CD.

Free download pdf