mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 18:54:57 +00:00
Kernel/Ext2FS: Don't hog both locks in Ext2FSInode::lookup()
This function was acquiring both the inode and file system locks (in that order) which could lead to deadlocks.
This commit is contained in:
parent
9d7e391f94
commit
ace8b9a0ee
1 changed files with 12 additions and 6 deletions
|
@ -1623,12 +1623,18 @@ RefPtr<Inode> Ext2FSInode::lookup(StringView name)
|
|||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name);
|
||||
if (populate_lookup_cache().is_error())
|
||||
return {};
|
||||
Locker locker(m_lock);
|
||||
auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; });
|
||||
if (it != m_lookup_cache.end())
|
||||
return fs().get_inode({ fsid(), (*it).value });
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name);
|
||||
return {};
|
||||
|
||||
InodeIndex inode_index;
|
||||
{
|
||||
Locker locker(m_lock);
|
||||
auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; });
|
||||
if (it == m_lookup_cache.end()) {
|
||||
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): '{}' not found", identifier(), name);
|
||||
return {};
|
||||
}
|
||||
inode_index = it->value;
|
||||
}
|
||||
return fs().get_inode({ fsid(), inode_index });
|
||||
}
|
||||
|
||||
void Ext2FSInode::one_ref_left()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue