mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 09:58:11 +00:00
Kernel: Protect mounted filesystem list with spinlock instead of mutex
This commit is contained in:
parent
3becff9eae
commit
210689281f
2 changed files with 9 additions and 9 deletions
|
@ -52,7 +52,7 @@ InodeIdentifier VirtualFileSystem::root_inode_id() const
|
||||||
|
|
||||||
ErrorOr<void> VirtualFileSystem::mount(FileSystem& fs, Custody& mount_point, int flags)
|
ErrorOr<void> VirtualFileSystem::mount(FileSystem& fs, Custody& mount_point, int flags)
|
||||||
{
|
{
|
||||||
return m_mounts.with_exclusive([&](auto& mounts) -> ErrorOr<void> {
|
return m_mounts.with([&](auto& mounts) -> ErrorOr<void> {
|
||||||
auto& inode = mount_point.inode();
|
auto& inode = mount_point.inode();
|
||||||
dbgln("VirtualFileSystem: Mounting {} at inode {} with flags {}",
|
dbgln("VirtualFileSystem: Mounting {} at inode {} with flags {}",
|
||||||
fs.class_name(),
|
fs.class_name(),
|
||||||
|
@ -67,7 +67,7 @@ ErrorOr<void> VirtualFileSystem::mount(FileSystem& fs, Custody& mount_point, int
|
||||||
|
|
||||||
ErrorOr<void> VirtualFileSystem::bind_mount(Custody& source, Custody& mount_point, int flags)
|
ErrorOr<void> VirtualFileSystem::bind_mount(Custody& source, Custody& mount_point, int flags)
|
||||||
{
|
{
|
||||||
return m_mounts.with_exclusive([&](auto& mounts) -> ErrorOr<void> {
|
return m_mounts.with([&](auto& mounts) -> ErrorOr<void> {
|
||||||
dbgln("VirtualFileSystem: Bind-mounting inode {} at inode {}", source.inode().identifier(), mount_point.inode().identifier());
|
dbgln("VirtualFileSystem: Bind-mounting inode {} at inode {}", source.inode().identifier(), mount_point.inode().identifier());
|
||||||
// FIXME: check that this is not already a mount point
|
// FIXME: check that this is not already a mount point
|
||||||
Mount mount { source.inode(), mount_point, flags };
|
Mount mount { source.inode(), mount_point, flags };
|
||||||
|
@ -92,7 +92,7 @@ ErrorOr<void> VirtualFileSystem::unmount(Inode& guest_inode)
|
||||||
{
|
{
|
||||||
dbgln("VirtualFileSystem: unmount called with inode {}", guest_inode.identifier());
|
dbgln("VirtualFileSystem: unmount called with inode {}", guest_inode.identifier());
|
||||||
|
|
||||||
return m_mounts.with_exclusive([&](auto& mounts) -> ErrorOr<void> {
|
return m_mounts.with([&](auto& mounts) -> ErrorOr<void> {
|
||||||
for (size_t i = 0; i < mounts.size(); ++i) {
|
for (size_t i = 0; i < mounts.size(); ++i) {
|
||||||
auto& mount = mounts[i];
|
auto& mount = mounts[i];
|
||||||
if (&mount.guest() != &guest_inode)
|
if (&mount.guest() != &guest_inode)
|
||||||
|
@ -126,7 +126,7 @@ ErrorOr<void> VirtualFileSystem::mount_root(FileSystem& fs)
|
||||||
auto pseudo_path = TRY(static_cast<FileBackedFileSystem&>(fs).file_description().pseudo_path());
|
auto pseudo_path = TRY(static_cast<FileBackedFileSystem&>(fs).file_description().pseudo_path());
|
||||||
dmesgln("VirtualFileSystem: mounted root from {} ({})", fs.class_name(), pseudo_path);
|
dmesgln("VirtualFileSystem: mounted root from {} ({})", fs.class_name(), pseudo_path);
|
||||||
|
|
||||||
m_mounts.with_exclusive([&](auto& mounts) {
|
m_mounts.with([&](auto& mounts) {
|
||||||
mounts.append(move(mount));
|
mounts.append(move(mount));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ ErrorOr<void> VirtualFileSystem::mount_root(FileSystem& fs)
|
||||||
|
|
||||||
auto VirtualFileSystem::find_mount_for_host(InodeIdentifier id) -> Mount*
|
auto VirtualFileSystem::find_mount_for_host(InodeIdentifier id) -> Mount*
|
||||||
{
|
{
|
||||||
return m_mounts.with_exclusive([&](auto& mounts) -> Mount* {
|
return m_mounts.with([&](auto& mounts) -> Mount* {
|
||||||
for (auto& mount : mounts) {
|
for (auto& mount : mounts) {
|
||||||
if (mount.host() && mount.host()->identifier() == id)
|
if (mount.host() && mount.host()->identifier() == id)
|
||||||
return &mount;
|
return &mount;
|
||||||
|
@ -147,7 +147,7 @@ auto VirtualFileSystem::find_mount_for_host(InodeIdentifier id) -> Mount*
|
||||||
|
|
||||||
auto VirtualFileSystem::find_mount_for_guest(InodeIdentifier id) -> Mount*
|
auto VirtualFileSystem::find_mount_for_guest(InodeIdentifier id) -> Mount*
|
||||||
{
|
{
|
||||||
return m_mounts.with_exclusive([&](auto& mounts) -> Mount* {
|
return m_mounts.with([&](auto& mounts) -> Mount* {
|
||||||
for (auto& mount : mounts) {
|
for (auto& mount : mounts) {
|
||||||
if (mount.guest().identifier() == id)
|
if (mount.guest().identifier() == id)
|
||||||
return &mount;
|
return &mount;
|
||||||
|
@ -724,7 +724,7 @@ ErrorOr<void> VirtualFileSystem::rmdir(StringView path, Custody& base)
|
||||||
|
|
||||||
void VirtualFileSystem::for_each_mount(Function<IterationDecision(Mount const&)> callback) const
|
void VirtualFileSystem::for_each_mount(Function<IterationDecision(Mount const&)> callback) const
|
||||||
{
|
{
|
||||||
m_mounts.with_shared([&](auto& mounts) {
|
m_mounts.with([&](auto& mounts) {
|
||||||
for (auto& mount : mounts) {
|
for (auto& mount : mounts) {
|
||||||
if (callback(mount) == IterationDecision::Break)
|
if (callback(mount) == IterationDecision::Break)
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#include <Kernel/FileSystem/Mount.h>
|
#include <Kernel/FileSystem/Mount.h>
|
||||||
#include <Kernel/FileSystem/UnveilNode.h>
|
#include <Kernel/FileSystem/UnveilNode.h>
|
||||||
#include <Kernel/Forward.h>
|
#include <Kernel/Forward.h>
|
||||||
#include <Kernel/Locking/MutexProtected.h>
|
#include <Kernel/Locking/SpinlockProtected.h>
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ private:
|
||||||
RefPtr<Inode> m_root_inode;
|
RefPtr<Inode> m_root_inode;
|
||||||
RefPtr<Custody> m_root_custody;
|
RefPtr<Custody> m_root_custody;
|
||||||
|
|
||||||
MutexProtected<Vector<Mount, 16>> m_mounts;
|
SpinlockProtected<Vector<Mount, 16>> m_mounts;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue