dentry cache questions
-
- Member
- Posts: 44
- Joined: Fri Sep 09, 2016 5:52 pm
- Location: Australia
- Contact:
dentry cache questions
I have a few questions about the implementation of a dentry cache. I am a bit unsure on how to manage files with the same name in different directories on a filesystem as they would have the same hash value in the hash table. Should I check the parent directory against the path? Also, how should I manage subdirectories, should I have a linked list and only read the entries from the disk when the list is empty?
Re: dentry cache questions
Depends on what you want to do. Either you make your dentry cache a map from inode and file name to inode, then every directory has its own entry cache and you don't need to deal with the same name twice. Or you make your dentry cache a map from path name to inode and device, then you also don't need to deal with the same name twice, though you do need to entirely resolve every path that goes into it first (add the CWD to relative paths, etc.). In either case, you do need a strategy to deal with hash collisions, since those are possible even with different names.
Carpe diem!
Re: dentry cache questions
Considering that hash collisions need to be handled anyway (at a lower level, namely in the hash table's implementation), using an inode number + file name seems to be the superior solution (less data to hash => faster lookup).
managarm: Microkernel-based OS capable of running a Wayland desktop (Discord: https://discord.gg/7WB6Ur3). My OS-dev projects: [mlibc: Portable C library for managarm, qword, Linux, Sigma, ...] [LAI: AML interpreter] [xbstrap: Build system for OS distributions].