Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


countis a usage counter to specify the number of processes using the namespace.rootpoints to the
vfsmountinstance of the root directory, andlistis the start of a doubly linked list that holds allvfsmount
instances linked by theirmnt_listelements.

Namespace manipulation operations such asmountandumountdo not act on a global data structure of
the kernel (as was previously the case). Instead, they manipulate thenamespaceinstance of the current
process that can be accessed via the task structure element of the same name. The change affects all
members because all processes of a namespace share the samenamespaceinstance.

8.3.5 Directory Entry Cache


Owing to slow block media, it can take quite some time to find the inode associated with a filename. Even
if the device data are already in the page cache (see Chapter 16), it is nonsensical to repeat the full lookup
operation each time.

Linux uses thedirectory entry cache(dentry cache, for short) to provide quick access to the results of a
previous full lookup operation (we take a closer look at this in Section 8.4.2). The cache is built around
struct dentry, which has already been mentioned a few times.

Once the VFS — together with the filesystem implementations — has read the data of a directory or file
entry, adentryinstance is created to cache the data found.

Dentry Structure


The structure is defined as follows:

<dcache.h>
struct dentry {
atomic_t d_count;
unsigned int d_flags; /* protected by d_lock */
spinlock_t d_lock; /* per dentry lock */
struct inode *d_inode; /* Where the name belongs to - NULL is
* negative */
/*
* The next three fields are touched by __d_lookup. Place them here
* so they all fit in a cache line.
*/
struct hlist_node d_hash; /* lookup hash list */
struct dentry *d_parent; /* parent directory */
struct qstr d_name;

struct list_head d_lru; /* LRU list */
union {
struct list_head d_child; /* child of parent list */
struct rcu_head d_rcu;
} d_u;
struct list_head d_subdirs; /* our children */
struct list_head d_alias; /* inode alias list */
unsigned long d_time; /* used by d_revalidate */
struct dentry_operations *d_op;
struct super_block *d_sb; /* The root of the dentry tree */
void *d_fsdata; /* fs-specific data */
Free download pdf