Kernel: Allow Ext2FS::flush_writes() to return ErrorOr<void>

This commit is contained in:
Zak-K-Abdi 2023-08-01 07:48:43 +01:00 committed by Sam Atkins
parent 28cda85f1f
commit abcf05801a
Notes: sideshowbarker 2024-07-17 20:33:50 +09:00
8 changed files with 26 additions and 12 deletions

View file

@ -305,9 +305,10 @@ void BlockBasedFileSystem::flush_writes_impl()
});
}
void BlockBasedFileSystem::flush_writes()
ErrorOr<void> BlockBasedFileSystem::flush_writes()
{
flush_writes_impl();
return {};
}
}

View file

@ -19,7 +19,7 @@ public:
u64 device_block_size() const { return m_device_block_size; }
virtual void flush_writes() override;
virtual ErrorOr<void> flush_writes() override;
void flush_writes_impl();
protected:

View file

@ -662,7 +662,7 @@ void Ext2FS::flush_block_group_descriptor_table()
}
}
void Ext2FS::flush_writes()
ErrorOr<void> Ext2FS::flush_writes()
{
{
MutexLocker locker(m_lock);
@ -670,8 +670,7 @@ void Ext2FS::flush_writes()
auto result = flush_super_block();
if (result.is_error()) {
dbgln("Ext2FS[{}]::flush_writes(): Failed to write superblock: {}", fsid(), result.error());
// FIXME: We should handle this error.
VERIFY_NOT_REACHED();
return result.release_error();
}
m_super_block_dirty = false;
}
@ -708,7 +707,13 @@ void Ext2FS::flush_writes()
});
}
BlockBasedFileSystem::flush_writes();
auto result = BlockBasedFileSystem::flush_writes();
if (result.is_error()) {
dbgln("Ext2FS[{}]::flush_writes(): Failed to flush writes: {}", BlockBasedFileSystem::fsid(), result.error());
return result.release_error();
}
return {};
}
ErrorOr<NonnullRefPtr<Ext2FSInode>> Ext2FS::build_root_inode() const

View file

@ -77,7 +77,7 @@ private:
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);
virtual void flush_writes() override;
virtual ErrorOr<void> flush_writes() override;
BlockIndex first_block_index() const;
BlockIndex first_block_of_block_group_descriptors() const;

View file

@ -51,7 +51,7 @@ public:
u8 file_type { 0 };
};
virtual void flush_writes() { }
virtual ErrorOr<void> flush_writes() { return {}; }
u64 logical_block_size() const { return m_logical_block_size; }
size_t fragment_size() const { return m_fragment_size; }

View file

@ -48,7 +48,11 @@ void Inode::sync()
{
if (is_metadata_dirty())
(void)flush_metadata();
fs().flush_writes();
auto result = fs().flush_writes();
if (result.is_error()) {
// TODO: Figure out how to propagate error to a higher function.
}
}
ErrorOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Credentials const& credentials, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const

View file

@ -259,8 +259,12 @@ void VirtualFileSystem::sync_filesystems()
file_systems.append(fs);
});
for (auto& fs : file_systems)
fs->flush_writes();
for (auto& fs : file_systems) {
auto result = fs->flush_writes();
if (result.is_error()) {
//TODO: Figure out how to propagate error to a higher function.
}
}
}
void VirtualFileSystem::lock_all_filesystems()

View file

@ -106,7 +106,7 @@ ErrorOr<void> PowerStateSwitchTask::perform_shutdown(PowerStateSwitchTask::DoReb
while (!mounts.is_empty()) {
auto& mount = mounts.take_last();
mount.guest_fs().flush_writes();
TRY(mount.guest_fs().flush_writes());
auto mount_path = TRY(mount.absolute_path());
auto& mount_inode = mount.guest();