feat(filesystem_v2): add cache_all_blocks method

This commit is contained in:
Marcus Holland-Moritz 2025-04-04 22:52:16 +02:00
parent 5717afa562
commit 2ad8ae4cdf
4 changed files with 14 additions and 0 deletions

View File

@ -361,6 +361,8 @@ class filesystem_v2 {
return impl_->cache_blocks_by_category(category);
}
void cache_all_blocks() const { impl_->cache_all_blocks(); }
class impl {
public:
virtual ~impl() = default;
@ -457,6 +459,7 @@ class filesystem_v2 {
virtual std::optional<std::string>
get_block_category(size_t block_number) const = 0;
virtual void cache_blocks_by_category(std::string_view category) const = 0;
virtual void cache_all_blocks() const = 0;
};
private:

View File

@ -105,6 +105,8 @@ class inode_reader_v2 {
impl_->cache_blocks(blocks);
}
void cache_all_blocks() const { impl_->cache_all_blocks(); }
class impl {
public:
virtual ~impl() = default;
@ -127,6 +129,7 @@ class inode_reader_v2 {
virtual void set_cache_tidy_config(cache_tidy_config const& cfg) = 0;
virtual size_t num_blocks() const = 0;
virtual void cache_blocks(std::span<size_t const> blocks) const = 0;
virtual void cache_all_blocks() const = 0;
};
private:

View File

@ -316,6 +316,8 @@ class filesystem_ final : public filesystem_v2::impl {
ir_.cache_blocks(meta_.get_block_numbers_by_category(category));
}
void cache_all_blocks() const override { ir_.cache_all_blocks(); }
private:
filesystem_info const* get_info(fsinfo_options const& opts) const;
void check_section(fs_section const& section) const;

View File

@ -158,6 +158,12 @@ class inode_reader_ final : public inode_reader_v2::impl {
}
}
void cache_all_blocks() const override {
for (size_t i = 0; i < cache_.block_count(); ++i) {
cache_.get(i, 0, 1);
}
}
private:
using offset_cache_type =
basic_offset_cache<uint32_t, file_off_t, size_t,