Kernel: Improve locking in Process, VFS and ATAController

We used to block on all process access. This meant that shell
reading the keyboard input would block all VFS access making disk
accesses practically impossible. We now block only when it is
necessary :)
This commit is contained in:
Bananymous
2023-03-30 22:02:16 +03:00
parent dcee92a6bc
commit b048630e5b
7 changed files with 90 additions and 60 deletions

View File

@@ -1,10 +1,9 @@
#pragma once
#include <BAN/HashMap.h>
#include <BAN/String.h>
#include <BAN/StringView.h>
#include <BAN/Vector.h>
#include <kernel/FS/FileSystem.h>
#include <kernel/Storage/StorageController.h>
#include <kernel/SpinLock.h>
namespace Kernel
{
@@ -16,9 +15,10 @@ namespace Kernel
static VirtualFileSystem& get();
virtual ~VirtualFileSystem() {};
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_fs->root_inode(); }
virtual BAN::RefPtr<Inode> root_inode() override { return m_root_fs->root_inode(); }
BAN::ErrorOr<void> mount(BAN::StringView, BAN::StringView);
BAN::ErrorOr<void> mount(FileSystem*, BAN::StringView);
struct File
{
@@ -29,7 +29,6 @@ namespace Kernel
private:
VirtualFileSystem() = default;
BAN::ErrorOr<void> mount(FileSystem*, BAN::StringView);
struct MountPoint
{
@@ -39,9 +38,9 @@ namespace Kernel
MountPoint* mount_point_for_inode(BAN::RefPtr<Inode>);
private:
SpinLock m_lock;
FileSystem* m_root_fs = nullptr;
BAN::Vector<MountPoint> m_mount_points;
BAN::Vector<StorageController*> m_storage_controllers;
};
}

View File

@@ -41,7 +41,7 @@ namespace Kernel
BAN::ErrorOr<BAN::Vector<BAN::String>> read_directory_entries(int);
BAN::String working_directory() const;
BAN::ErrorOr<BAN::String> working_directory() const;
BAN::ErrorOr<void> set_working_directory(BAN::StringView);
static BAN::RefPtr<Process> current() { return Thread::current().process(); }

View File

@@ -87,6 +87,7 @@ namespace Kernel
private:
ATABus m_buses[2];
const PCIDevice& m_pci_device;
SpinLock m_lock;
friend class ATADevice;