2

I've been reading this page, http://www.tldp.org/LDP/tlk/fs/filesystem.html, and I have trouble organizing all the different caches it's talking about. Especially, I don't understand the different scenarios of when each are used.

From the way I understood, there are

  1. Buffer cache: Used by the VFS. Says that data buffers are put in the cache. I don't know if data buffers are the only thing in the Buffer cache. Also, I'm not sure if it's only used by the VFS.

  2. VFS inode cache: After accessing a file, its inode is put into the cache for faster look up. I'm not sure if having the inode information means that the system no longer needs to go down the file system tree to the location (As in, if a file is under Documents, it will no longer need to reach Documents from root directory).

  3. EXT2 (or other filesystems that use inodes) inode cache: Does this exist? It's never mentioned, but I'm assuming it exists.

  4. VFS directory cache: Stores "directory name to inode" mappings. As the following quote says from the link, apparently you can get a VFS inode just with the VFS cache:

    If there is no entry in the directory cache, the real file system gets the VFS inode either from the underlying file system or from the inode cache.

    Then why do we even need a directory cache? Is this related to the dentry cache?

  5. Dentry cache: Why is this not mentioned in the above article? Is it not related?

2

Then why do we even need a directory cache?

It's just another level of caching. Even if all the path components can be found in other caches, it still takes time to traverse them all. So the directory cache provides a way to cache whole paths and avoid looking things up path element by path element from the root each time.

  • Is each path component an inode? And is "directory cache" and "dentry cache" the same? – CuriousKimchi Dec 29 '16 at 6:57
  • @CuriousKimchi: Every directory is a file and every file has an inode. – Julie Pelletier Dec 29 '16 at 7:09
  • @JuliePelletier Let me see if I understand it right. So, for example, I am trying to access /foo/bar/file. Even if I have everything I need in the inode cache, I need to look up the inode for "/" which has info for inode for "foo" which has info for inode for "bar", and so on till I get the data from /foo/bar/file. And if "/foo/bar/file" is in the directory cache, then, I can just go straight to the inode for "file", correct? – CuriousKimchi Dec 29 '16 at 7:18
  • That's exactly right. – Julie Pelletier Dec 29 '16 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.