mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-28 23:39:02 +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:
parent
97c799576a
commit
10c470e95f
Notes:
sideshowbarker
2024-07-19 16:10:46 +09:00
Author: https://github.com/awesomekling
Commit: 10c470e95f
12 changed files with 177 additions and 152 deletions
|
@ -4,12 +4,35 @@
|
|||
#include "UnixTypes.h"
|
||||
#include <AK/Buffer.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include "ext2_fs.h"
|
||||
|
||||
struct ext2_group_desc;
|
||||
struct ext2_inode;
|
||||
struct ext2_super_block;
|
||||
|
||||
class Ext2FileSystem;
|
||||
|
||||
class Ext2Inode final : public CoreInode {
|
||||
friend class Ext2FileSystem;
|
||||
public:
|
||||
virtual ~Ext2Inode() override;
|
||||
|
||||
virtual Unix::ssize_t read_bytes(Unix::off_t, Unix::size_t, byte* buffer, FileDescriptor*) override;
|
||||
|
||||
size_t size() const { return m_raw_inode.i_size; }
|
||||
bool is_symlink() const { return isSymbolicLink(m_raw_inode.i_mode); }
|
||||
|
||||
private:
|
||||
Ext2FileSystem& fs();
|
||||
Ext2Inode(Ext2FileSystem&, unsigned index, const ext2_inode&);
|
||||
|
||||
SpinLock m_lock;
|
||||
Vector<unsigned> m_block_list;
|
||||
ext2_inode m_raw_inode;
|
||||
};
|
||||
|
||||
class Ext2FileSystem final : public DiskBackedFileSystem {
|
||||
friend class Ext2Inode;
|
||||
public:
|
||||
static RetainPtr<Ext2FileSystem> create(RetainPtr<DiskDevice>&&);
|
||||
virtual ~Ext2FileSystem() override;
|
||||
|
@ -49,6 +72,7 @@ private:
|
|||
virtual Unix::ssize_t readInodeBytes(InodeIdentifier, Unix::off_t offset, Unix::size_t count, byte* buffer, FileDescriptor*) const override;
|
||||
virtual InodeIdentifier makeDirectory(InodeIdentifier parentInode, const String& name, Unix::mode_t) override;
|
||||
virtual InodeIdentifier findParentOfInode(InodeIdentifier) const override;
|
||||
virtual RetainPtr<CoreInode> get_inode(InodeIdentifier) override;
|
||||
|
||||
bool isDirectoryInode(unsigned) const;
|
||||
unsigned allocateInode(unsigned preferredGroup, unsigned expectedSize);
|
||||
|
@ -77,5 +101,12 @@ private:
|
|||
|
||||
mutable SpinLock m_inodeCacheLock;
|
||||
mutable HashMap<unsigned, RetainPtr<CachedExt2InodeImpl>> m_inodeCache;
|
||||
|
||||
mutable SpinLock m_inode_cache_lock;
|
||||
mutable HashMap<BlockIndex, RetainPtr<Ext2Inode>> m_inode_cache;
|
||||
};
|
||||
|
||||
inline Ext2FileSystem& Ext2Inode::fs()
|
||||
{
|
||||
return static_cast<Ext2FileSystem&>(CoreInode::fs());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue