Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


address_
space_
operations

dentry_
operations

s_files

super_block

host
page_tree

a_ops

address_space

f_op
f_dentry

f_op
f_dentry

f_op
f_dentry

file instances of the superblock

d_inode
d_sb
d_ops
NAME

task_struct

files files_struct

inode_
operations

file_
operations

i_op
i_dentry
i_fop
i_sb
i_mapping

inode

struct page
Doubly chained
list (schematically)

Figure 8-3: Interplay of the VFS components.

Because opened files are always assigned to a specific system process, the kernel must store the connec-
tion between the file and the process in its data structures. As discussed briefly in Chapter 2, the task
structure includes an element in which all opened files are held (via a roundabout route). This element is
an array that is accessed using the file descriptor as an index. The objects it contains are not only linked
with the inode of the corresponding file, but also have a pointer to an element of thedentry cacheused to
speed lookup operations.

The individual filesystem implementations are also able to store their own data (that is not manipulated
by the VFS layer) in the VFS inode.

Filesystemand SuperblockInformation


The supported filesystem types are linked by means of a special kernel object that features a method of
reading thesuperblock. As well as key information on the filesystem (block size, maximum file size, etc.),
the superblock contains function pointersto read, write, and manipulate inodes.

The kernel also creates a list of the superblock instances of all active filesystems. I use the termactive
instead ofmountedbecause, in certain circumstances, it is possible to use a single superblock for several
mount points.^4

(^4) When a filesystem of a block device is mounted at several points in the directory hierarchy.

Free download pdf