1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:15:07 +00:00

Make page_in_from_vnode 2x faster.

...by adding a new class called Ext2Inode that inherits CoreInode.
The idea is that a vnode will wrap a CoreInode rather than InodeIdentifier.
Each CoreInode subclass can keep whatever caches they like.

Right now, Ext2Inode caches the list of block indices since it can be very
expensive to retrieve.
This commit is contained in:
Andreas Kling 2018-11-13 13:02:39 +01:00
parent 97c799576a
commit 10c470e95f
12 changed files with 177 additions and 152 deletions

View file

@ -17,6 +17,31 @@
static const dword mepoch = 476763780;
class FileDescriptor;
class FileSystem;
class CoreInode : public Retainable<CoreInode> {
public:
virtual ~CoreInode();
FileSystem& fs() const { return m_fs; }
unsigned fsid() const;
unsigned index() const { return m_index; }
InodeIdentifier identifier() const { return { fsid(), index() }; }
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) = 0;
protected:
CoreInode(FileSystem& fs, unsigned index)
: m_fs(fs)
, m_index(index)
{
}
private:
FileSystem& m_fs;
unsigned m_index { 0 };
};
class FileSystem : public Retainable<FileSystem> {
public:
@ -50,6 +75,8 @@ public:
virtual InodeIdentifier findParentOfInode(InodeIdentifier) const = 0;
virtual RetainPtr<CoreInode> get_inode(InodeIdentifier) = 0;
InodeIdentifier childOfDirectoryInodeWithName(InodeIdentifier, const String& name) const;
ByteBuffer readEntireInode(InodeIdentifier, FileDescriptor* = nullptr) const;
String nameOfChildInDirectory(InodeIdentifier parent, InodeIdentifier child) const;
@ -83,6 +110,11 @@ inline bool InodeIdentifier::isRootInode() const
return (*this) == fileSystem()->rootInode();
}
inline unsigned CoreInode::fsid() const
{
return m_fs.id();
}
namespace AK {
template<>