.. SPDX-License-Identifier: GPL-2.0
=========================================
Overview of the Linux Virtual File System
=========================================
Original author: Richard Gooch <rgooch@atnf.csiro.au>
- Copyright (C) 1999 Richard Gooch
- Copyright (C) 2005 Pekka Enberg
Introduction
============
The Virtual File System (also known as the Virtual Filesystem Switch) is
the software layer in the kernel that provides the filesystem interface
to userspace programs. It also provides an abstraction within the
kernel which allows different filesystem implementations to coexist.
VFS system calls open(2), stat(2), read(2), write(2), chmod(2) and so on
are called from a process context. Filesystem locking is described in
the document Documentation/filesystems/locking.rst.
Directory Entry Cache (dcache)
------------------------------
The VFS implements the open(2), stat(2), chmod(2), and similar system
calls. The pathname argument that is passed to them is used by the VFS
to search through the directory entry cache (also known as the dentry
cache or dcache). This provides a very fast look-up mechanism to
translate a pathname (filename) into a specific dentry. Dentries live
in RAM and are never saved to disc: they exist only for performance.
The dentry cache is meant to be a view into your entire filespace. As
most computers cannot fit all dentries in the RAM at the same time, some
bits of the cache are missing. In order to resolve your pathname into a
dentry, the VFS may have to resort to creating dentries along the way,
and then loading the inode. This is done by looking up the inode.
The Inode Object
----------------
An individual dentry usually has a pointer to an inode. Inodes are
filesystem objects such as regular files, directories, FIFOs and other
beasts. They live either on the disc (for block device filesystems) or
in the memory (for pseudo filesystems). Inodes that live on the disc
are copied into the memory when required and changes to the inode are
written back to disc. A single inode can be pointed to by multiple
dentries (hard links, for example, do this).
To look up an inode requires that the VFS calls the lookup() method of
the parent directory inode. This method is installed