Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


However, the superblock manages more inode lists that are managed independently ofi_sb_list
(Section 8.4.1 takes a closer look at the definition ofstruct super_block). If an inode is dirty, that is,
its content has been modified, it is listed on a dirty list headed bysuper_block->s_dirtywith the list
elementi_list. This has the advantage that it is not necessary to scanallinodes of the system when
writing back data (data writeback is also often referred to assynchronization) — it suffices to consider all
inodes on the dirty list. Two more lists (headed bysuper_block->s_ioandsuper_block->s_more_io)
use the same list elementi_list. They contain inodes that have been selected to be written back to disk
and are waiting for this to happen.

8.3.3 Process-Specific Information


File descriptors (which are nothing more than integer numbers) are used to uniquely identify opened files
within a process. This assumes that the kernel is capable of establishing a link between the descriptors in
the user process and the structures used internally. The elements needed to do this are included in the
task structure of each process.

<sched.h>
struct task_struct {
...
/* file system info */
int link_count, total_link_count;
...
/* filesystem information */
struct fs_struct *fs;
/* open file information */
struct files_struct *files;
/* namespaces */
struct nsproxy *nsproxy;
...
}

The integer elementslink_countandtotal_link_countare used to prevent endless loops when looking
up circularly chained links as I will demonstrate in Section 8.4.2.

The filesystem-related data of a process are stored infs. These data include, for example, the current
working directory and information onchrootrestrictions, which I discuss in Section 8.3.4.

Since the kernel allows for simultaneously runningmultiple containers that mimic independent sys-
tems, every resource that seems ‘‘global’’ to the container is wrapped up by the kernel and separately
managed for every container. The virtual filesystem is also affected because each container can face a
different mount hierarchy. The corresponding information is contained inns_proxy->mnt_namespace
(see Section 8.3.4).

filescontains the process file descriptors examined in the section below.

AssociatedFiles


Thefileelement of the task structure is of typefiles_struct. The definition is as follows:

<sched.h>
struct files_struct {
atomic_t count;
struct fdtable *fdt;
Free download pdf