mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-04 05:20:30 +00:00
Kernel/FileSystem: Pass last mount point guest inode to unmount prepare
This will be important later on when we check file system busyness.
This commit is contained in:
parent
2fe5ece449
commit
8fb126bec6
Notes:
sideshowbarker
2024-07-17 05:02:42 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/8fb126bec6 Pull-request: https://github.com/SerenityOS/serenity/pull/19668 Reviewed-by: https://github.com/gmta ✅ Reviewed-by: https://github.com/linusg
11 changed files with 14 additions and 13 deletions
|
@ -532,8 +532,9 @@ unsigned Ext2FS::free_inode_count() const
|
|||
return super_block().s_free_inodes_count;
|
||||
}
|
||||
|
||||
ErrorOr<void> Ext2FS::prepare_to_clear_last_mount()
|
||||
ErrorOr<void> Ext2FS::prepare_to_clear_last_mount(Inode& mount_guest_inode)
|
||||
{
|
||||
(void)mount_guest_inode;
|
||||
MutexLocker locker(m_lock);
|
||||
for (auto& it : m_inode_cache) {
|
||||
if (it.value->ref_count() > 1)
|
||||
|
|
|
@ -70,7 +70,7 @@ private:
|
|||
virtual ErrorOr<void> initialize_while_locked() override;
|
||||
virtual bool is_initialized_while_locked() override;
|
||||
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount() override;
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount(Inode& mount_guest_inode) override;
|
||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_inode(Ext2FSInode& parent_inode, StringView name, mode_t, dev_t, UserID, GroupID);
|
||||
ErrorOr<NonnullRefPtr<Inode>> create_directory(Ext2FSInode& parent_inode, StringView name, mode_t, UserID, GroupID);
|
||||
|
|
|
@ -33,7 +33,7 @@ private:
|
|||
virtual bool is_initialized_while_locked() override;
|
||||
// FIXME: This is not a proper way to clear last mount of a FAT filesystem,
|
||||
// but for now we simply have no other way to properly do it.
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount() override { return {}; }
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount(Inode&) override { return {}; }
|
||||
|
||||
FATFS(OpenFileDescription&);
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ protected:
|
|||
// 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> prepare_to_clear_last_mount(Inode& mount_guest_inode) override = 0;
|
||||
|
||||
virtual ErrorOr<void> initialize_while_locked() = 0;
|
||||
virtual bool is_initialized_while_locked() = 0;
|
||||
|
|
|
@ -27,11 +27,11 @@ FileSystem::~FileSystem()
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<void> FileSystem::prepare_to_unmount()
|
||||
ErrorOr<void> FileSystem::prepare_to_unmount(Inode& mount_guest_inode)
|
||||
{
|
||||
return m_attach_count.with([&](auto& attach_count) -> ErrorOr<void> {
|
||||
if (attach_count == 1)
|
||||
return prepare_to_clear_last_mount();
|
||||
return prepare_to_clear_last_mount(mount_guest_inode);
|
||||
return {};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public:
|
|||
virtual unsigned total_inode_count() const { return 0; }
|
||||
virtual unsigned free_inode_count() const { return 0; }
|
||||
|
||||
ErrorOr<void> prepare_to_unmount();
|
||||
ErrorOr<void> prepare_to_unmount(Inode& mount_guest_inode);
|
||||
|
||||
struct DirectoryEntryView {
|
||||
DirectoryEntryView(StringView name, InodeIdentifier, u8 file_type);
|
||||
|
@ -69,7 +69,7 @@ protected:
|
|||
void set_block_size(u64 size) { m_block_size = size; }
|
||||
void set_fragment_size(size_t size) { m_fragment_size = size; }
|
||||
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount() { return {}; }
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount([[maybe_unused]] Inode& mount_guest_inode) { return {}; }
|
||||
|
||||
mutable Mutex m_lock { "FS"sv };
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ u8 ISO9660FS::internal_file_type_to_directory_entry_type(DirectoryEntryView cons
|
|||
return DT_REG;
|
||||
}
|
||||
|
||||
ErrorOr<void> ISO9660FS::prepare_to_clear_last_mount()
|
||||
ErrorOr<void> ISO9660FS::prepare_to_clear_last_mount(Inode&)
|
||||
{
|
||||
// FIXME: Do proper cleaning here.
|
||||
BlockBasedFileSystem::remove_disk_cache_before_last_unmount();
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
private:
|
||||
ISO9660FS(OpenFileDescription&);
|
||||
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount() override;
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount(Inode&) override;
|
||||
|
||||
virtual bool is_initialized_while_locked() override;
|
||||
virtual ErrorOr<void> initialize_while_locked() override;
|
||||
|
|
|
@ -21,7 +21,7 @@ Plan9FS::Plan9FS(OpenFileDescription& file_description)
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<void> Plan9FS::prepare_to_clear_last_mount()
|
||||
ErrorOr<void> Plan9FS::prepare_to_clear_last_mount(Inode&)
|
||||
{
|
||||
// FIXME: Do proper cleaning here.
|
||||
return {};
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
private:
|
||||
Plan9FS(OpenFileDescription&);
|
||||
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount() override;
|
||||
virtual ErrorOr<void> prepare_to_clear_last_mount(Inode&) override;
|
||||
|
||||
virtual bool is_initialized_while_locked() override;
|
||||
virtual ErrorOr<void> initialize_while_locked() override;
|
||||
|
|
|
@ -275,7 +275,7 @@ ErrorOr<void> VirtualFileSystem::unmount(Custody& mountpoint_custody)
|
|||
if (custody_path->view() != mountpoint_path->view())
|
||||
continue;
|
||||
NonnullRefPtr<FileSystem> fs = mount.guest_fs();
|
||||
TRY(fs->prepare_to_unmount());
|
||||
TRY(fs->prepare_to_unmount(mount.guest()));
|
||||
fs->mounted_count({}).with([&](auto& mounted_count) {
|
||||
VERIFY(mounted_count > 0);
|
||||
if (mounted_count == 1) {
|
||||
|
|
Loading…
Reference in a new issue