Ver código fonte

Kernel/FileSystem: Pass last mount point guest inode to unmount prepare

This will be important later on when we check file system busyness.
kleines Filmröllchen 2 anos atrás
pai
commit
8fb126bec6

+ 2 - 1
Kernel/FileSystem/Ext2FS/FileSystem.cpp

@@ -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)

+ 1 - 1
Kernel/FileSystem/Ext2FS/FileSystem.h

@@ -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);

+ 1 - 1
Kernel/FileSystem/FATFS/FileSystem.h

@@ -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&);
 

+ 1 - 1
Kernel/FileSystem/FileBackedFileSystem.h

@@ -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;

+ 2 - 2
Kernel/FileSystem/FileSystem.cpp

@@ -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 {};
     });
 }

+ 2 - 2
Kernel/FileSystem/FileSystem.h

@@ -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 };
 

+ 1 - 1
Kernel/FileSystem/ISO9660FS/FileSystem.cpp

@@ -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();

+ 1 - 1
Kernel/FileSystem/ISO9660FS/FileSystem.h

@@ -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;

+ 1 - 1
Kernel/FileSystem/Plan9FS/FileSystem.cpp

@@ -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 {};

+ 1 - 1
Kernel/FileSystem/Plan9FS/FileSystem.h

@@ -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;

+ 1 - 1
Kernel/FileSystem/VirtualFileSystem.cpp

@@ -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) {