summaryrefslogtreecommitdiff
path: root/Kernel/FileSystem/FileBackedFileSystem.h
diff options
context:
space:
mode:
authorSergey Bugaev <bugaevc@serenityos.org>2020-05-18 21:55:08 +0300
committerAndreas Kling <kling@serenityos.org>2020-05-19 11:07:35 +0200
commit88e23113ae4983a4281f864370cfee5e2e5b945d (patch)
tree0600af57cccd46f040b8f476912a0e7cd600cb1d /Kernel/FileSystem/FileBackedFileSystem.h
parentde4b7d9c21448b2d61a0f7770d654de5718c7438 (diff)
downloadserenity-88e23113ae4983a4281f864370cfee5e2e5b945d.zip
Kernel: Tweak FileBackedFS API to avoid intermediary copies
read_block() and write_block() now accept the count (how many bytes to read or write) and offset (where in the block to start; defaults to 0). Using these new APIs, we can avoid doing copies between intermediary buffers in a lot more cases. Hopefully this improves performance or something.
Diffstat (limited to 'Kernel/FileSystem/FileBackedFileSystem.h')
-rw-r--r--Kernel/FileSystem/FileBackedFileSystem.h14
1 files changed, 7 insertions, 7 deletions
diff --git a/Kernel/FileSystem/FileBackedFileSystem.h b/Kernel/FileSystem/FileBackedFileSystem.h
index 498a35595e..cb9c2d1c7b 100644
--- a/Kernel/FileSystem/FileBackedFileSystem.h
+++ b/Kernel/FileSystem/FileBackedFileSystem.h
@@ -36,8 +36,6 @@ class FileBackedFS : public FS {
public:
virtual ~FileBackedFS() override;
- virtual bool is_file_backed() const override { return true; }
-
File& file() { return m_file_description->file(); }
FileDescription& file_description() { return *m_file_description; }
const File& file() const { return m_file_description->file(); }
@@ -52,8 +50,8 @@ public:
protected:
explicit FileBackedFS(FileDescription&);
- bool read_block(unsigned index, u8* buffer, FileDescription* = nullptr) const;
- bool read_blocks(unsigned index, unsigned count, u8* buffer, FileDescription* = nullptr) const;
+ bool read_block(unsigned index, u8* buffer, size_t count, size_t offset = 0, bool allow_cache = true) const;
+ bool read_blocks(unsigned index, unsigned count, u8* buffer, bool allow_cache = true) const;
bool raw_read(unsigned index, u8* buffer);
bool raw_write(unsigned index, const u8* buffer);
@@ -61,16 +59,18 @@ protected:
bool raw_read_blocks(unsigned index, size_t count, u8* buffer);
bool raw_write_blocks(unsigned index, size_t count, const u8* buffer);
- bool write_block(unsigned index, const u8*, FileDescription* = nullptr);
- bool write_blocks(unsigned index, unsigned count, const u8*, FileDescription* = nullptr);
+ bool write_block(unsigned index, const u8* buffer, size_t count, size_t offset = 0, bool allow_cache = true);
+ bool write_blocks(unsigned index, unsigned count, const u8*, bool allow_cache = true);
size_t m_logical_block_size { 512 };
private:
+ virtual bool is_file_backed() const override { return true; }
+
DiskCache& cache() const;
void flush_specific_block_if_needed(unsigned index);
- NonnullRefPtr<FileDescription> m_file_description;
+ mutable NonnullRefPtr<FileDescription> m_file_description;
mutable OwnPtr<DiskCache> m_cache;
};