dentry cache questions

Discussions on more advanced topics such as monolithic vs micro-kernels, transactional memory models, and paging vs segmentation should go here. Use this forum to expand and improve the wiki!
Post Reply
ComputerFido
Member
Member
Posts: 44
Joined: Fri Sep 09, 2016 5:52 pm
Location: Australia
Contact:

dentry cache questions

Post by ComputerFido »

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?
nullplan
Member
Member
Posts: 1766
Joined: Wed Aug 30, 2017 8:24 am

Re: dentry cache questions

Post by nullplan »

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!
Korona
Member
Member
Posts: 1000
Joined: Thu May 17, 2007 1:27 pm
Contact:

Re: dentry cache questions

Post by Korona »

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].
Post Reply