diff options
author | Liav A <liavalb@gmail.com> | 2022-08-20 00:03:24 +0300 |
---|---|---|
committer | Andrew Kaster <andrewdkaster@gmail.com> | 2022-10-22 16:57:52 -0400 |
commit | 0fd7b688af0b9b5a8976fb8b0acfeec68917101d (patch) | |
tree | bc325a61ca5ed7170fcc2c13fd4759d47981e299 /Kernel/FileSystem/FileBackedFileSystem.h | |
parent | 965afba3205baa4a8f66c17eb6402b1174a2ce52 (diff) | |
download | serenity-0fd7b688af0b9b5a8976fb8b0acfeec68917101d.zip |
Kernel: Introduce support for using FileSystem object in multiple mounts
The idea is to enable mounting FileSystem objects across multiple mounts
in contrast to what happened until now - each mount has its own unique
FileSystem object being attached to it.
Considering a situation of mounting a block device at 2 different mount
points at in system, there were a couple of critical flaws due to how
the previous "design" worked:
1. BlockBasedFileSystem(s) that pointed to the same actual device had a
separate DiskCache object being attached to them. Because both instances
were not synchronized by any means, corruption of the filesystem is most
likely achieveable by a simple cache flush of either of the instances.
2. For superblock-oriented filesystems (such as the ext2 filesystem),
lack of synchronization between both instances can lead to severe
corruption in the superblock, which could render the entire filesystem
unusable.
3. Flags of a specific filesystem implementation (for example, with xfs
on Linux, one can instruct to mount it with the discard option) must be
honored across multiple mounts, to ensure expected behavior against a
particular filesystem.
This patch put the foundations to start fix the issues mentioned above.
However, there are still major issues to solve, so this is only a start.
Diffstat (limited to 'Kernel/FileSystem/FileBackedFileSystem.h')
-rw-r--r-- | Kernel/FileSystem/FileBackedFileSystem.h | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Kernel/FileSystem/FileBackedFileSystem.h b/Kernel/FileSystem/FileBackedFileSystem.h index e959bb729c..8bfb1a1b6f 100644 --- a/Kernel/FileSystem/FileBackedFileSystem.h +++ b/Kernel/FileSystem/FileBackedFileSystem.h @@ -12,6 +12,8 @@ namespace Kernel { class FileBackedFileSystem : public FileSystem { + friend class VirtualFileSystem; + public: virtual ~FileBackedFileSystem() override; @@ -23,10 +25,19 @@ public: protected: explicit FileBackedFileSystem(OpenFileDescription&); + // Note: We require all FileBackedFileSystem to implement something that actually + // takes into account the fact that we will clean the last mount of the filesystem, + // therefore, removing the file system with it from the Kernel memory. + virtual ErrorOr<void> prepare_to_clear_last_mount() override = 0; + + virtual ErrorOr<void> initialize_while_locked() = 0; + virtual bool is_initialized_while_locked() = 0; + private: + virtual ErrorOr<void> initialize() override final; virtual bool is_file_backed() const override { return true; } + IntrusiveListNode<FileBackedFileSystem> m_file_backed_file_system_node; mutable NonnullLockRefPtr<OpenFileDescription> m_file_description; }; - } |