mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
59ed235c85
Files opened with O_DIRECT will now bypass the disk cache in read/write operations (though metadata operations will still hit the disk cache.) This will allow us to test actual disk performance instead of testing disk *cache* performance, if that's what we want. :^) There's room for improvment here, we're very aggressively flushing any dirty cache entries for the specific block before reading/writing that block. This is done by walking the entire cache, which may be slow.
36 lines
1,015 B
C++
36 lines
1,015 B
C++
#pragma once
|
|
|
|
#include "FileSystem.h"
|
|
#include <AK/ByteBuffer.h>
|
|
|
|
class DiskCache;
|
|
|
|
class DiskBackedFS : public FS {
|
|
public:
|
|
virtual ~DiskBackedFS() override;
|
|
|
|
virtual bool is_disk_backed() const override { return true; }
|
|
|
|
DiskDevice& device() { return *m_device; }
|
|
const DiskDevice& device() const { return *m_device; }
|
|
|
|
virtual void flush_writes() override;
|
|
|
|
void flush_writes_impl();
|
|
|
|
protected:
|
|
explicit DiskBackedFS(NonnullRefPtr<DiskDevice>&&);
|
|
|
|
bool read_block(unsigned index, u8* buffer, FileDescription* = nullptr) const;
|
|
bool read_blocks(unsigned index, unsigned count, u8* buffer, FileDescription* = nullptr) const;
|
|
|
|
bool write_block(unsigned index, const u8*, FileDescription* = nullptr);
|
|
bool write_blocks(unsigned index, unsigned count, const u8*, FileDescription* = nullptr);
|
|
|
|
private:
|
|
DiskCache& cache() const;
|
|
void flush_specific_block_if_needed(unsigned index);
|
|
|
|
NonnullRefPtr<DiskDevice> m_device;
|
|
mutable OwnPtr<DiskCache> m_cache;
|
|
};
|