Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 8: The Virtual Filesystem


uppercase and lowercase, a simple string match would return an incorrect result. A FAT-specific
function must be provided in this case.
❑ d_revalidateis of particular relevance for network filesystems. It checks whether the
structure set up by the individualdentryobjects in memory still reflects the current situa-
tion. Because the underlying filesystem is not directly linked with the kernel/VFS and all
information must be gathered via a network connection, somedentrys may no longer be
valid as a result of changes to the filesystem made at the other end. This function ensures
consistency.
As inconsistencies of this kind do not usually occur in local filesystems, the default implementa-
tion in VFS does nothing whend_revalidateis invoked.

As the functions in the preceding list are not implemented by most filesystems, the convention is that
the operations are always replaced with the VFS default implementation if a null pointer is found for a
function.

StandardFunctions


Several auxiliary functions that ease handling dentry objects are provided by the kernel. Their imple-
mentation is mostly an exercise in list management and data structure handling, so I won’t bother to
discuss their code. It is, however, important to show their prototypes and describe their effect since
we will come across them frequently in discussing implementation of VFS operations. The follow-
ing auxiliary functions require a pointer tostruct dentryas parameter. Each performs one simple
operation.

❑ dgetneeds to be called whenever adentryinstance is put to use by some part of the kernel.
Callingdgetincrements the reference count of the object; that is, it acquires a reference to it.
❑ dputis the counterpart todget: It must be called when adentryinstance is not required any
more by a user in the kernel.
The function decrements the usage count of adentryobject. If the count drops to zero, the
dentry_operations->d_deletemethod is called if it is available. Additionally, the instance is
unhashed from the global dentry hash usingd_drop, and also taken away from the LRU list and
put on the unused list.
If the object is not contained in the hash whendputis called, it is deleted from memory via
kfree.
❑ d_dropunhashes adentryinstance from the global dentry hash tables. It is automatically called
fromdputif the usage count drops to zero, but can also be called manually if a dentry cache
object needs to be invalidated.__d_dropis a variant ofd_dropthat does not automatically han-
dle locking.
❑ d_deleteunhashes adentryobject using__d_dropif it is still contained on the global dentry
hash tables. If only one user for the object remains,dentry_iputis also called to decrement the
usage count of the inode associated with the dentry object.
d_deleteis usually called immediately beforedput. This ensures that thedentryobject will be
erased bydputsince it is not on the global dentry hash anymore.
Free download pdf