I have decided to rewrite the code for my virtual file system in order to implement some new features, one of them being caching of directory entries (I'm not going to worry about caching of file data, not yet). My problem is simple, the solution apparently not so much. How should I store the directory entries in my cache?
I have been thinking about this for a while, but I cannot seem to find a solution that fit my needs. I want it to be easy to look up a given file or directory and it should be possible to edit the cache when a file is changed or deleted. When a file is changed I will find it acceptable if the entire directory must be re-fetced into the cache from the actual file system, so the problem is more or less how to structure the cache itself.
My "solution" so far is a cache for each mount point with a two-level tree like structure. The structure contains a list of all cached directories identifiable by file name and inode. Each of these directory entries contains a list of all files (and directories) inside this directory. What do you think? I would like some comments on this
