mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Kernel: Allow Ext2FS::flush_writes() to return ErrorOr<void>
This commit is contained in:
parent
28cda85f1f
commit
abcf05801a
8 changed files with 26 additions and 12 deletions
|
@ -305,9 +305,10 @@ void BlockBasedFileSystem::flush_writes_impl()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void BlockBasedFileSystem::flush_writes()
|
ErrorOr<void> BlockBasedFileSystem::flush_writes()
|
||||||
{
|
{
|
||||||
flush_writes_impl();
|
flush_writes_impl();
|
||||||
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ public:
|
||||||
|
|
||||||
u64 device_block_size() const { return m_device_block_size; }
|
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();
|
void flush_writes_impl();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -662,7 +662,7 @@ void Ext2FS::flush_block_group_descriptor_table()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ext2FS::flush_writes()
|
ErrorOr<void> Ext2FS::flush_writes()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_lock);
|
MutexLocker locker(m_lock);
|
||||||
|
@ -670,8 +670,7 @@ void Ext2FS::flush_writes()
|
||||||
auto result = flush_super_block();
|
auto result = flush_super_block();
|
||||||
if (result.is_error()) {
|
if (result.is_error()) {
|
||||||
dbgln("Ext2FS[{}]::flush_writes(): Failed to write superblock: {}", fsid(), result.error());
|
dbgln("Ext2FS[{}]::flush_writes(): Failed to write superblock: {}", fsid(), result.error());
|
||||||
// FIXME: We should handle this error.
|
return result.release_error();
|
||||||
VERIFY_NOT_REACHED();
|
|
||||||
}
|
}
|
||||||
m_super_block_dirty = false;
|
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
|
ErrorOr<NonnullRefPtr<Ext2FSInode>> Ext2FS::build_root_inode() const
|
||||||
|
|
|
@ -77,7 +77,7 @@ private:
|
||||||
ErrorOr<NonnullRefPtr<Inode>> get_inode(InodeIdentifier) const;
|
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_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);
|
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_index() const;
|
||||||
BlockIndex first_block_of_block_group_descriptors() const;
|
BlockIndex first_block_of_block_group_descriptors() const;
|
||||||
|
|
|
@ -51,7 +51,7 @@ public:
|
||||||
u8 file_type { 0 };
|
u8 file_type { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
virtual void flush_writes() { }
|
virtual ErrorOr<void> flush_writes() { return {}; }
|
||||||
|
|
||||||
u64 logical_block_size() const { return m_logical_block_size; }
|
u64 logical_block_size() const { return m_logical_block_size; }
|
||||||
size_t fragment_size() const { return m_fragment_size; }
|
size_t fragment_size() const { return m_fragment_size; }
|
||||||
|
|
|
@ -48,7 +48,11 @@ void Inode::sync()
|
||||||
{
|
{
|
||||||
if (is_metadata_dirty())
|
if (is_metadata_dirty())
|
||||||
(void)flush_metadata();
|
(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
|
ErrorOr<NonnullRefPtr<Custody>> Inode::resolve_as_link(Credentials const& credentials, Custody& base, RefPtr<Custody>* out_parent, int options, int symlink_recursion_level) const
|
||||||
|
|
|
@ -259,8 +259,12 @@ void VirtualFileSystem::sync_filesystems()
|
||||||
file_systems.append(fs);
|
file_systems.append(fs);
|
||||||
});
|
});
|
||||||
|
|
||||||
for (auto& fs : file_systems)
|
for (auto& fs : file_systems) {
|
||||||
fs->flush_writes();
|
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()
|
void VirtualFileSystem::lock_all_filesystems()
|
||||||
|
|
|
@ -106,7 +106,7 @@ ErrorOr<void> PowerStateSwitchTask::perform_shutdown(PowerStateSwitchTask::DoReb
|
||||||
|
|
||||||
while (!mounts.is_empty()) {
|
while (!mounts.is_empty()) {
|
||||||
auto& mount = mounts.take_last();
|
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_path = TRY(mount.absolute_path());
|
||||||
auto& mount_inode = mount.guest();
|
auto& mount_inode = mount.guest();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue