From 6f69d5204fecf151ca0c4a1c0ca904c13ae8d095 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 21 Oct 2021 17:01:52 +0200 Subject: [PATCH] Kernel: Make Inode::flush_metadata() return a KResult Even if this goes nowhere yet, we have to start building an error propagation path somewhere. --- Kernel/FileSystem/DevPtsFS.cpp | 3 ++- Kernel/FileSystem/DevPtsFS.h | 2 +- Kernel/FileSystem/DevTmpFS.cpp | 3 ++- Kernel/FileSystem/DevTmpFS.h | 2 +- Kernel/FileSystem/Ext2FileSystem.cpp | 3 ++- Kernel/FileSystem/Ext2FileSystem.h | 2 +- Kernel/FileSystem/ISO9660FileSystem.cpp | 3 ++- Kernel/FileSystem/ISO9660FileSystem.h | 2 +- Kernel/FileSystem/Inode.cpp | 6 +++--- Kernel/FileSystem/Inode.h | 2 +- Kernel/FileSystem/Plan9FileSystem.cpp | 3 ++- Kernel/FileSystem/Plan9FileSystem.h | 2 +- Kernel/FileSystem/ProcFS.cpp | 3 ++- Kernel/FileSystem/ProcFS.h | 2 +- Kernel/FileSystem/SysFS.cpp | 3 ++- Kernel/FileSystem/SysFS.h | 2 +- Kernel/FileSystem/TmpFS.cpp | 3 ++- Kernel/FileSystem/TmpFS.h | 2 +- 18 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index 4c64ef1958a..b96cb5bf13d 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -145,8 +145,9 @@ KResultOr> DevPtsFSInode::lookup(StringView name) }); } -void DevPtsFSInode::flush_metadata() +KResult DevPtsFSInode::flush_metadata() { + return KSuccess; } KResult DevPtsFSInode::add_child(Inode&, const StringView&, mode_t) diff --git a/Kernel/FileSystem/DevPtsFS.h b/Kernel/FileSystem/DevPtsFS.h index 11a336039ba..e907a521777 100644 --- a/Kernel/FileSystem/DevPtsFS.h +++ b/Kernel/FileSystem/DevPtsFS.h @@ -51,7 +51,7 @@ private: virtual InodeMetadata metadata() const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual KResult add_child(Inode&, const StringView& name, mode_t) override; diff --git a/Kernel/FileSystem/DevTmpFS.cpp b/Kernel/FileSystem/DevTmpFS.cpp index 93df86d516c..8552bb2eaa3 100644 --- a/Kernel/FileSystem/DevTmpFS.cpp +++ b/Kernel/FileSystem/DevTmpFS.cpp @@ -70,8 +70,9 @@ KResultOr> DevTmpFSInode::lookup(StringView) VERIFY_NOT_REACHED(); } -void DevTmpFSInode::flush_metadata() +KResult DevTmpFSInode::flush_metadata() { + return KSuccess; } KResultOr DevTmpFSInode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) diff --git a/Kernel/FileSystem/DevTmpFS.h b/Kernel/FileSystem/DevTmpFS.h index d2545599ead..418252d6afa 100644 --- a/Kernel/FileSystem/DevTmpFS.h +++ b/Kernel/FileSystem/DevTmpFS.h @@ -51,7 +51,7 @@ protected: virtual KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual InodeMetadata metadata() const override final; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index f50ba218499..98a9979dc0c 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -773,7 +773,7 @@ InodeMetadata Ext2FSInode::metadata() const return metadata; } -void Ext2FSInode::flush_metadata() +KResult Ext2FSInode::flush_metadata() { MutexLocker locker(m_inode_lock); dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]::flush_metadata(): Flushing inode", identifier()); @@ -786,6 +786,7 @@ void Ext2FSInode::flush_metadata() } } set_metadata_dirty(false); + return KSuccess; } KResultOr> Ext2FS::get_inode(InodeIdentifier inode) const diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 1da3ccf9aa3..078152daf1f 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -42,7 +42,7 @@ private: virtual InodeMetadata metadata() const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual KResult add_child(Inode& child, const StringView& name, mode_t) override; diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp index a964f1945fc..492433f3d73 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.cpp +++ b/Kernel/FileSystem/ISO9660FileSystem.cpp @@ -499,8 +499,9 @@ KResultOr> ISO9660Inode::lookup(StringView name) return inode.release_nonnull(); } -void ISO9660Inode::flush_metadata() +KResult ISO9660Inode::flush_metadata() { + return KSuccess; } KResultOr ISO9660Inode::write_bytes(off_t, size_t, const UserOrKernelBuffer&, OpenFileDescription*) diff --git a/Kernel/FileSystem/ISO9660FileSystem.h b/Kernel/FileSystem/ISO9660FileSystem.h index f0bb51832dd..5db938cdd8b 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.h +++ b/Kernel/FileSystem/ISO9660FileSystem.h @@ -351,7 +351,7 @@ public: virtual InodeMetadata metadata() const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual KResult add_child(Inode&, const StringView& name, mode_t) override; diff --git a/Kernel/FileSystem/Inode.cpp b/Kernel/FileSystem/Inode.cpp index 799e6cbb7a6..dd53e593d9f 100644 --- a/Kernel/FileSystem/Inode.cpp +++ b/Kernel/FileSystem/Inode.cpp @@ -41,14 +41,14 @@ void Inode::sync_all() for (auto& inode : inodes) { VERIFY(inode.is_metadata_dirty()); - inode.flush_metadata(); + (void)inode.flush_metadata(); } } void Inode::sync() { if (is_metadata_dirty()) - flush_metadata(); + (void)flush_metadata(); fs().flush_writes(); } @@ -103,7 +103,7 @@ void Inode::will_be_destroyed() { MutexLocker locker(m_inode_lock); if (m_metadata_dirty) - flush_metadata(); + (void)flush_metadata(); } KResult Inode::set_atime(time_t) diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 4356915a82a..eddb3030c1b 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -81,7 +81,7 @@ public: virtual KResult increment_link_count(); virtual KResult decrement_link_count(); - virtual void flush_metadata() = 0; + virtual KResult flush_metadata() = 0; void will_be_destroyed(); diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index d239f4a7411..3ad1158577e 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -822,9 +822,10 @@ InodeMetadata Plan9FSInode::metadata() const return metadata; } -void Plan9FSInode::flush_metadata() +KResult Plan9FSInode::flush_metadata() { // Do nothing. + return KSuccess; } KResult Plan9FSInode::traverse_as_directory(Function callback) const diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h index 1dfe4f7e55d..835432b44e2 100644 --- a/Kernel/FileSystem/Plan9FileSystem.h +++ b/Kernel/FileSystem/Plan9FileSystem.h @@ -155,7 +155,7 @@ public: // ^Inode virtual InodeMetadata metadata() const override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& data, OpenFileDescription*) override; virtual KResult traverse_as_directory(Function) const override; diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index fd88f671a42..de36b0513f0 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -70,8 +70,9 @@ ProcFSInode::~ProcFSInode() { } -void ProcFSInode::flush_metadata() +KResult ProcFSInode::flush_metadata() { + return KSuccess; } KResult ProcFSInode::add_child(Inode&, const StringView&, mode_t) diff --git a/Kernel/FileSystem/ProcFS.h b/Kernel/FileSystem/ProcFS.h index 966cfd55a41..abd525ea5b2 100644 --- a/Kernel/FileSystem/ProcFS.h +++ b/Kernel/FileSystem/ProcFS.h @@ -56,7 +56,7 @@ protected: // ^Inode virtual KResult attach(OpenFileDescription& description) = 0; virtual void did_seek(OpenFileDescription&, off_t) = 0; - virtual void flush_metadata() override final; + virtual KResult flush_metadata() override final; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override final; virtual KResult add_child(Inode&, const StringView& name, mode_t) override final; virtual KResult remove_child(const StringView& name) override final; diff --git a/Kernel/FileSystem/SysFS.cpp b/Kernel/FileSystem/SysFS.cpp index cc26614663c..e45da8a7337 100644 --- a/Kernel/FileSystem/SysFS.cpp +++ b/Kernel/FileSystem/SysFS.cpp @@ -148,8 +148,9 @@ InodeMetadata SysFSInode::metadata() const return metadata; } -void SysFSInode::flush_metadata() +KResult SysFSInode::flush_metadata() { + return KSuccess; } KResultOr SysFSInode::write_bytes(off_t offset, size_t count, UserOrKernelBuffer const& buffer, OpenFileDescription* fd) diff --git a/Kernel/FileSystem/SysFS.h b/Kernel/FileSystem/SysFS.h index 4b8bf05c946..d62781f48c4 100644 --- a/Kernel/FileSystem/SysFS.h +++ b/Kernel/FileSystem/SysFS.h @@ -137,7 +137,7 @@ protected: virtual KResultOr read_bytes(off_t, size_t, UserOrKernelBuffer& buffer, OpenFileDescription*) const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual InodeMetadata metadata() const override; virtual KResultOr write_bytes(off_t, size_t, UserOrKernelBuffer const&, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index f1e43397e28..17115a093a9 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -216,7 +216,7 @@ void TmpFSInode::notify_watchers() set_metadata_dirty(false); } -void TmpFSInode::flush_metadata() +KResult TmpFSInode::flush_metadata() { // We don't really have any metadata that could become dirty. // The only reason we even call set_metadata_dirty() is @@ -224,6 +224,7 @@ void TmpFSInode::flush_metadata() // switched to a different mechanism, we can stop ever marking // our metadata as dirty at all. set_metadata_dirty(false); + return KSuccess; } KResult TmpFSInode::chmod(mode_t mode) diff --git a/Kernel/FileSystem/TmpFS.h b/Kernel/FileSystem/TmpFS.h index 87441885b66..c13cc908f27 100644 --- a/Kernel/FileSystem/TmpFS.h +++ b/Kernel/FileSystem/TmpFS.h @@ -56,7 +56,7 @@ public: virtual InodeMetadata metadata() const override; virtual KResult traverse_as_directory(Function) const override; virtual KResultOr> lookup(StringView name) override; - virtual void flush_metadata() override; + virtual KResult flush_metadata() override; virtual KResultOr write_bytes(off_t, size_t, const UserOrKernelBuffer& buffer, OpenFileDescription*) override; virtual KResultOr> create_child(StringView name, mode_t, dev_t, UserID, GroupID) override; virtual KResult add_child(Inode&, const StringView& name, mode_t) override;