Why is the inode cache needed?

Directory entries and inodes are different objects, so they get separate caches: the dentry cache in dcache.c, the inode cache in inode_hashtable in inode.c. But the inode cache is a slave to the dcache:

The dcache is a master of the icache — whenever a dcache entry exists, the inode will always exist.

As you no doubt know already, the point of these caches is to increase performance and avoid constant disk accesses, especially for the inode which can be updated many times while a file is open.


You're asking about the inode cache implemented as part of the Linux Virtual File System (VFS). Caches, including the inode cache are not just used to provide functionality, like accessing inode entries, as there are other mechanisms for this as you point out.

Caches can be used to improve performance and in this case looking up inode data from an io device such as a disk is very slow, so storing previously accessed inode data in memory makes file system access much quicker.

Tags:

Inode

Cache