OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 5:03 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: dentry cache questions
PostPosted: Wed Jun 17, 2020 5:38 am 
Offline
Member
Member

Joined: Fri Sep 09, 2016 5:52 pm
Posts: 44
Location: Australia
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?

_________________
My OS:
https://github.com/fido2020/Lemon-OS
https://lemonos.org
https://discord.gg/NAYp6AUYWM


Top
 Profile  
 
 Post subject: Re: dentry cache questions
PostPosted: Wed Jun 17, 2020 7:46 am 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
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!


Top
 Profile  
 
 Post subject: Re: dentry cache questions
PostPosted: Wed Jun 17, 2020 10:52 am 
Offline
Member
Member

Joined: Thu May 17, 2007 1:27 pm
Posts: 999
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].


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 15 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group