Kernel: Remove completely unnecessary lock on file lookup
Mount point lookup already does locking internally, there is no need for a lock for the whole duration of the lookup :D
This commit is contained in:
@@ -92,8 +92,9 @@ namespace Kernel
|
|||||||
MountPoint* mount_from_root_inode(BAN::RefPtr<Inode>);
|
MountPoint* mount_from_root_inode(BAN::RefPtr<Inode>);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Mutex m_mutex;
|
|
||||||
BAN::RefPtr<FileSystem> m_root_fs;
|
BAN::RefPtr<FileSystem> m_root_fs;
|
||||||
|
|
||||||
|
Mutex m_mount_point_lock;
|
||||||
BAN::Vector<MountPoint> m_mount_points;
|
BAN::Vector<MountPoint> m_mount_points;
|
||||||
|
|
||||||
friend class BAN::RefPtr<VirtualFileSystem>;
|
friend class BAN::RefPtr<VirtualFileSystem>;
|
||||||
|
|||||||
@@ -210,14 +210,14 @@ namespace Kernel
|
|||||||
if (!file.inode->mode().ifdir())
|
if (!file.inode->mode().ifdir())
|
||||||
return BAN::Error::from_errno(ENOTDIR);
|
return BAN::Error::from_errno(ENOTDIR);
|
||||||
|
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mount_point_lock);
|
||||||
TRY(m_mount_points.emplace_back(file_system, BAN::move(file)));
|
TRY(m_mount_points.emplace_back(file_system, BAN::move(file)));
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
VirtualFileSystem::MountPoint* VirtualFileSystem::mount_from_host_inode(BAN::RefPtr<Inode> inode)
|
VirtualFileSystem::MountPoint* VirtualFileSystem::mount_from_host_inode(BAN::RefPtr<Inode> inode)
|
||||||
{
|
{
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mount_point_lock);
|
||||||
for (MountPoint& mount : m_mount_points)
|
for (MountPoint& mount : m_mount_points)
|
||||||
if (*mount.host.inode == *inode)
|
if (*mount.host.inode == *inode)
|
||||||
return &mount;
|
return &mount;
|
||||||
@@ -226,7 +226,7 @@ namespace Kernel
|
|||||||
|
|
||||||
VirtualFileSystem::MountPoint* VirtualFileSystem::mount_from_root_inode(BAN::RefPtr<Inode> inode)
|
VirtualFileSystem::MountPoint* VirtualFileSystem::mount_from_root_inode(BAN::RefPtr<Inode> inode)
|
||||||
{
|
{
|
||||||
LockGuard _(m_mutex);
|
LockGuard _(m_mount_point_lock);
|
||||||
for (MountPoint& mount : m_mount_points)
|
for (MountPoint& mount : m_mount_points)
|
||||||
if (*mount.target->root_inode() == *inode)
|
if (*mount.target->root_inode() == *inode)
|
||||||
return &mount;
|
return &mount;
|
||||||
@@ -235,8 +235,6 @@ namespace Kernel
|
|||||||
|
|
||||||
BAN::ErrorOr<VirtualFileSystem::File> VirtualFileSystem::file_from_relative_path(BAN::RefPtr<Inode> root_inode, const File& parent, const Credentials& credentials, BAN::StringView path, int flags)
|
BAN::ErrorOr<VirtualFileSystem::File> VirtualFileSystem::file_from_relative_path(BAN::RefPtr<Inode> root_inode, const File& parent, const Credentials& credentials, BAN::StringView path, int flags)
|
||||||
{
|
{
|
||||||
LockGuard _(m_mutex);
|
|
||||||
|
|
||||||
auto inode = parent.inode;
|
auto inode = parent.inode;
|
||||||
ASSERT(inode);
|
ASSERT(inode);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user